```py foo: str if isinstance(foo, str): ... else: asdf: list[str] = "" # no error ``` https://mypy-play.net/?mypy=master&python=3.10&gist=98cc704dbc9936fa1c3801984cd631fd my use case is an `assert_unreachable` function: ```ts def assert_unreachable(msg: str): raise AssertionError(msg) foo: str if isinstance(foo, str): ... else: # no error even though the msg argument was not provided assert_unreachable() #type:ignore[unreachable] ```
Activity
hauntsaninja commentedon Dec 1, 2021
Yeah, this is intentional. https://mypy.readthedocs.io/en/stable/common_issues.html#unreachable-code
I think in practice basically all warnings mypy would give if it didn't do this would end up being false positives.
KotlinIsland commentedon Dec 1, 2021
@hauntsaninja Those docs don't really explain why "this would end up being false positives", only showing very obvious true positives being ignored.