mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
![]() ## Summary This PR generalizes some of the logic we have in `Type::is_subtype_of` and `Type::is_disjoint_from` so that we fallback to the instance type of the metaclass more often in `Type::ClassLiteral` and `Type::SubclassOf` branches. This simplifies the code (we end up with one less branch in `is_subtype_of`, and we can remove a helper method that's no longer used), makes the code more robust (any fixes made to subtyping or disjointness of instance types will automatically improve our understanding of subtyping/disjointness for class-literal types and `type[]` types) and more elegantly expresses the type-system invariants encoded in these branches. ## Test Plan No new tests added (it's a pure refactor, adding no new functionality). All existing tests pass, however, including the property tests. |
||
---|---|---|
.. | ||
resources | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml | ||
mdtest.py | ||
mdtest.py.lock |