Skip to content

Unreachability should detect redundant isinstances even for object arguments #20668

@A5rocks

Description

@A5rocks

Bug Report

See #20665

To Reproduce

def f(x: object) -> None:
    if isinstance(x, int):
        print("aaaa")
    elif isinstance(x, int):
        print("aaaa")

Expected Behavior

Error

Actual Behavior

No error

Your Environment

  • Mypy version used: master
  • Mypy command-line flags: --warn-unreachable --strict
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-reachabilityDetecting unreachable code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions