Skip to content

branch with generic type narrowed to <nothing> treated as reachable #11976

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
DetachHead opened this issue Jan 12, 2022 · 6 comments
Closed

branch with generic type narrowed to <nothing> treated as reachable #11976

DetachHead opened this issue Jan 12, 2022 · 6 comments
Labels
bug mypy got something wrong

Comments

@DetachHead
Copy link
Contributor

DetachHead commented Jan 12, 2022

@DetachHead DetachHead added the bug mypy got something wrong label Jan 12, 2022
@DetachHead DetachHead changed the title union with generic type narrowed to <nothing> treated as reachable branch with generic type narrowed to <nothing> treated as reachable Jan 12, 2022
@sobolevn
Copy link
Member

sobolevn commented Jan 13, 2022

Tested with mypy out/ex.py --warn-unreachable --warn-unused-ignore --show-traceback

Снимок экрана 2022-01-13 в 13 12 08

I don't see a problem here 🤔

There's no error generated (because reveal_type is not counted as unreachable code on purpose). So, no error = unused # type: ignore.

Do you agree?

@KotlinIsland
Copy link
Contributor

I don't see a problem here 🤔

There's no error generated (because reveal_type is not counted as unreachable code on purpose). So, no error = unused # type: ignore.

@sobolevn That is not true, a reveal_type in unreachable code is not analyzed at all:

a = 1
if False:
    reveal_type(a)  # error: Statement is unreachable
if False:
    reveal_type(a)  # type: ignore[unreachable]

@sobolevn
Copy link
Member

sobolevn commented Feb 8, 2022

Please, see #11443

@DetachHead
Copy link
Contributor Author

this seems to be fixed now, though perhaps a test should be added so it doesn't break again

@erictraut
Copy link

Yes, this bug appears to have been fixed. This doesn't repro with mypy 1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

5 participants