[red-knot] Literal[False]
not always inferred for comparisons between tuple types with disjunct literal elements
#14279
Labels
bug
Something isn't working
help wanted
Contributions especially welcome
red-knot
Multi-file analysis & type inference
red-knot infers the following types for the following comparisons:
The last one should also be inferred as
Literal[False]
, just like the first three. This is because two objects of typesLiteral["foo"]
andLiteral["bar"]
respectively will never compare equal to each other. By the same token, two 2-element tuples where the second elements are of typeLiteral["foo"]
andLiteral["bar"]
respectively will never compare equal, regardless of what their first element is.I discovered this while working on #14244. Ideally, this comparison would be inferred as
Literal[False]
, sincesys.version_info[3]
should be inferred by red-knot as being of typeLiteral["alpha", "beta", "candidate", "final"]
, and objects with that type never compare equal to the string"finallllllll"
:The text was updated successfully, but these errors were encountered: