Utilities for mypy.stubgen, mypy.stubgenc, and mypy.stubdoc modules.
Exception |
|
Undocumented |
Function | common |
Undocumented |
Function | fail |
Undocumented |
Function | find |
Find module and determine __all__ for a Python 3 module. |
Function | find |
Undocumented |
Function | generate |
Ignore or report errors during stub generation. |
Function | remove |
Remove comments from source that could be understood as misplaced type comments. |
Function | report |
Undocumented |
Function | walk |
Iterates through all packages and sub-packages in the given list. |
Constant | NOT |
Undocumented |
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 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.
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.
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.