Skip to content

ProgressBar item_show_func displays the previous item #1353

Closed

Description

@JoelEager

I've noticed a bug with the item_show_func option for click.progressbar where the progress bar ends up showing the previous item instead of the current one.

The issue seems to be that ProgressBar.generator() will only render the progress bar after the current item has been processed. As a result, the previous item is visible on screen while the current one is in processing.

I think this change to lines 285-288 should fix the issue:

for rv in self.iter:
    self.current_item = rv
    self.render_progress()
    yield rv
    self.make_step(1)

Activity

  1. davidism commented on Jul 12, 2019

    @davidism
    Member

    You can just as easily argue that the current behavior is correct as it shows the last completed task. Which is correct?

  2. JoelEager commented on Jul 12, 2019

    @JoelEager
    ContributorAuthor

    The documentation, to me at least, seems to indicate that the intended behavior is to display the current item as opposed to the previous one. So I guess this is less of a bug and more of a case of the docs and implementation being out of sync.

  3. davidism commented on Jul 12, 2019

    @davidism
    Member

    Still not sure, but would you mind making a PR so I can take a look at it?

  4. JoelEager commented on Jul 12, 2019

    @JoelEager
    ContributorAuthor

    Sure, I'll try to put one up this evening.

  5. added a commit that references this issue on Jul 13, 2019
  6. nip3o commented on Oct 2, 2020

    @nip3o

    Any updates on this? I find the current behaviour quite confusing, especially when iterating over a single item (for example over a queryset which has been filtered by primary key) – then the progressbar is not shown at all.

  7. BALaka-18 commented on Mar 2, 2021

    @BALaka-18
    Contributor

    @davidism I'm from MLH fellowship, would like to work on this Issue.

  8. davidism commented on Mar 2, 2021

    @davidism
    Member

    @BALaka-18 there is already a PR for this, but it wasn't linked for some reason. Sorry about that.

  9. BALaka-18 commented on Mar 2, 2021

    @BALaka-18
    Contributor

    @BALaka-18 there is already a PR for this, but it wasn't linked for some reason. Sorry about that.

    Sure ! Not a problem.

  10. added this to the 8.0.0 milestone on Mar 4, 2021
  11. JoelEager commented on Mar 4, 2021

    @JoelEager
    ContributorAuthor

    Thanks for taking the time to revive and resolve this. I'm looking forward to making use of your fix in the future.

  12. locked as resolved and limited conversation to collaborators on Mar 19, 2021
  13. added
    help output
    and removed on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help output

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions