module documentation

Utilities for mypy.stubgen, mypy.stubgenc, and mypy.stubdoc modules.

Exception CantImport Undocumented
Function common_dir_prefix Undocumented
Function fail_missing Undocumented
Function find_module_path_and_all_py3 Find module and determine __all__ for a Python 3 module.
Function find_module_path_using_sys_path Undocumented
Function generate_guarded Ignore or report errors during stub generation.
Function remove_misplaced_type_comments Remove comments from source that could be understood as misplaced type comments.
Function report_missing Undocumented
Function walk_packages Iterates through all packages and sub-packages in the given list.
Constant NOT_IMPORTABLE_MODULES Undocumented
def common_dir_prefix(paths: list[str]) -> str: (source)

Undocumented

def fail_missing(mod: str, reason: ModuleNotFoundReason): (source)

Undocumented

def find_module_path_and_all_py3(inspect: ModuleInspect, module: str, verbose: bool) -> tuple[str|None, list[str]|None]|None: (source)

Find module and determine __all__ for a Python 3 module. Return None if the module is a C module. Return (module_path, __all__) if it is a Python module. Raise CantImport if import failed.

def find_module_path_using_sys_path(module: str, sys_path: list[str]) -> str|None: (source)

Undocumented

@contextmanager
def generate_guarded(mod: str, target: str, ignore_errors: bool = True, verbose: bool = False) -> Iterator[None]: (source)

Ignore or report errors during stub generation. Optionally report success.

@overload
def remove_misplaced_type_comments(source: bytes) -> bytes:
@overload
def remove_misplaced_type_comments(source: str) -> str:
(source)

Remove comments from source that could be understood as misplaced type comments. Normal comments may look like misplaced type comments, and since they cause blocking parse errors, we want to avoid them.

def report_missing(mod: str, message: str|None = '', traceback: str = ''): (source)

Undocumented

def walk_packages(inspect: ModuleInspect, packages: list[str], verbose: bool = False) -> Iterator[str]: (source)

Iterates through all packages and sub-packages in the given list. This uses runtime imports (in another process) to find both Python and C modules. For Python packages we simply pass the __path__ attribute to pkgutil.walk_packages() to get the content of the package (all subpackages and modules). However, packages in C extensions do not have this attribute, so we have to roll out our own logic: recursively find all modules imported in the package that have matching names.

NOT_IMPORTABLE_MODULES: tuple = (source)

Undocumented

Value
()