Skip to content

Unreachable with always true/false operands to and/or  #8711

Closed
@llchan

Description

@llchan

It appears that an always true/false operand into and/or is marked as unreachable, even when it doesnt cause the other operand to be short circuited away (that scenario is correct, and emits a different "is never evaluated" message). The examples below are obviously very contrived; a more real-world example is something like

assert isinstance(x, float) and x > 0.0

  • Are you reporting a bug, or opening a feature request? bug
  • Please insert below the code you are checking with mypy.
    True and True
  • What is the actual behavior/output?
    main.py: note: In function "foo":
    main.py:1:1: error: Left operand of 'and' is always true  [unreachable]
            True and True
            ^
    
  • What is the behavior/output you expect? Success
  • What are the versions of mypy and Python you are using? master (0.770+dev.833fc2caec6773683d691a72058293ae87139210) with CPython 3.7.7
  • What are the mypy flags you are using? Custom, but effectively --strict

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions