8000 Bug: false positive with --warn-unreachable · Issue #7214 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}
Bug: false positive with --warn-unreachable #7214
Closed
@jcugat

Description

@jcugat

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

Maybe related to #7204 and #7207

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0