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

Spurious "return statement in function which does not return" #13014

Closed
bwo opened this issue Jun 23, 2022 · 1 comment
Closed

Spurious "return statement in function which does not return" #13014

bwo opened this issue Jun 23, 2022 · 1 comment
Labels
bug mypy got something wrong

Comments

@bwo
Copy link
Contributor

bwo commented Jun 23, 2022

Consider:

import sys
from typing import NoReturn, Callable


def foo() -> NoReturn:
    sys.exit(1)


def bar() -> Callable[[], NoReturn]:
    return lambda: foo()   # line 10


def baz() -> Callable[[], NoReturn]:
    return foo

Running mypy v 0.961 against a file with these contents gives the error "foo.py:10: error: Return statement in function which does not return".

But, the return statement is in a function which does return, returning a function which does not. There are no complaints about the definition of baz, presumably because no function is defined in it.

@bwo bwo added the bug mypy got something wrong label Jun 23, 2022
@AlexWaygood
Copy link
Member

Duplicate of #10520

@AlexWaygood AlexWaygood marked this as a duplicate of #10520 Jun 23, 2022
@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 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
Projects
None yet
Development

No branches or pull requests

2 participants