-
Notifications
You must be signed in to change notification settings - Fork 217
Closed
Labels
type propertiessubtyping, assignability, equivalence, and moresubtyping, assignability, equivalence, and more
Description
Some types have a finite number of possible inhabitants. Examples include builtins.bool (the inhabitants are Literal[True] and Literal[False]) and enum types. For such types, we should consider the union of all possible inhabitants as equivalent to the type itself (so for example Literal[True, False]) is equivalent to builtins.bool). We should also take this equivalence into account when resolving negated intersections (so for example builtins.bool & ~Literal[True] is equivalent to Literal[False]; practically this will come up in type narrowing.)
Tasks here, in the order we'll likely get to them:
- resolve
Literal[True] | Literal[False]tobuiltins.bool - resolve
builtins.boolback toLiteral[True] | Literal[False]when intersection eliminates a type inhabitant - extend the above handling to enum types, when we add them
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type propertiessubtyping, assignability, equivalence, and moresubtyping, assignability, equivalence, and more