Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy error on progress bar usage #1892

decaz opened this issue May 13, 2021 · 2 comments

mypy error on progress bar usage #1892

decaz opened this issue May 13, 2021 · 2 comments


Copy link

decaz commented May 13, 2021

import click

with click.progressbar([1, 2, 3]) as bar:
    for x in bar:

mypy error:

$ mypy error: "Iterable[<nothing>]" has no attribute "__next__"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)


  • Python version: 3.9.5
  • Click version: 8.0.0
  • mypy version: 0.812
Copy link

jcrotts commented May 13, 2021

Changing the return type in ProgressBar.__iter__

def __iter__(self) -> t.Iterable[V]:
from t.Iterable[V] to t.Iterator[V] fixes the mypy error, but it requires that you declare the type of x.
I'm also not sure if it's the correct thing to do type wise.

Copy link

I'm working in this, going to use generics since it shouldn't affect performance in this case

@davidism davidism added this to the 8.0.1 milestone May 13, 2021
@davidism davidism self-assigned this May 13, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants