-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[red-knot] Small simplifications to
Type::is_subtype_of
and `Type::…
…is_disjoint_from` (#15622) ## 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.
- Loading branch information
1 parent
8a8240b
commit fbb06fe
Showing
1 changed file
with
23 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters