module documentation
(source)

Calculation of the least upper bound types (joins).
Class ​Instance​Joiner Undocumented
Class ​Type​Join​Visitor Implementation of the least upper bound algorithm.
Function combine​_arg​_names Produces a list of argument names compatible with both callables.
Function combine​_similar​_callables Undocumented
Function is​_better Undocumented
Function is​_similar​_callables Return True if t and s have identical numbers of arguments, default arguments and varargs.
Function join​_similar​_callables Undocumented
Function join​_simple Return a simple least upper bound given the declared type.
Function join​_type​_list Undocumented
Function join​_types Return the least upper bound of s and t.
Function object​_from​_instance Construct the type 'builtins.object' from an instance type.
Function object​_or​_any​_from​_type Undocumented
Function trivial​_join Return one of types (expanded) if it is a supertype of other, otherwise top type.
Function unpack​_callback​_protocol Undocumented
def combine_arg_names(t, s): (source)

Produces a list of argument names compatible with both callables.

For example, suppose 't' and 's' have the following signatures:

  • t: (a: int, b: str, X: str) -> None
  • s: (a: int, b: str, Y: str) -> None

This function would return ["a", "b", None]. This information is then used above to compute the join of t and s, which results in a signature of (a: int, b: str, str) -> None.

Note that the third argument's name is omitted and 't' and 's' are both valid subtypes of this inferred signature.

Precondition: is_similar_types(t, s) is true.

Parameters
t:CallableTypeUndocumented
s:CallableTypeUndocumented
Returns
List[Optional[str]]Undocumented
def combine_similar_callables(t, s): (source)

Undocumented

Parameters
t:CallableTypeUndocumented
s:CallableTypeUndocumented
Returns
CallableTypeUndocumented
def is_better(t, s): (source)

Undocumented

Parameters
t:TypeUndocumented
s:TypeUndocumented
Returns
boolUndocumented
def is_similar_callables(t, s): (source)
Return True if t and s have identical numbers of arguments, default arguments and varargs.
Parameters
t:CallableTypeUndocumented
s:CallableTypeUndocumented
Returns
boolUndocumented
def join_similar_callables(t, s): (source)

Undocumented

Parameters
t:CallableTypeUndocumented
s:CallableTypeUndocumented
Returns
CallableTypeUndocumented
def join_simple(declaration, s, t): (source)
Return a simple least upper bound given the declared type.
Parameters
declaration:Optional[Type]Undocumented
s:TypeUndocumented
t:TypeUndocumented
Returns
ProperTypeUndocumented
def join_type_list(types): (source)

Undocumented

Parameters
types:List[Type]Undocumented
Returns
ProperTypeUndocumented
def join_types(s, t, instance_joiner=None): (source)

Return the least upper bound of s and t.

For example, the join of 'int' and 'object' is 'object'.

Parameters
s:TypeUndocumented
t:TypeUndocumented
instance​_joiner:Optional[InstanceJoiner]Undocumented
Returns
ProperTypeUndocumented
def object_from_instance(instance): (source)
Construct the type 'builtins.object' from an instance type.
Parameters
instance:InstanceUndocumented
Returns
InstanceUndocumented
def object_or_any_from_type(typ): (source)

Undocumented

Parameters
typ:ProperTypeUndocumented
Returns
ProperTypeUndocumented
def trivial_join(s, t): (source)
Return one of types (expanded) if it is a supertype of other, otherwise top type.
Parameters
s:TypeUndocumented
t:TypeUndocumented
Returns
ProperTypeUndocumented
def unpack_callback_protocol(t): (source)

Undocumented

Parameters
t:InstanceUndocumented
Returns
Optional[Type]Undocumented