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​_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 python​_major​_ver Undocumented
Instance Variable results Undocumented
Instance Variable search​_paths 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, fscache, options, stdlib_py_versions=None): (source)

Undocumented

Parameters
search​_paths:SearchPathsUndocumented
fscache:Optional[FileSystemCache]Undocumented
options:Optional[Options]Undocumented
stdlib​_py​_versions:Optional[StdlibVersions]Undocumented
def clear(self): (source)

Undocumented

def find_lib_path_dirs(self, id, lib_path): (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.

Parameters
id:strUndocumented
lib​_path:Tuple[str, ...]Undocumented
Returns
PackageDirsUndocumented
def find_module(self, id, *, fast_path=False): (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.

Parameters
id:strUndocumented
fast​_path:boolUndocumented
Returns
ModuleSearchResultUndocumented
def find_modules_recursive(self, module): (source)

Undocumented

Parameters
module:strUndocumented
Returns
List[BuildSource]Undocumented
def get_toplevel_possibilities(self, lib_path, id): (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.

Parameters
lib​_path:Tuple[str, ...]Undocumented
id:strUndocumented
Returns
List[str]Undocumented
fscache = (source)

Undocumented

initial_components: Dict[Tuple[str, ...], Dict[str, List[str]]] = (source)

Undocumented

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

Undocumented

options = (source)

Undocumented

python_major_ver = (source)

Undocumented

results: Dict[str, ModuleSearchResult] = (source)

Undocumented

search_paths = (source)

Undocumented

stdlib_py_versions = (source)

Undocumented

def _can_find_module_in_parent_dir(self, id): (source)
Test if a module can be found by checking the parent directories of the current working directory.
Parameters
id:strUndocumented
Returns
boolUndocumented
def _find_module(self, id, use_typeshed): (source)

Undocumented

Parameters
id:strUndocumented
use​_typeshed:boolUndocumented
Returns
ModuleSearchResultUndocumented
def _find_module_non_stub_helper(self, components, pkg_dir): (source)

Undocumented

Parameters
components:List[str]Undocumented
pkg​_dir:strUndocumented
Returns
Union[OnePackageDir, ModuleNotFoundReason]Undocumented
def _is_compatible_stub_package(self, stub_dir): (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.

Parameters
stub​_dir:strUndocumented
Returns
boolUndocumented
def _typeshed_has_version(self, module): (source)

Undocumented

Parameters
module:strUndocumented
Returns
boolUndocumented
def _update_ns_ancestors(self, components, match): (source)

Undocumented

Parameters
components:List[str]Undocumented
match:Tuple[str, bool]Undocumented