Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive: unreachable case when using Literal #17328

Closed
Dreamsorcerer opened this issue Jun 4, 2024 · 0 comments · Fixed by #17817
Closed

False positive: unreachable case when using Literal #17328

Dreamsorcerer opened this issue Jun 4, 2024 · 0 comments · Fixed by #17817
Labels
bug mypy got something wrong

Comments

@Dreamsorcerer
Copy link
Contributor

Bug Report

There are similar bug reports, but I'm not clear if any of them are the same cause or not. When using a Literal in the match statement, I get unreachable errors. The error doesn't occur if the Literal is replaced with int.

To Reproduce

Occupancy = tuple[Literal[1], int]

occ: Occupancy
match occ:
    case (1, 5):
        print(1)
    case (1, 6):
        print(2)  # Unreachable error

Your Environment

  • Mypy version used: 1.10
  • Mypy command-line flags: --warn-unreachable
  • Python version used: 3.12
@Dreamsorcerer Dreamsorcerer added the bug mypy got something wrong label Jun 4, 2024
brianschubert added a commit to brianschubert/mypy that referenced this issue Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant