Skip to content

Regression in 0.660 regarding StopIteration #6209

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

Closed
boustrophedon opened this issue Jan 17, 2019 · 3 comments
Closed

Regression in 0.660 regarding StopIteration #6209

boustrophedon opened this issue Jan 17, 2019 · 3 comments

Comments

@boustrophedon
Copy link

I'm not really sure if this is a regression or if this is mypy picking up something new, but if so I don't understand why.

The documentation for StopIteration says that "The exception object has a single attribute value, which is given as an argument when constructing the exception, and defaults to None." I don't get an error that I'm using the optional as a non-optional in my original code with 0.650, so probably something is wrong there anyway.

def main() -> None:
    s = StopIteration("hello")
    print('value' in dir(s))
    print(s.value)

if __name__ == '__main__':
    main()

commands to reproduce:

python --version
# Python 3.7.1
python -m venv .
source bin/activate
pip install --upgrade pip # not necessary for reproduction
pip install mypy==0.650
mypy test.py
# no output
pip install mypy==0.660
mypy test.py
# test.py:4: error: "StopIteration" has no attribute "value"`

However, running python test.py shows that StopIteration definitely has a value attribute:

python test.py
# True
# hello
@JelleZijlstra
Copy link
Member

Looks like this was introduced in python/typeshed#2533. I will submit a fix to typeshed now.

@boustrophedon
Copy link
Author

Thanks!

@JelleZijlstra
Copy link
Member

Fixed in typeshed now; the fix should get published with the next mypy release.

My sense is that this bug isn't bad enough to warrant an emergency release, but cc @msullivan as the release manager.

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this issue Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants