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

Another --warn-unreachable false positive #7207

Closed
scop opened this issue Jul 14, 2019 · 2 comments
Closed

Another --warn-unreachable false positive #7207

scop opened this issue Jul 14, 2019 · 2 comments

Comments

@scop
Copy link
Contributor

scop commented Jul 14, 2019

I'm not sure if this is the same issue as #7204, but here's another --warn-unreahcable false positive with a much smaller test case:

from numbers import Number

def test(x: float) -> None:
    if not isinstance(x, Number):
        raise
    print("Not unreachable!")

...gives with mypy 0.720:

t.py:6: error: Statement is unreachable

Assuming mypy relies on x always being a float like the type hint says, the "not isinstance" is actually always False and I guess it would be legitimate for the error to be issued on line 5 (raise). But surely the print statement on line 6 is never unreachable, right?

@JelleZijlstra
Copy link
Member

This isn't so much an issue with --warn-unreachable as with mypy not understanding the numbers module. See #3186 for prior discussion.

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 16, 2019

Closing since fixing #3186 is the correct fix for this as well.

@JukkaL JukkaL closed this as completed Jul 16, 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

3 participants