class documentation

class FindModuleCache: (source)

View In Hierarchy

Module finder with integrated cache. Module locations and some intermediate results are cached internally and can be cleared with the clear() method. All file system accesses are performed through a FileSystemCache, which is not ever cleared by this class. If necessary it must be cleared by client code.

Method __init__ Undocumented
Method clear Undocumented
Method find_lib_path_dirs Find which elements of a lib_path have the directory a module needs to exist.
Method find_module Return the path of the module source file or why it wasn't found.
Method find_module_via_source_set Fast path to find modules by looking through the input sources
Method find_modules_recursive Undocumented
Method get_toplevel_possibilities Find which elements of lib_path could contain a particular top-level module.
Instance Variable fscache Undocumented
Instance Variable initial_components Undocumented
Instance Variable ns_ancestors Undocumented
Instance Variable options Undocumented
Instance Variable results Undocumented
Instance Variable search_paths Undocumented
Instance Variable source_set Undocumented
Instance Variable stdlib_py_versions Undocumented
Method _can_find_module_in_parent_dir Test if a module can be found by checking the parent directories of the current working directory.
Method _find_module Undocumented
Method _find_module_non_stub_helper Undocumented
Method _is_compatible_stub_package Does a stub package support the target Python version?
Method _typeshed_has_version Undocumented
Method _update_ns_ancestors Undocumented
def __init__(self, search_paths: SearchPaths, fscache: FileSystemCache|None, options: Options|None, stdlib_py_versions: StdlibVersions|None = None, source_set: BuildSourceSet|None = None): (source)

Undocumented

def clear(self): (source)

Undocumented

def find_lib_path_dirs(self, id: str, lib_path: tuple[str, ...]) -> PackageDirs: (source)

Find which elements of a lib_path have the directory a module needs to exist. This is run for the python_path, mypy_path, and typeshed_path search paths.

def find_module(self, id: str, *, fast_path: bool = False) -> ModuleSearchResult: (source)

Return the path of the module source file or why it wasn't found. If fast_path is True, prioritize performance over generating detailed error descriptions.

def find_module_via_source_set(self, id: str) -> ModuleSearchResult|None: (source)

Fast path to find modules by looking through the input sources This is only used when --fast-module-lookup is passed on the command line.

def find_modules_recursive(self, module: str) -> list[BuildSource]: (source)

Undocumented

def get_toplevel_possibilities(self, lib_path: tuple[str, ...], id: str) -> list[str]: (source)

Find which elements of lib_path could contain a particular top-level module. In practice, almost all modules can be routed to the correct entry in lib_path by looking at just the first component of the module name. We take advantage of this by enumerating the contents of all of the directories on the lib_path and building a map of which entries in the lib_path could contain each potential top-level module that appears.

Undocumented

initial_components: dict[tuple[str, ...], dict[str, list[str]]] = (source)

Undocumented

ns_ancestors: dict[str, str] = (source)

Undocumented

Undocumented

search_paths = (source)

Undocumented

source_set = (source)

Undocumented

stdlib_py_versions = (source)

Undocumented

def _can_find_module_in_parent_dir(self, id: str) -> bool: (source)

Test if a module can be found by checking the parent directories of the current working directory.

def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult: (source)

Undocumented

def _find_module_non_stub_helper(self, components: list[str], pkg_dir: str) -> OnePackageDir|ModuleNotFoundReason: (source)

Undocumented

def _is_compatible_stub_package(self, stub_dir: str) -> bool: (source)

Does a stub package support the target Python version? Stub packages may contain a metadata file which specifies whether the stubs are compatible with Python 2 and 3.

def _typeshed_has_version(self, module: str) -> bool: (source)

Undocumented

def _update_ns_ancestors(self, components: list[str], match: tuple[str, bool]): (source)

Undocumented