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

(🐞) 'warn-unreachable' doesn't reactivate after it is suppressed with a <nothing> statement #11437

Closed
KotlinIsland opened this issue Nov 3, 2021 · 4 comments
Labels
bug mypy got something wrong topic-reachability Detecting unreachable code

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Nov 3, 2021

from typing import NoReturn

def foo() -> NoReturn:
    raise Exception

def bar() -> NoReturn:
    foo()
    foo()
    print("hi")  # no warning

The first call to foo is suppress the unreachable intentionally, (same with the second). But the print("hi) should definitely show an unreachable error.

@KotlinIsland KotlinIsland added the bug mypy got something wrong label Nov 3, 2021
@sobolevn
Copy link
Member

sobolevn commented Nov 3, 2021

Looks like this is intentional: https://github.com/python/mypy/blame/5703becbbe9be5006ed0d2d998dd4a793f1aedd0/test-data/unit/check-unreachable-code.test#L905

It can be easily changed, but I am not sure that this won't break a lot of existing code.
Let's try it out.

@KotlinIsland KotlinIsland reopened this Mar 21, 2022
@KotlinIsland KotlinIsland changed the title warn-unreachable doesn't work when two NoReturn functions are called (🐞) 'warn-unreachable' doesn't reactivate after it is suppressed with a <nothing> statement Mar 21, 2022
@KotlinIsland
Copy link
Contributor Author

topic-reachability Detecting unreachable code

@JelleZijlstra JelleZijlstra added the topic-reachability Detecting unreachable code label Mar 21, 2022
@erictraut
Copy link

It appears that the latest version of mypy (1.5) behaves as expected here, so I think this is safe to close.

@ikonst
Copy link
Contributor

ikonst commented Aug 12, 2023

Likely fixed by #15386

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

Successfully merging a pull request may close this issue.

6 participants