module documentation

Low-level infrastructure to find modules. This builds on fscache.py; find_sources.py builds on top of this.

Class BuildSource A single source file.
Class BuildSourceSet Helper to efficiently test a file's membership in a set of build sources.
Class FindModuleCache Module finder with integrated cache.
Class ModuleNotFoundReason Undocumented
Class SearchPaths Undocumented
Function compute_search_paths Compute the search paths as specified in PEP 561.
Function default_lib_path Return default standard library search paths.
Function get_search_dirs Find package directories for given python.
Function highest_init_level Compute the highest level where an __init__ file is found.
Function is_init_file Undocumented
Function load_stdlib_py_versions Return dict with minimum and maximum Python versions of stdlib modules.
Function matches_exclude Undocumented
Function mypy_path Undocumented
Function parse_version Undocumented
Function typeshed_py_version Return Python version used for checking whether module supports typeshed.
Function verify_module Check that all packages containing id have a __init__ file.
Constant PYTHON_EXTENSIONS Undocumented
Type Alias ModuleSearchResult Undocumented
Type Alias OnePackageDir Undocumented
Type Alias PackageDirs Undocumented
Type Alias StdlibVersions Undocumented
def compute_search_paths(sources: list[BuildSource], options: Options, data_dir: str, alt_lib_path: str|None = None) -> SearchPaths: (source)

Compute the search paths as specified in PEP 561. There are the following 4 members created: - User code (from `sources`) - MYPYPATH (set either via config or environment variable) - installed package directories (which will later be split into stub-only and inline) - typeshed

def default_lib_path(data_dir: str, pyversion: tuple[int, int], custom_typeshed_dir: str|None) -> list[str]: (source)

Return default standard library search paths.

@functools.lru_cache(maxsize=None)
def get_search_dirs(python_executable: str|None) -> tuple[list[str], list[str]]: (source)

Find package directories for given python. This runs a subprocess call, which generates a list of the directories in sys.path. To avoid repeatedly calling a subprocess (which can be slow!) we lru_cache the results.

def highest_init_level(fscache: FileSystemCache, id: str, path: str, prefix: str) -> int: (source)

Compute the highest level where an __init__ file is found.

def is_init_file(path: str) -> bool: (source)

Undocumented

def load_stdlib_py_versions(custom_typeshed_dir: str|None) -> StdlibVersions: (source)

Return dict with minimum and maximum Python versions of stdlib modules. The contents look like {..., 'secrets': ((3, 6), None), 'symbol': ((2, 7), (3, 9)), ...} None means there is no maximum version.

def matches_exclude(subpath: str, excludes: list[str], fscache: FileSystemCache, verbose: bool) -> bool: (source)

Undocumented

def mypy_path() -> list[str]: (source)

Undocumented

def parse_version(version: str) -> tuple[int, int]: (source)

Undocumented

def typeshed_py_version(options: Options) -> tuple[int, int]: (source)

Return Python version used for checking whether module supports typeshed.

def verify_module(fscache: FileSystemCache, id: str, path: str, prefix: str) -> bool: (source)

Check that all packages containing id have a __init__ file.

PYTHON_EXTENSIONS: list[str] = (source)

Undocumented

Value
['.pyi', '.py']
ModuleSearchResult = (source)

Undocumented

Value
Union[str, ModuleNotFoundReason]
OnePackageDir = (source)

Undocumented

Value
Tuple[str, bool]
PackageDirs = (source)

Undocumented

Value
List[OnePackageDir]
StdlibVersions: _TypeAlias = (source)

Undocumented

Value
Dict[str, Tuple[Tuple[int, int], Optional[Tuple[int, int]]]]