class documentation

Class for matching types against other types.

Method __init__ Construct.
Method default_match Undocumented
Method expand_subclasses Undocumented
Method expand_superclasses Undocumented
Method get_subclasses Get all classes derived from this type.
Method get_superclasses Get all base classes of this type.
Method match_Class_against_Class Match a pytd.Class against another pytd.Class.
Method match_Function_against_Class Undocumented
Method match_Function_against_Function Undocumented
Method match_Functions_against_Class Undocumented
Method match_Generic_against_Generic Match a pytd.GenericType against another pytd.GenericType.
Method match_Generic_against_Unknown Undocumented
Method match_Protocol_against_Unknown Match a typing.Protocol against an unknown class.
Method match_Signature_against_Function Undocumented
Method match_Signature_against_Signature Match a pytd.Signature against another pytd.Signature.
Method match_type_against_type Undocumented
Method match_Unknown_against_Generic Undocumented
Method maybe_lookup_type_param Undocumented
Method type_parameter This generates the type parameter when matching against a generic type.
Method unclass Prevent further subclass or superclass expansion for this type.
Instance Variable any_also_is_bottom Undocumented
Instance Variable direct_subclasses Undocumented
Instance Variable solver Undocumented
Method _full_name Undocumented
Method _get_parameters Undocumented
Method _match_type_against_type Match a pytd.Type against another pytd.Type.
Instance Variable _implications Undocumented

Inherited from TypeMatcher:

Method match Undocumented
def __init__(self, direct_subclasses=None, any_also_is_bottom=True): (source)

Construct. Args: direct_subclasses: A dictionary, mapping pytd.Type to lists of pytd.Type. any_also_is_bottom: Whether we should, (if True) consider pytd.AnythingType() to also be at the bottom of the type hierarchy, thus making it a subclass of everything, or (if False) to be only at the top.

def default_match(self, t1, t2, *unused_args, **unused_kwargs): (source)
def expand_subclasses(self, t): (source)

Undocumented

def expand_superclasses(self, t): (source)

Undocumented

def get_subclasses(self, t): (source)

Get all classes derived from this type. Args: t: A pytd.Type Returns: A list of pytd.Type.

def get_superclasses(self, t): (source)

Get all base classes of this type. Args: t: A pytd.Type Returns: A list of pytd.Type.

def match_Class_against_Class(self, cls1, cls2, subst): (source)

Match a pytd.Class against another pytd.Class.

def match_Function_against_Class(self, f1, cls2, subst, cache): (source)

Undocumented

def match_Function_against_Function(self, f1, f2, subst, skip_self=False): (source)

Undocumented

def match_Functions_against_Class(self, methods, cls2, subst): (source)

Undocumented

def match_Generic_against_Generic(self, t1: pytd.GenericType, t2: pytd.GenericType, subst: _SubstType) -> booleq.BooleanTerm: (source)

Match a pytd.GenericType against another pytd.GenericType.

def match_Generic_against_Unknown(self, t1, t2, subst): (source)

Undocumented

def match_Protocol_against_Unknown(self, protocol, unknown, subst): (source)

Match a typing.Protocol against an unknown class.

def match_Signature_against_Function(self, sig, f, subst, skip_self=False): (source)

Undocumented

def match_Signature_against_Signature(self, sig1, sig2, subst, skip_self=False): (source)

Match a pytd.Signature against another pytd.Signature. Args: sig1: The caller sig2: The callee subst: Current type parameters. skip_self: If True, doesn't compare the first parameter, which is considered (and verified) to be "self". Returns: An instance of booleq.BooleanTerm, i.e. a boolean formula.

def match_type_against_type(self, t1, t2, subst): (source)

Undocumented

def match_Unknown_against_Generic(self, t1: _UnknownType, t2: pytd.GenericType, subst: _SubstType) -> booleq.BooleanTerm: (source)

Undocumented

def maybe_lookup_type_param(self, t, subst): (source)

Undocumented

def type_parameter(self, unknown: _UnknownType, base_class: pytd.Class, item: pytd.TemplateItem) -> StrictType: (source)

This generates the type parameter when matching against a generic type. For example, when we match ~unknown1 against list[T], we need an additional type to model the T in "~unknown1[T]". This type would have the name "~unknown1.list.T". Args: unknown: An unknown type. This is the type that's matched against base_class[T]. base_class: The base class of the generic we're matching the unknown against. E.g. "list". item: The actual type parameter. ("T" in the examples above). Returns: A type (pytd.Node) to represent this type parameter.

def unclass(self, t): (source)

Prevent further subclass or superclass expansion for this type.

any_also_is_bottom = (source)

Undocumented

direct_subclasses = (source)

Undocumented

Undocumented

def _full_name(self, t): (source)

Undocumented

def _get_parameters(self, t1, t2): (source)

Undocumented

def _match_type_against_type(self, t1, t2, subst): (source)

Match a pytd.Type against another pytd.Type.

_implications: dict = (source)

Undocumented