class documentation

A cache for loaded PyTD files. Typically, you'll have one instance of this class, per module. Attributes: options: A config.Options object. builtins: The builtins ast. typing: The typing ast.

Method __init__ Undocumented
Method add_module_prefixes Undocumented
Method concat_all Undocumented
Method finish_and_verify_ast Verify the ast, doing external type resolution first if necessary.
Method get_default_ast Undocumented
Method get_resolved_modules Gets a name -> ResolvedModule map of the loader's resolved modules.
Method has_module_prefix Undocumented
Method import_name Undocumented
Method import_relative Import a module relative to our base module.
Method import_relative_name IMPORT_NAME with level=-1. A name relative to the current directory.
Method load_file Load a module from a filename.
Method load_module Load (or retrieve from cache) a module and resolve its dependencies.
Method lookup_builtin Undocumented
Method resolve_ast Resolve the dependencies of an AST, without adding it to our modules.
Method resolve_pytd Resolve and verify pytd value, using the given ast for local lookup.
Method save_to_pickle Save to a pickle. See PickledPyiLoader.load_from_pickle for reverse.
Instance Variable builtins Undocumented
Instance Variable options Undocumented
Instance Variable typing Undocumented
Method _create_empty Undocumented
Method _import_module_by_name Load a name like 'sys' or 'foo.bar.baz'.
Method _load_ast_dependencies Fill in all ClassType.cls pointers and load reexported modules.
Method _load_builtin Load a pytd/pyi that ships with pytype or typeshed.
Method _process_module Create a module from a loaded ast and save it to the loader cache.
Method _resolve_classtype_pointers Undocumented
Method _resolve_classtype_pointers_for_all_modules Undocumented
Method _resolve_external_and_local_types Undocumented
Method _resolve_external_types Undocumented
Method _try_import_prefix Try importing all prefixes of name, returning the first valid module.
Instance Variable _aliases Undocumented
Instance Variable _builtin_loader Undocumented
Instance Variable _import_name_cache Undocumented
Instance Variable _module_loader Undocumented
Instance Variable _modules Undocumented
Instance Variable _prefixes Undocumented
Instance Variable _resolver Undocumented
Instance Variable _typeshed_loader Undocumented
def __init__(self, options, modules=None, missing_modules=()): (source)

Undocumented

def add_module_prefixes(self, module_name): (source)

Undocumented

def concat_all(self): (source)

Undocumented

def finish_and_verify_ast(self, mod_ast): (source)

Verify the ast, doing external type resolution first if necessary.

def get_default_ast(self): (source)

Undocumented

def get_resolved_modules(self): (source)

Gets a name -> ResolvedModule map of the loader's resolved modules.

def has_module_prefix(self, prefix): (source)

Undocumented

def import_name(self, module_name: str): (source)

Undocumented

def import_relative(self, level: int) -> Optional[_AST]: (source)

Import a module relative to our base module. Args: level: Relative level: https://docs.python.org/2/library/functions.html#__import__ E.g. 1: "from . import abc" 2: "from .. import abc" etc. Since you'll use import_name() for -1 and 0, this function expects the level to be >= 1. Returns: The parsed pytd. Instance of pytd.TypeDeclUnit. None if we can't find the module. Raises: ValueError: If we don't know the name of the base module.

def import_relative_name(self, name: str) -> Optional[_AST]: (source)

IMPORT_NAME with level=-1. A name relative to the current directory.

def load_file(self, module_name, filename, mod_ast=None): (source)

Load a module from a filename.

def load_module(self, mod_info, mod_ast=None): (source)

Load (or retrieve from cache) a module and resolve its dependencies.

def lookup_builtin(self, name): (source)

Undocumented

def resolve_ast(self, ast): (source)

Resolve the dependencies of an AST, without adding it to our modules.

def resolve_pytd(self, pytd_node, lookup_ast): (source)

Resolve and verify pytd value, using the given ast for local lookup.

def save_to_pickle(self, filename): (source)

Save to a pickle. See PickledPyiLoader.load_from_pickle for reverse.

builtins = (source)

Undocumented

Undocumented

Undocumented

def _create_empty(self, mod_info): (source)

Undocumented

def _import_module_by_name(self, module_name) -> Optional[_AST]: (source)

Load a name like 'sys' or 'foo.bar.baz'. Args: module_name: The name of the module. May contain dots. Returns: The parsed file, instance of pytd.TypeDeclUnit, or None if we the module wasn't found.

def _load_ast_dependencies(self, dependencies, lookup_ast, lookup_ast_name=None): (source)

Fill in all ClassType.cls pointers and load reexported modules.

def _load_builtin(self, namespace, module_name): (source)

Load a pytd/pyi that ships with pytype or typeshed.

def _process_module(self, mod_info, mod_ast): (source)

Create a module from a loaded ast and save it to the loader cache. Args: mod_info: The metadata of the module being imported. mod_ast: The pytd.TypeDeclUnit representing the module. Returns: The ast (pytd.TypeDeclUnit) as represented in this loader.

def _resolve_classtype_pointers(self, mod_ast, *, lookup_ast=None): (source)

Undocumented

def _resolve_classtype_pointers_for_all_modules(self): (source)

Undocumented

def _resolve_external_and_local_types(self, mod_ast, lookup_ast=None): (source)

Undocumented

def _resolve_external_types(self, mod_ast, lookup_ast=None): (source)

Undocumented

def _try_import_prefix(self, name: str) -> Optional[_AST]: (source)

Try importing all prefixes of name, returning the first valid module.

_aliases: dict = (source)

Undocumented

_builtin_loader = (source)

Undocumented

_import_name_cache: dict = (source)

Undocumented

_module_loader = (source)

Undocumented

_modules = (source)

Undocumented

_prefixes = (source)

Undocumented

_resolver = (source)

Undocumented

_typeshed_loader = (source)

Undocumented