Bug: false positive with --warn-unreachable · Issue #7214 · python/mypy (original) (raw)

@jcugat

Please provide more information to help us understand the issue:

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"}))
$ mypy --warn-unreachable test.py
test.py:8: error: Statement is unreachable
$ pip freeze | grep mypy
mypy==0.720
mypy-extensions==0.4.1
$ python -V
Python 3.6.8

Maybe related to #7204 and #7207