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

False positive with Python 2 old-style raise statement #11742

Closed
JukkaL opened this issue Dec 14, 2021 · 0 comments · Fixed by #11786
Closed

False positive with Python 2 old-style raise statement #11742

JukkaL opened this issue Dec 14, 2021 · 0 comments · Fixed by #11786
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 14, 2021

This generates an error, even though it's valid at runtime:

raise Exception(), None, None  # First argument must be BaseException subtype

An exception instance is valid if the second object is None: https://docs.python.org/2/reference/simple_stmts.html#the-raise-statement

It looks like #11289 forgot to handle this case.

Since this is a regression and we are close to cutting a release branch, I'm planning to revert #11289 for now. It can be merged again with a fix to the special case.

cc @sobolevn

@JukkaL JukkaL added bug mypy got something wrong false-positive mypy gave an error on correct code labels Dec 14, 2021
JukkaL added a commit that referenced this issue Dec 14, 2021
JukkaL added a commit that referenced this issue Dec 14, 2021
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
JukkaL pushed a commit that referenced this issue Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant