Skip to content

Unreachability depends on statement ordering #18901

Closed
coderabbit-test/mypy
#1
@A5rocks

Description

@A5rocks

Bug Report

X and sys.platform == "win32" does not mark the block as unreachable, but sys.platform == "win32" and X does. This probably has been reported before but I'm not sure how to phrase this let alone search issues.

To Reproduce

import sys

X = True

if X and sys.platform == "win32":
    reveal_type(False)  # N: Revealed type is "Literal[False]?"

Expected Behavior

I expect the branch to be unreachable, so the reveal_type should not show anything

Your Environment

Reproduced in mypy play.

  • Mypy version used: v1.15
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.12

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy