Stub generator for C modules.
The public interface is via the mypy.stubgen module.
Function | add_typing_import |
Add typing imports for collections/types that occur in the generated stub. |
Function | generate_c_function_stub |
Generate stub for a single function or method. |
Function | generate_c_property_stub |
Generate property stub using introspection of 'obj'. |
Function | generate_c_type_stub |
Generate stub for a single class using runtime introspection. |
Function | generate_stub_for_c_module |
Generate stub for C module. |
Function | get_type_fullname |
Undocumented |
Function | infer_method_sig |
Undocumented |
Function | is_c_classmethod |
Undocumented |
Function | is_c_function |
Undocumented |
Function | is_c_method |
Undocumented |
Function | is_c_property |
Undocumented |
Function | is_c_property_readonly |
Undocumented |
Function | is_c_type |
Undocumented |
Function | is_pybind11_overloaded_function_docstring |
Undocumented |
Function | is_pybind_skipped_attribute |
Undocumented |
Function | is_skipped_attribute |
Undocumented |
Function | is_static_property |
Undocumented |
Function | method_name_sort_key |
Sort methods in classes in a typical order. |
Function | strip_or_import |
Strips unnecessary module names from typ. |
Constant | _DEFAULT_TYPING_IMPORTS |
Undocumented |
Parameters | |
output:List[ | Undocumented |
Returns | |
List[ | Undocumented |
Generate stub for a single function or method.
The result (always a single line) will be appended to 'output'. If necessary, any required names will be added to 'imports'. The 'class_name' is used to find signature of __init__ or __new__ in 'class_sigs'.
Parameters | |
module:ModuleType | Undocumented |
name:str | Undocumented |
obj:object | Undocumented |
output:List[ | Undocumented |
imports:List[ | Undocumented |
self_var:Optional[ | Undocumented |
sigs:Optional[ | Undocumented |
class_name:Optional[ | Undocumented |
class_sigs:Optional[ | Undocumented |
Generate property stub using introspection of 'obj'.
Try to infer type from docstring, append resulting lines to 'output'.
Parameters | |
name:str | Undocumented |
obj:object | Undocumented |
static_properties:List[ | Undocumented |
rw_properties:List[ | Undocumented |
ro_properties:List[ | Undocumented |
readonly:bool | Undocumented |
module:Optional[ | Undocumented |
imports:Optional[ | Undocumented |
Generate stub for a single class using runtime introspection.
The result lines will be appended to 'output'. If necessary, any required names will be added to 'imports'.
Parameters | |
module:ModuleType | Undocumented |
class_name:str | Undocumented |
obj:type | Undocumented |
output:List[ | Undocumented |
imports:List[ | Undocumented |
sigs:Optional[ | Undocumented |
class_sigs:Optional[ | Undocumented |
Generate stub for C module.
This combines simple runtime introspection (looking for docstrings and attributes with simple builtin types) and signatures inferred from .rst documentation (if given).
If directory for target doesn't exist it will be created. Existing stub will be overwritten.
Parameters | |
module_name:str | Undocumented |
target:str | Undocumented |
sigs:Optional[ | Undocumented |
class_sigs:Optional[ | Undocumented |
Undocumented
Parameters | |
name:str | Undocumented |
self_var:Optional[ | Undocumented |
Returns | |
List[ | Undocumented |
Sort methods in classes in a typical order.
I.e.: constructor, normal methods, special methods.
Parameters | |
name:str | Undocumented |
Returns | |
Tuple[ | Undocumented |
Strips unnecessary module names from typ.
If typ represents a type that is inside module or is a type coming from builtins, remove module declaration from it. Return stripped name of the type.
Parameters | |
typ:str | Undocumented |
module:ModuleType | Undocumented |
imports:List[ | Undocumented |
Returns | |
str | Undocumented |