Closed
Description
Consider the following snippet.
import contextlib
import sys
from typing import Iterator, NoReturn
def foo() -> NoReturn:
with bar():
pass
sys.exit(0)
@contextlib.contextmanager
def bar() -> Iterator[None]:
yield None
Running mypy produces
error: Implicit return in function which does not return [misc]
def foo() -> NoReturn:
^
Hand-writing the context manager (as follows) does not produce the same error.
class Bar:
def __enter__(self) -> None:
return None
def __exit__(self, *args: Any) -> None:
pass
I think the error in the contextlib case is a false positive.
mypy version 0.761
and 0.770+dev.a07dbd00638c35729e30dfc4ae441a8985183563
(current master)
Python version 3.6.9
flags --ignore-missing-imports --check-untyped-defs --disallow-untyped-defs --no-implicit-optional --warn-unused-ignores
May be related to #8129.
Metadata
Metadata
Assignees
Labels
No labels