Skip to content

False positive: unreachable case when using Literal #17328

Closed
@Dreamsorcerer

Description

@Dreamsorcerer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions