module documentation

Visitor(s) for walking ASTs.

Class AddNamePrefix Visitor for making names fully qualified.
Class AdjustSelf Visitor for setting the correct type on self.
Class AdjustTypeParameters Visitor for adjusting type parameters.
Class ClassTypeToLateType Convert ClassType to LateType.
Class ClearClassPointers Set .cls pointers to 'None'.
Class CollectDependencies Visitor for retrieving module names from external types.
Class CreateTypeParametersForSignatures Visitor for inserting type parameters into signatures.
Class DefaceUnresolved Replace all types not in a symbol table with AnythingType.
Class DropMutableParameters Drops all mutable parameters.
Class ExpandSignatures Expand to Cartesian product of parameter types.
Class ExtractSuperClassesByName Visitor for extracting all superclasses (i.e., the class hierarchy).
Class FillInLocalPointers Fill in ClassType pointers using symbol tables.
Class LateTypeToClassType Convert LateType to (unresolved) ClassType.
Class LookupBuiltins Look up built-in NamedTypes and give them fully-qualified names.
Class LookupExternalTypes Look up NamedType pointers using a symbol table.
Class LookupLocalTypes Look up local identifiers. Must be called on a TypeDeclUnit.
Class NamedTypeToClassType Change all NamedType objects to ClassType objects.
Class RemoveMethods Visitor for removing unwanted methods from classes.
Class RemoveUnknownClasses Visitor for converting ClassTypes called ~unknown* to just AnythingType.
Class ReplaceModulesWithAny Replace all references to modules in a list with AnythingType.
Class ReplaceTypeParameters Visitor for replacing type parameters with actual types.
Class ReplaceTypes Visitor for replacing types in a tree.
Class ReplaceUnionsWithAny Undocumented
Class StripExternalNamePrefix Strips off the prefix the parser uses to mark external types.
Class VerifyContainers Visitor for verifying containers.
Class VerifyLiterals Visitor for verifying that Literal[object] contains an enum.
Class VerifyLookup Utility class for testing visitors.LookupClasses.
Class VerifyVisitor Visitor for verifying pytd ASTs. For tests.
Exception ContainerError Undocumented
Exception LiteralValueError Undocumented
Exception SymbolLookupError Undocumented
Function ClassAsType Converts a pytd.Class to an instance of pytd.Type.
Function ExpandSignature Expand a single signature.
Function LookupClasses Converts a PyTD object from one using NamedType to ClassType.
Function MaybeSubstituteParameters Substitutes parameters into base_type if the latter has a template.
Class _CountUnknowns Visitor for counting how often given unknowns occur in a type.
Class _RemoveTypeParametersFromGenericAny Adjusts GenericType nodes to handle base type changes.
Class _ToTypeVisitor Visitor for calling pytd.ToType().
Function _MaybeSubstituteParametersInGenericType Undocumented
def ClassAsType(cls): (source)

Converts a pytd.Class to an instance of pytd.Type.

def ExpandSignature(sig): (source)

Expand a single signature. For argument lists that contain disjunctions, generates all combinations of arguments. The expansion will be done right to left. E.g., from (a or b, c or d), this will generate the signatures (a, c), (a, d), (b, c), (b, d). (In that order) Arguments: sig: A pytd.Signature instance. Returns: A list. The visit function of the parent of this node (VisitFunction) will process this list further.

def LookupClasses(target, global_module=None, ignore_late_types=False): (source)

Converts a PyTD object from one using NamedType to ClassType. Args: target: The PyTD object to process. If this is a TypeDeclUnit it will also be used for lookups. global_module: Global symbols. Required if target is not a TypeDeclUnit. ignore_late_types: If True, raise an error if we encounter a LateType. Returns: A new PyTD object that only uses ClassType. All ClassType instances will point to concrete classes. Raises: ValueError: If we can't find a class.

def MaybeSubstituteParameters(base_type, parameters=None): (source)

Substitutes parameters into base_type if the latter has a template.

def _MaybeSubstituteParametersInGenericType(node): (source)

Undocumented