Tests for stubs.
Verify that various things in stubs are consistent with how things behave at runtime.
Class | Error |
No class docstring; 0/6 instance variable, 4/4 methods documented |
Class | Missing |
Marker object for things that are missing (from a stub or the runtime). |
Class | Signature |
No class docstring; 0/4 instance variable, 0/2 method, 1/3 static method documented |
Function | build_stubs |
Uses mypy to construct stub objects for the given modules. |
Function | get_allowlist_entries |
Undocumented |
Function | get_mypy_type_of_runtime_value |
Returns a mypy type object representing the type of runtime. |
Function | get_stub |
Returns a stub object for the given module, if we've built one. |
Function | get_typeshed_stdlib_modules |
Returns a list of stdlib modules in typeshed (for current Python version). |
Function | is_dunder |
Returns whether name is a dunder name. |
Function | is_probably_a_function |
Undocumented |
Function | is_subtype_helper |
Checks whether left is a subtype of right. |
Function | main |
Undocumented |
Function | maybe_strip_cls |
Undocumented |
Function | parse_options |
Undocumented |
Function | safe_inspect_signature |
Undocumented |
Function | test_module |
Tests a given module's stub against introspecting it at runtime. |
Function | test_stubs |
This is stubtest! It's time to test the stubs! |
Function | verify |
Entry point for comparing a stub to a runtime object. |
Function | verify_decorator |
Undocumented |
Function | verify_funcitem |
Undocumented |
Function | verify_mypyfile |
Undocumented |
Function | verify_none |
Undocumented |
Function | verify_overloadedfuncdef |
Undocumented |
Function | verify_typealias |
Undocumented |
Function | verify_typeinfo |
Undocumented |
Function | verify_typevarexpr |
Undocumented |
Function | verify_var |
Undocumented |
Constant | MISSING |
Undocumented |
Constant | SPECIAL_DUNDERS |
Undocumented |
Constant | T |
Undocumented |
Variable | MaybeMissing |
Undocumented |
Function | _resolve_funcitem_from_decorator |
Returns a FuncItem that corresponds to the output of the decorator. |
Function | _style |
Wrapper around mypy.util for fancy formatting. |
Function | _verify_arg_default_value |
Checks whether argument default values are compatible. |
Function | _verify_arg_name |
Checks whether argument names match. |
Function | _verify_property |
Undocumented |
Function | _verify_signature |
Undocumented |
Function | _verify_static_class_methods |
Undocumented |
Variable | _all_stubs |
Undocumented |
Variable | _formatter |
Undocumented |
Uses mypy to construct stub objects for the given modules.
This sets global state that get_stub can access.
Returns all modules we might want to check. If find_submodules is False, this is equal to modules.
Parameters | |
modules:List[ | List of modules to build stubs for. |
options:Options | Mypy options for finding and building stubs. |
find_submodules:bool | Whether to attempt to find submodules of the given modules as well. |
Returns | |
List[ | Undocumented |
Returns a mypy type object representing the type of runtime.
Returns None if we can't find something that works.
Parameters | |
runtime:Any | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
module:str | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
custom_typeshed_dir:Optional[ | Undocumented |
Returns | |
List[ | Undocumented |
Parameters | |
name:str | Undocumented |
exclude_special:bool | Whether to return False for a couple special dunder methods. |
Returns | |
bool | Undocumented |
Parameters | |
left:mypy.types.Type | Undocumented |
right:mypy.types.Type | Undocumented |
Returns | |
bool | Undocumented |
Undocumented
Parameters | |
name:str | Undocumented |
args:List[ | Undocumented |
Returns | |
List[ | Undocumented |
Tests a given module's stub against introspecting it at runtime.
Requires the stub to have been built already, accomplished by a call to build_stubs.
Parameters | |
module_name:str | The module to test |
Returns | |
Iterator[ | Undocumented |
Parameters | |
args:argparse.Namespace | Undocumented |
use_builtins_fixtures:bool | Undocumented |
Returns | |
int | Undocumented |
Entry point for comparing a stub to a runtime object.
We use single dispatch based on the type of stub.
Parameters | |
stub:MaybeMissing[ | The mypy node representing a part of the stub |
runtime:MaybeMissing[ | The runtime object corresponding to stub |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.Decorator | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.FuncItem | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.MypyFile | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:Missing | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.OverloadedFuncDef | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.TypeAlias | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.TypeInfo | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.TypeVarExpr | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.Var | Undocumented |
runtime:MaybeMissing[ | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |
Returns a FuncItem that corresponds to the output of the decorator.
Returns None if we can't figure out what that would be. For convenience, this function also accepts FuncItems.
Parameters | |
dec:nodes.OverloadPart | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
message:str | Undocumented |
**kwargs:Any | Undocumented |
Returns | |
str | Undocumented |
Parameters | |
stub_arg:nodes.Argument | Undocumented |
runtime_arg:inspect.Parameter | Undocumented |
Returns | |
Iterator[ | Undocumented |
Parameters | |
stub_arg:nodes.Argument | Undocumented |
runtime_arg:inspect.Parameter | Undocumented |
function_name:str | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.Decorator | Undocumented |
runtime:Any | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:Signature[ | Undocumented |
runtime:Signature[ | Undocumented |
function_name:str | Undocumented |
Returns | |
Iterator[ | Undocumented |
Undocumented
Parameters | |
stub:nodes.FuncBase | Undocumented |
runtime:Any | Undocumented |
object_path:List[ | Undocumented |
Returns | |
Iterator[ | Undocumented |