Bug: false positive with --warn-unreachable · Issue #7214 · python/mypy (original) (raw)
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request?
Bug - Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
from contextlib import suppress
from typing import Dict
def foo(blah: Dict[str, str]):
with suppress(KeyError):
return blah["blah"]
return blah["default"]
print(foo({"default": "default"}))
- What is the actual behavior/output?
$ mypy --warn-unreachable test.py
test.py:8: error: Statement is unreachable
- What is the behavior/output you expect?
No error, since line 8 is reachable. - What are the versions of mypy and Python you are using?
$ pip freeze | grep mypy
mypy==0.720
mypy-extensions==0.4.1
$ python -V
Python 3.6.8
- What are the mypy flags you are using? (For example --strict-optional)
--warn-unreachable