ruff
84d064a1 - [red-knot] fix building unions with literals and AlwaysTruthy/AlwaysFalsy (#17451)

Commit
126 days ago
[red-knot] fix building unions with literals and AlwaysTruthy/AlwaysFalsy (#17451) In #17403 I added a comment asserting that all same-kind literal types share all the same super-types. This is true, with two notable exceptions: the types `AlwaysTruthy` and `AlwaysFalsy`. These two types are super-types of some literal types within a given kind and not others: `Literal[0]`, `Literal[""]`, and `Literal[b""]` inhabit `AlwaysFalsy`, while other literals inhabit `AlwaysTruthy`. This PR updates the literal-unions optimization to handle these types correctly. Fixes https://github.com/astral-sh/ruff/issues/17447 Verified locally that `QUICKCHECK_TESTS=100000 cargo test -p red_knot_python_semantic -- --ignored types::property_tests::stable` now passes again.
Author
Parents
  • crates/red_knot_python_semantic
    • resources/mdtest
      • File
        union_types.md
    • src/types
      • File
        builder.rs