Type inference constraints.
Class |
|
Undocumented |
Class |
|
A representation of a type constraint. |
Class |
|
Visitor class for inferring type constraints. |
Function | any |
Deduce what we can from a collection of constraint lists. |
Function | build |
Undocumented |
Function | filter |
Keep only constraints that can possibly be satisfied. |
Function | find |
Undocumented |
Function | find |
Disambiguate overload item against a template. |
Function | find |
Like find_matching_overload_item, but return all matches, not just the first. |
Function | handle |
Undocumented |
Function | infer |
Infer type constraints. |
Function | infer |
Infer type variable constraints for a callable and actual arguments. |
Function | infer |
Like infer_constraints, but return None if the input relation is known to be unsatisfiable, for example if template=List[T] and actual=int. (In this case infer_constraints would return [], just like it would for an automatically satisfied relation like template=List[T] and actual=object... |
Function | is |
Is a type complete? |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | is |
Check that two lists of constraints have similar structure. |
Function | merge |
Transform a constraint target into a union with given Any type. |
Function | neg |
Map SubtypeOf to SupertypeOf and vice versa. |
Function | select |
Select only those lists where each item is a constraint against Any. |
Function | simplify |
Undocumented |
Constant | SUBTYPE |
Undocumented |
Constant | SUPERTYPE |
Undocumented |
Function | _infer |
Undocumented |
Function | _is |
Check that every constraint in the first list has a similar one in the second. |
list[ list[ Constraint]|None]
, eager: bool
) -> list[ Constraint]
:
(source)
¶
Deduce what we can from a collection of constraint lists. It's a given that at least one of the lists must be satisfied. A None element in the list of options represents an unsatisfiable constraint and is ignored. Ignore empty constraint lists if eager is true -- they are always trivially satisfiable.
tuple[ Type, ...]
, mapped_prefix_len: int|None
, mapped_suffix_len: int|None
, template: tuple[ Type, ...]
, template_prefix_len: int
, template_suffix_len: int
, direction: int
) -> tuple[ list[ Constraint], tuple[ Type, ...], tuple[ Type, ...]]
:
(source)
¶
Undocumented
Keep only constraints that can possibly be satisfied. Currently, we filter out constraints where target is not a subtype of the upper bound. Since those can be never satisfied. We may add more cases in future if it improves type inference.
tuple[ Type, ...]
, template: tuple[ Type, ...]
, direction: int
) -> tuple[ list[ Constraint], tuple[ Type, ...], tuple[ Type, ...]]
:
(source)
¶
Undocumented
Overloaded
, template: CallableType
) -> CallableType
:
(source)
¶
Disambiguate overload item against a template.
Overloaded
, template: CallableType
) -> list[ CallableType]
:
(source)
¶
Like find_matching_overload_item, but return all matches, not just the first.
UnionType
, actual: Type
, direction: int
) -> list[ Constraint]
:
(source)
¶
Undocumented
Infer type constraints. Match a template type, which may contain type variable references, recursively against a type which does not contain (the same) type variable references. The result is a list of type constrains of form 'T is a supertype/subtype of x', where T is a type variable present in the template and x is a type without reference to type variables present in the template. Assume T and S are type variables. Now the following results can be calculated (read as '(template, actual) --> result'): (T, X) --> T :> X (X[T], X[Y]) --> T <: Y and T :> Y ((T, T), (X, Y)) --> T :> X and T :> Y ((T, S), (X, Y)) --> T :> X and S :> Y (X[T], Any) --> T <: Any and T :> Any The constraints are represented as Constraint objects.
CallableType
, arg_types: Sequence[ Type|None]
, arg_kinds: list[ ArgKind]
, formal_to_actual: list[ list[ int]]
, context: ArgumentInferContext
) -> list[ Constraint]
:
(source)
¶
Infer type variable constraints for a callable and actual arguments. Return a list of constraints.
Type
, actual: Type
, direction: int
) -> list[ Constraint]|None
:
(source)
¶
Like infer_constraints, but return None if the input relation is known to be unsatisfiable, for example if template=List[T] and actual=int. (In this case infer_constraints would return [], just like it would for an automatically satisfied relation like template=List[T] and actual=object.)
Is a type complete? A complete doesn't have uninhabited type components or (when not in strict optional mode) None components.
Check that two lists of constraints have similar structure. This means that each list has same type variable plus direction pairs (i.e we ignore the target). Except for constraints where target is Any type, there we ignore direction as well.
Type
, actual: Type
, direction: int
) -> list[ Constraint]
:
(source)
¶
Undocumented