sdkagent

mypy API reference

400 public APIs from mypy (python/mypy) — 92 classes, 165 functions, 143 methods. Signatures extracted by static analysis of the actual source.

Repository: python/mypy

KindCount
Classes92
Functions165
Methods143

API list

funcmisc.analyze_typeform_stats.analyze_stats(output:str) -> None
Parse mypy stats output and calculate TypeForm parsing efficiency.
funcmisc.diff-cache.encode_for_diff(s:str, obj:object) -> str
Encode a cache entry value for inclusion in the JSON diff.
funcmisc.diff-cache.load(cache:MetadataStore, s:str) -> Any
Load and normalize a cache entry.
funcmisc.diff-cache.normalize_json_meta(obj:dict[str, Any]) -> None
Normalize a JSON meta dict to avoid spurious diffs.
funcmisc.diff-cache.normalize_meta(meta:CacheMeta) -> None
Normalize a CacheMeta instance to avoid spurious diffs.
funcmisc.diff-cache.serialize_meta_ff(meta:CacheMeta, version_prefix:bytes) -> bytes
Serialize a CacheMeta instance back to fixed format binary.
funcmisc.sync-typeshed.update_typeshed(typeshed_dir:str, commit:str | None) -> str
Update contents of local typeshed copy.
classmypy.applytype.PolyTranslator
Make free type variables generic in the type if possible.
funcmypy.applytype.apply_poly(tp:CallableType, poly_tvars:Sequence[TypeVarLikeType]) -> CallableType | None
Make free type variables generic in the type if possible.
classmypy.binder.ConditionalTypeBinder
Keep track of conditional types of variables.
methodmypy.binder.ConditionalTypeBinder.assign_type(expr:Expression, type:Type, declared_type:Type | None) -> None
Narrow type of expression through an assignment.
methodmypy.binder.ConditionalTypeBinder.can_put_directly(expr:Expression) -> bool
Will `.put()` on this expression be successful?
methodmypy.binder.ConditionalTypeBinder.cleanse(expr:Expression) -> None
Remove all references to a Node from the binder.
methodmypy.binder.ConditionalTypeBinder.pop_frame(can_skip:bool, fall_through:int, *discard:bool=False) -> Frame
Pop a frame and return it.
methodmypy.binder.ConditionalTypeBinder.push_frame(conditional_frame:bool=False) -> Frame
Push a new frame into the binder.
methodmypy.binder.ConditionalTypeBinder.put(expr:Expression, typ:Type, *from_assignment:bool=True) -> None
Directly set the narrowed type of expression (if it supports it).
classmypy.binder.Frame
A Frame represents a specific point in the execution of a program.
classmypy.binder.FrameContext
Context manager pushing a Frame to ConditionalTypeBinder.
funcmypy.binder.collapse_variadic_union(typ:UnionType) -> Type
Simplify a union involving variadic tuple if possible.
funcmypy.binder.get_declaration(expr:BindableExpression) -> Type | None
Get the declared or inferred type of a RefExpr expression.
classmypy.build.AckMessage
An empty message used primarily for synchronization.
classmypy.build.BuildManager
This class holds shared state for building a mypy program.
methodmypy.build.BuildManager.all_imported_modules_in_file(file:MypyFile) -> list[tuple[int, str, int]]
Find all reachable import statements in a file.
methodmypy.build.BuildManager.broadcast(message:bytes) -> None
Broadcast same message to all workers in parallel.
methodmypy.build.BuildManager.correct_rel_imp(file:MypyFile, imp:ImportFrom | ImportAll) -> str
Function to correct for relative imports.
methodmypy.build.BuildManager.get_scc_batch(max_size_in_batch:int) -> list[SCC]
Get a batch of SCCs from queue to submit to a worker.
methodmypy.build.BuildManager.getmtime(path:str) -> int
Return a file's mtime; but 0 in bazel mode.
methodmypy.build.BuildManager.is_module(id:str) -> bool
Does the given fullname refer to a module?
methodmypy.build.BuildManager.is_transitive_scc_dep(from_scc_id:int, to_scc_id:int) -> bool
Check if one SCC is a (transitive) dependency of another.
methodmypy.build.BuildManager.parse_file(id:str, path:str, source:str | None, options:Options, raw_data:FileRawData | None=None) -> MypyFile
Parse the source of a file with the given name.
methodmypy.build.BuildManager.parse_files_threaded_raw(states:list[State]) -> tuple[list[State], set[State]]
Parse files in parallel using a thread pool.
methodmypy.build.BuildManager.receive_worker_message(idx:int) -> ReadBuffer
Receive a single message from a worker, with crash diagnostics.
methodmypy.build.BuildManager.submit(graph:Graph, sccs:list[SCC]) -> None
Submit a stale SCC for processing in current process or parallel workers.
methodmypy.build.BuildManager.wait_ack() -> None
Wait for an ack from all workers.
methodmypy.build.BuildManager.wait_for_done(graph:Graph) -> tuple[list[SCC], bool, dict[str, ModuleResult]]
Wait for a stale SCC processing to finish.
classmypy.build.BuildResult
The result of a successful build.
classmypy.build.GraphMessage
A message wrapping the build graph computed by the coordinator.
classmypy.build.ModuleNotFound
Control flow exception to signal that a module was not found.
classmypy.build.NodeInfo
Some info about a node in the graph of SCCs.
methodmypy.build.NodeInfo.dumps() -> str
Convert to JSON string.
classmypy.build.SccRequestMessage
A message representing a request to type check a batch of SCCs.
classmypy.build.SccsDataMessage
A message wrapping the SCC structure computed by the coordinator.
classmypy.build.SourcesDataMessage
A message wrapping a list of build sources.
classmypy.build.State
The state for a module.
methodmypy.build.State.check_blockers() -> None
Raise CompileError if a blocking error is detected.
methodmypy.build.State.compute_dependencies() -> None
Compute a module's dependencies after parsing it.
methodmypy.build.State.get_source() -> str
Get module source and parse inline mypy configurations.
methodmypy.build.State.is_fresh() -> bool
Return whether the cache data for this file is fresh.
methodmypy.build.State.parse_file(*temporary:bool=False, *raw_data:FileRawData | None=None) -> None
Parse file and run first pass of semantic analysis.
methodmypy.build.State.parse_inline_configuration(source:str) -> None
Check for inline mypy: options directive and parse them.
methodmypy.build.State.reload_meta() -> None
Force reload of cache meta.
methodmypy.build.State.verify_dependencies(suppressed_only:bool=False) -> None
Report errors for import targets in modules that don't exist.
methodmypy.build.State.wrap_context(check_blockers:bool=True) -> Iterator[None]
Temporarily change the error import context to match this state.
methodmypy.build.State.write(buf:WriteBuffer) -> None
Serialize State for sending to build worker.
classmypy.build.WorkerClient
A simple class that represents a mypy build worker.
funcmypy.build.add_catch_all_gitignore(target_dir:str) -> None
Add catch-all .gitignore to an existing directory.
funcmypy.build.create_metastore(options:Options, parallel_worker:bool) -> MetadataStore
Create the appropriate metadata store.
funcmypy.build.default_data_dir() -> str
Returns directory containing typeshed directory.
funcmypy.build.deps_filtered(graph:Graph, vertices:AbstractSet[str], id:str, pri_max:int) -> list[str]
Filter dependencies for id with pri < pri_max.
funcmypy.build.dump_graph(graph:Graph, stdout:TextIO | None=None) -> None
Dump the graph as a JSON string to stdout.
funcmypy.build.dump_line_checking_stats(path:str, graph:Graph) -> None
Dump per-line expression type checking stats.
funcmypy.build.dump_timing_stats(path:str, graph:Graph) -> None
Dump timing stats for each file in the given graph.
funcmypy.build.find_cache_meta(id:str, path:str, manager:BuildManager, skip_validation:bool=False) -> tuple[CacheMeta, CacheMetaEx] | None
Find cache data for a module.
funcmypy.build.find_module_simple(id:str, manager:BuildManager) -> str | None
Find a filesystem path for module `id` or `None` if not found.
funcmypy.build.find_stale_sccs(sccs:list[SCC], graph:Graph, manager:BuildManager) -> tuple[list[SCC], list[SCC]]
Split a list of ready SCCs into stale and fresh.
funcmypy.build.get_cache_names(id:str, path:str, options:Options) -> tuple[str, str, str | None]
Return the file names for the cache files.
funcmypy.build.import_priority(imp:ImportBase, toplevel_priority:int) -> int
Compute import priority from an import node.
funcmypy.build.in_partial_package(id:str, manager:BuildManager) -> bool
Check if a missing module can potentially be a part of a package.
funcmypy.build.load_plugins(options:Options, errors:Errors, stdout:TextIO, extra_plugins:Sequence[Plugin]) -> tuple[Plugin, dict[str, str]]
Load all configured plugins.
funcmypy.build.load_plugins_from_config(options:Options, errors:Errors, stdout:TextIO) -> tuple[list[Plugin], dict[str, str]]
Load all configured plugins.
funcmypy.build.log_configuration(manager:BuildManager, sources:list[BuildSource]) -> None
Output useful configuration information to LOG and TRACE
funcmypy.build.maybe_load_deps(graph:Graph, ascc:SCC, manager:BuildManager) -> None
Load any missing fresh modules needed to process a stale SCC
funcmypy.build.normpath(path:str, options:Options) -> str
Convert path to absolute; but to relative in bazel mode.
funcmypy.build.options_snapshot(module:str, manager:BuildManager) -> dict[str, object]
Make compact snapshot of options for a module.
funcmypy.build.order_ascc(graph:Graph, ascc:AbstractSet[str], pri_max:int=PRI_INDIRECT) -> list[str]
Come up with the ideal processing order within an SCC.
funcmypy.build.order_ascc_ex(graph:Graph, ascc:SCC) -> list[str]
Apply extra heuristics on top of order_ascc().
funcmypy.build.process_graph(graph:Graph, manager:BuildManager) -> None
Process everything in dependency order.
funcmypy.build.process_stale_scc(graph:Graph, ascc:SCC, manager:BuildManager) -> None
Process the modules in one SCC from source code.
funcmypy.build.read_deps_cache(manager:BuildManager, graph:Graph) -> dict[str, FgDepMeta] | None
Read and validate the fine-grained dependencies cache.
funcmypy.build.record_missing_stub_packages(cache_dir:str, missing_stub_packages:set[str]) -> None
Write a file containing missing stub packages.
funcmypy.build.sorted_components(graph:Graph) -> list[SCC]
Return the graph's SCCs, topologically sorted by dependencies.
funcmypy.build.take_module_snapshot(module:types.ModuleType) -> str
Take plugin module snapshot by recording its version and hash.
funcmypy.build.transitive_dep_hash(scc:SCC, graph:Graph) -> bytes
Compute stable snapshot of transitive import structure for given SCC.
funcmypy.build.write_deps_cache(rdeps:dict[str, dict[str, set[str]]], manager:BuildManager, graph:Graph) -> None
Write cache files for fine-grained dependencies.
funcmypy.build.write_plugins_snapshot(manager:BuildManager) -> None
Write snapshot of versions and hashes of currently active plugins.
funcmypy.build_worker.worker.serve(server:IPCServer, ctx:ServerContext) -> None
Main server loop of the worker.
funcmypy.build_worker.worker.should_shutdown(buf:ReadBuffer, expected_tag:Tag) -> bool
Check if the message is a shutdown request.
classmypy.cache.CacheMeta
Class representing cache metadata for a module.
classmypy.checkexpr.ExpressionChecker
Expression type checker.
methodmypy.checkexpr.ExpressionChecker.accept(node:Expression, type_context:Type | None=None, allow_none_return:bool=False, always_allow_any:bool=False, is_callee:bool=False) -> Type
Type check a node in the given type context.
methodmypy.checkexpr.ExpressionChecker.analyze_external_member_access(member:str, base_type:Type, context:Context) -> Type
Analyse member access that is external, i.e.
methodmypy.checkexpr.ExpressionChecker.analyze_ordinary_member_access(e:MemberExpr, is_lvalue:bool, rvalue:Expression | None=None) -> Type
Analyse member expression or member lvalue.
methodmypy.checkexpr.ExpressionChecker.analyze_type_type_callee(item:ProperType, context:Context) -> Type
Analyze the callee X in X(...) where X is Type[item].
methodmypy.checkexpr.ExpressionChecker.bool_type() -> Instance
Return instance type 'bool'.
methodmypy.checkexpr.ExpressionChecker.check_boolean_op(e:OpExpr) -> Type
Type check a boolean operation ('and' or 'or').
methodmypy.checkexpr.ExpressionChecker.check_call_expr_with_callee_type(callee_type:Type, e:CallExpr, callable_name:str | None, object_type:Type | None, member:str | None=None) -> Type
Type check call expression.
methodmypy.checkexpr.ExpressionChecker.check_for_comp(e:GeneratorExpr | DictionaryComprehension) -> None
Check the for_comp part of comprehensions.
methodmypy.checkexpr.ExpressionChecker.check_list_multiply(e:OpExpr) -> Type
Type check an expression of form '[...] * e'.
methodmypy.checkexpr.ExpressionChecker.concat_tuples(left:TupleType, right:TupleType) -> TupleType
Concatenate two fixed length tuples.
methodmypy.checkexpr.ExpressionChecker.defn_returns_none(defn:SymbolNode | None) -> bool
Check if `defn` can _only_ return None.
methodmypy.checkexpr.ExpressionChecker.get_partial_self_var(expr:MemberExpr) -> Var | None
Get variable node for a partial self attribute.
methodmypy.checkexpr.ExpressionChecker.infer_arg_types_in_empty_context(args:list[Expression]) -> list[Type]
Infer argument expression types in an empty context.
methodmypy.checkexpr.ExpressionChecker.is_valid_keyword_var_arg(typ:Type) -> bool
Is a type valid as a **kwargs argument?
methodmypy.checkexpr.ExpressionChecker.is_valid_var_arg(typ:Type) -> bool
Is a type valid as a *args argument?
methodmypy.checkexpr.ExpressionChecker.named_type(name:str) -> Instance
Return an instance type with type given by the name and no type arguments.
methodmypy.checkexpr.ExpressionChecker.object_type() -> Instance
Return instance type 'object'.
methodmypy.checkexpr.ExpressionChecker.try_infer_partial_type(e:CallExpr) -> None
Try to make partial type precise from a call.
methodmypy.checkexpr.ExpressionChecker.try_parse_as_type_expression(maybe_type_expr:Expression) -> Type | None
Try to parse a value Expression as a type expression.
methodmypy.checkexpr.ExpressionChecker.type_overrides_set(exprs:Sequence[Expression], overrides:Sequence[Type]) -> Iterator[None]
Set _temporary_ type overrides for given expressions.
methodmypy.checkexpr.ExpressionChecker.visit_bytes_expr(e:BytesExpr) -> Type
Type check a bytes literal (trivial).
methodmypy.checkexpr.ExpressionChecker.visit_call_expr(e:CallExpr, allow_none_return:bool=False) -> Type
Type check a call expression.
methodmypy.checkexpr.ExpressionChecker.visit_cast_expr(expr:CastExpr) -> Type
Type check a cast expression.
methodmypy.checkexpr.ExpressionChecker.visit_comparison_expr(e:ComparisonExpr) -> Type
Type check a comparison expression.
methodmypy.checkexpr.ExpressionChecker.visit_complex_expr(e:ComplexExpr) -> Type
Type check a complex literal.
methodmypy.checkexpr.ExpressionChecker.visit_dict_expr(e:DictExpr) -> Type
Type check a dict expression.
methodmypy.checkexpr.ExpressionChecker.visit_dictionary_comprehension(e:DictionaryComprehension) -> Type
Type check a dictionary comprehension.
methodmypy.checkexpr.ExpressionChecker.visit_ellipsis(e:EllipsisExpr) -> Type
Type check '...'.
methodmypy.checkexpr.ExpressionChecker.visit_float_expr(e:FloatExpr) -> Type
Type check a float literal (trivial).
methodmypy.checkexpr.ExpressionChecker.visit_index_expr(e:IndexExpr) -> Type
Type check an index expression (base[index]).
methodmypy.checkexpr.ExpressionChecker.visit_int_expr(e:IntExpr) -> Type
Type check an integer literal (trivial).
methodmypy.checkexpr.ExpressionChecker.visit_lambda_expr(e:LambdaExpr) -> Type
Type check lambda expression.
methodmypy.checkexpr.ExpressionChecker.visit_list_expr(e:ListExpr) -> Type
Type check a list expression [...].
methodmypy.checkexpr.ExpressionChecker.visit_member_expr(e:MemberExpr, is_lvalue:bool=False) -> Type
Visit member expression (of form e.id).
methodmypy.checkexpr.ExpressionChecker.visit_name_expr(e:NameExpr) -> Type
Type check a name expression.
methodmypy.checkexpr.ExpressionChecker.visit_op_expr(e:OpExpr) -> Type
Type check a binary operator expression.
methodmypy.checkexpr.ExpressionChecker.visit_reveal_expr(expr:RevealExpr) -> Type
Type check a reveal_type expression.
methodmypy.checkexpr.ExpressionChecker.visit_str_expr(e:StrExpr) -> Type
Type check a string literal (trivial).
methodmypy.checkexpr.ExpressionChecker.visit_super_expr(e:SuperExpr) -> Type
Type check a super expression (non-lvalue).
methodmypy.checkexpr.ExpressionChecker.visit_template_str_expr(e:TemplateStrExpr) -> Type
Type check a template string expression (t-string).
methodmypy.checkexpr.ExpressionChecker.visit_tuple_expr(e:TupleExpr) -> Type
Type check a tuple expression.
methodmypy.checkexpr.ExpressionChecker.visit_type_alias_expr(alias:TypeAliasExpr) -> Type
Right hand side of a type alias definition.
methodmypy.checkexpr.ExpressionChecker.visit_type_application(tapp:TypeApplication) -> Type
Type check a type application (expr[type, ...]).
methodmypy.checkexpr.ExpressionChecker.visit_unary_expr(e:UnaryExpr) -> Type
Type check an unary operation ('not', '-', '+' or '~').
classmypy.checkexpr.HasErasedComponentsQuery
Visitor for querying whether a type has an erased component.
funcmypy.checkexpr.has_any_type(t:Type, ignore_in_type_obj:bool=False) -> bool
Whether t contains an Any type
funcmypy.checkexpr.has_bytes_component(typ:Type) -> bool
Is this one of builtin byte types, or a union that contains it?
funcmypy.checkexpr.has_coroutine_decorator(t:Type) -> bool
Whether t came from a function decorated with `@coroutine`.
funcmypy.checkexpr.is_async_def(t:Type) -> bool
Whether t came from a function defined using `async def`.
funcmypy.checkexpr.is_expr_literal_type(node:Expression) -> bool
Returns 'true' if the given node is a Literal
funcmypy.checkexpr.replace_callable_return_type(c:CallableType, new_ret_type:Type) -> CallableType
Return a copy of a callable type with a different return type.
funcmypy.checkexpr.try_getting_literal(typ:Type) -> ProperType
If possible, get a more precise literal type for a given type.
classmypy.checkmember.MemberContext
Information and objects needed to type check attribute access.
funcmypy.checkmember.analyze_decorator_or_funcbase_access(defn:Decorator | FuncBase, itype:Instance, name:str, mx:MemberContext) -> Type
Analyzes the type behind method access.
funcmypy.checkmember.analyze_descriptor_access(descriptor_type:Type, mx:MemberContext) -> Type
Type check descriptor access.
funcmypy.checkmember.analyze_member_var_access(name:str, itype:Instance, info:TypeInfo, mx:MemberContext) -> Type
Analyse attribute access that does not target a method.
funcmypy.checkmember.analyze_var(name:str, var:Var, itype:Instance, mx:MemberContext, *implicit:bool=False, *is_trivial_self:bool=False) -> Type
Analyze access to an attribute via a Var node.
funcmypy.checkmember.has_operator(typ:Type, op_method:str) -> bool
Does type have operator with the given name?
funcmypy.checkmember.is_instance_var(var:Var) -> bool
Return if var is an instance variable according to PEP 526.
funcmypy.checkmember.may_be_awaitable_attribute(name:str, typ:Type, mx:MemberContext, override_info:TypeInfo | None=None) -> bool
Check if the given type has the attribute when awaited.
classmypy.checkpattern.PatternChecker
Pattern checker.
funcmypy.checkpattern.get_var(expr:Expression) -> Var
Warning: this in only true for expressions captured by a match statement.
classmypy.checkstrformat.StringFormatterChecker
String interpolation/formatter type checker.
methodmypy.checkstrformat.StringFormatterChecker.accept(expr:Expression, context:Type | None=None) -> Type
Type check a node.
methodmypy.checkstrformat.StringFormatterChecker.auto_generate_keys(all_specs:list[ConversionSpecifier], ctx:Context) -> bool
Translate '{} {name} {}' to '{0} {name} {1}'.
funcmypy.checkstrformat.has_type_component(typ:Type, fullname:str) -> bool
Is this a specific instance type, or a union that contains it?
classmypy.config_parser.VersionTypeError
Provide a fallback value if the Python version is unsupported.
funcmypy.config_parser.convert_to_boolean(value:Any | None) -> bool
Return a boolean value translating from other types if necessary.
funcmypy.config_parser.mypy_comments_to_config_map(line:str, template:Options) -> tuple[dict[str, str], list[str]]
Rewrite the mypy comment syntax into ini file syntax.
funcmypy.config_parser.parse_config_file(options:Options, set_strict_flags:Callable[[], None], filename:str | None, stdout:TextIO | None=None, stderr:TextIO | None=None) -> None
Parse a config file into an Options object.
funcmypy.config_parser.split_directive(s:str) -> tuple[list[str], list[str]]
Split s on commas, except during quoted sections.
classmypy.constraints.Constraint
A representation of a type constraint.
classmypy.constraints.ConstraintBuilderVisitor
Visitor class for inferring type constraints.
funcmypy.constraints.any_constraints(options:list[list[Constraint] | None], *eager:bool) -> list[Constraint]
Deduce what we can from a collection of constraint lists.
funcmypy.constraints.filter_satisfiable(option:list[Constraint] | None) -> list[Constraint] | None
Keep only constraints that can possibly be satisfied.
funcmypy.constraints.find_matching_overload_item(overloaded:Overloaded, template:CallableType) -> CallableType
Disambiguate overload item against a template.
funcmypy.constraints.infer_constraints(template:Type, actual:Type, direction:int, skip_neg_op:bool=False, erase_types:bool=True) -> list[Constraint]
Infer type constraints.
funcmypy.constraints.is_similar_constraints(x:list[Constraint], y:list[Constraint]) -> bool
Check that two lists of constraints have similar structure.
funcmypy.constraints.merge_with_any(constraint:Constraint) -> Constraint
Transform a constraint target into a union with given Any type.
funcmypy.constraints.neg_op(op:int) -> int
Map SubtypeOf to SupertypeOf and vice versa.
funcmypy.constraints.repack_callable_args(callable:CallableType, tuple_type:TypeInfo) -> list[Type]
Present callable with star unpack in a normalized form.
funcmypy.copytype.copy_type(t:ProperType) -> ProperType
Create a shallow copy of a type.
funcmypy.dmypy.client.action(subparser:argparse.ArgumentParser) -> Callable[[ActionFunction], ActionFunction]
Decorator to tie an action function to a subparser.
funcmypy.dmypy.client.check_output(response:dict[str, Any], verbose:bool, junit_xml:str | None, perf_stats_file:str | None) -> None
Print the output from a check or recheck command.
funcmypy.dmypy.client.check_status(data:dict[str, Any]) -> tuple[int, str]
Check if the process is alive.
funcmypy.dmypy.client.do_check(args:argparse.Namespace) -> None
Ask the daemon to check a list of files.
funcmypy.dmypy.client.do_daemon(args:argparse.Namespace) -> None
Serve requests in the foreground.
funcmypy.dmypy.client.do_hang(args:argparse.Namespace) -> None
Hang for 100 seconds, as a debug hack.
funcmypy.dmypy.client.do_help(args:argparse.Namespace) -> None
Print full help (same as dmypy --help).
funcmypy.dmypy.client.do_inspect(args:argparse.Namespace) -> None
Ask daemon to print the type of an expression.
funcmypy.dmypy.client.do_kill(args:argparse.Namespace) -> None
Kill daemon process with SIGKILL.
funcmypy.dmypy.client.do_restart(args:argparse.Namespace) -> None
Restart daemon (it may or may not be running; but not hanging).
funcmypy.dmypy.client.do_start(args:argparse.Namespace) -> None
Start daemon (it must not already be running).
funcmypy.dmypy.client.do_status(args:argparse.Namespace) -> None
Print daemon status.
funcmypy.dmypy.client.do_stop(args:argparse.Namespace) -> None
Stop daemon via a 'stop' request.
funcmypy.dmypy.client.do_suggest(args:argparse.Namespace) -> None
Ask the daemon for a suggested signature.
funcmypy.dmypy.client.get_status(status_file:str) -> tuple[int, str]
Read status file and check if the process is alive.
funcmypy.dmypy.client.is_running(status_file:str) -> bool
Check if the server is running cleanly
funcmypy.dmypy.client.main(argv:list[str]) -> None
The code is top-down.
funcmypy.dmypy.client.request(status_file:str, command:str, *timeout:int | None=None, **kwds:object) -> dict[str, Any]
Send a request to the daemon.
funcmypy.dmypy.client.restart_server(args:argparse.Namespace, allow_sources:bool=False) -> None
Restart daemon (it may or may not be running; but not hanging).
funcmypy.dmypy.client.start_server(args:argparse.Namespace, allow_sources:bool=False) -> None
Start the server from command arguments and wait for it.
funcmypy.dmypy.client.wait_for_server(status_file:str, timeout:float=5.0) -> None
Wait until the server is up.
funcmypy.dmypy_os.alive(pid:int) -> bool
Is the process alive?
funcmypy.dmypy_os.kill(pid:int) -> None
Kill the process.
methodmypy.dmypy_server.Server.check(sources:list[BuildSource], export_types:bool, is_tty:bool, terminal_width:int) -> dict[str, Any]
Check using fine-grained incremental mode.
methodmypy.dmypy_server.Server.cmd_check(files:Sequence[str], export_types:bool, is_tty:bool, terminal_width:int) -> dict[str, object]
Check a list of files.
methodmypy.dmypy_server.Server.cmd_hang() -> dict[str, object]
Hang for 100 seconds, as a debug hack.
methodmypy.dmypy_server.Server.cmd_status(fswatcher_dump_file:str | None=None) -> dict[str, object]
Return daemon status.
methodmypy.dmypy_server.Server.cmd_stop() -> dict[str, object]
Stop daemon.
methodmypy.dmypy_server.Server.cmd_suggest(function:str, callsites:bool, **kwargs:Any) -> dict[str, object]
Suggest a signature for a function.
methodmypy.dmypy_server.Server.direct_imports(module:tuple[str, str], graph:mypy.build.Graph) -> list[BuildSource]
Return the direct imports of module not included in seen.
methodmypy.dmypy_server.Server.fine_grained_increment_follow_imports(sources:list[BuildSource], explicit_export_types:bool=False) -> list[str]
Like fine_grained_increment, but follow imports.
methodmypy.dmypy_server.Server.following_imports() -> bool
Are we following imports?
methodmypy.dmypy_server.Server.run_command(command:str, data:dict[str, object]) -> dict[str, object]
Run a specific command from the registry.
methodmypy.dmypy_server.Server.serve() -> None
Serve requests, synchronously (no thread or fork).
funcmypy.dmypy_server.ignore_suppressed_imports(module:str) -> bool
Can we skip looking for newly unsuppressed imports to module?
classmypy.dmypy_util.WriteToConn
Helper class to write to a connection instead of standard output.
funcmypy.dmypy_util.receive(connection:IPCBase) -> Any
Receive single JSON data frame from a connection.
funcmypy.dmypy_util.send(connection:IPCBase, data:Any) -> None
Send data to a connection encoded and framed.
classmypy.erasetype.TypeVarEraser
Implementation of type erasure
funcmypy.erasetype.erase_type(typ:Type) -> ProperType
Erase any type variables from a type.
funcmypy.erasetype.replace_meta_vars(t:Type, target_type:Type) -> Type
Replace unification variables in a type with the target type.
funcmypy.erasetype.shallow_erase_type_for_equality(typ:Type) -> ProperType
Erase type variables from Instance's
classmypy.error_formatter.JSONFormatter
Formatter for basic JSON output format.
methodmypy.error_formatter.JSONFormatter.report_error(error:'MypyError') -> str
Prints out the errors as simple, static JSON lines.
classmypy.errors.CompileError
Exception raised when there is a compile error.
classmypy.errors.ErrorInfo
Representation of a single error message.
classmypy.errors.Errors
Container for compile errors.
methodmypy.errors.Errors.clear_errors_in_targets(path:str, targets:set[str]) -> None
Remove errors in specific fine-grained targets within a file.
methodmypy.errors.Errors.current_target() -> str | None
Retrieves the current target from the associated scope.
methodmypy.errors.Errors.file_messages(path:str) -> list[ErrorTuple]
Return an error tuple list of new error messages from a given file.
methodmypy.errors.Errors.find_shadow_file_mapping(path:str) -> str | None
Return the shadow file path for a given source file path or None.
methodmypy.errors.Errors.format_messages(path:str, error_tuples:list[ErrorTuple], formatter:ErrorFormatter | None=None) -> list[str]
Return a string list of new error messages from a given file.
methodmypy.errors.Errors.format_messages_default(error_tuples:list[ErrorTuple], source_lines:list[str] | None) -> list[str]
Return a string list that represents the error messages.
methodmypy.errors.Errors.get_watchers() -> Iterator[ErrorWatcher]
Yield the `ErrorWatcher` stack from top to bottom.
methodmypy.errors.Errors.import_context() -> list[tuple[str, int]]
Return a copy of the import context.
methodmypy.errors.Errors.is_blockers() -> bool
Are the any errors that are blockers?
methodmypy.errors.Errors.is_errors() -> bool
Are there any generated messages?
methodmypy.errors.Errors.is_errors_for_file(file:str) -> bool
Are there any errors for the given file?
methodmypy.errors.Errors.new_messages() -> list[str]
Return a string list of new error messages.
methodmypy.errors.Errors.num_messages() -> int
Return the number of generated messages.
methodmypy.errors.Errors.prefer_simple_messages() -> bool
Should we generate simple/fast error messages?
methodmypy.errors.Errors.raise_error(use_stdout:bool=True) -> NoReturn
Raise a CompileError with the generated messages.
methodmypy.errors.Errors.render_messages(file:str, errors:list[ErrorInfo]) -> list[ErrorTuple]
Translate the messages into a sequence of tuples.
methodmypy.errors.Errors.report_simple_error(file:str, line:int, message:str, code:ErrorCode | None) -> None
Generate a simple error in a module.
methodmypy.errors.Errors.set_file(file:str, module:str | None, options:Options, scope:Scope | None=None) -> None
Set the path and module id of the current file.
methodmypy.errors.Errors.set_ignore_prefix(prefix:str) -> None
Set path prefix that will be removed from all paths.
methodmypy.errors.Errors.set_import_context(ctx:list[tuple[str, int]]) -> None
Replace the entire import context with a new value.
methodmypy.errors.Errors.sort_messages(errors:list[ErrorInfo]) -> list[ErrorInfo]
Sort an array of error messages locally by line number.
methodmypy.errors.Errors.sort_within_context(errors:list[ErrorInfo]) -> list[ErrorInfo]
For the same location decide which messages to show first/last.
methodmypy.errors.Errors.targets() -> set[str]
Return a set of all targets that contain errors.
funcmypy.errors.remove_path_prefix(path:str, prefix:str | None) -> str
If path starts with prefix, return copy of path with the prefix removed.
funcmypy.errors.report_internal_error(err:Exception, file:str | None, line:int, errors:Errors | None, options:Options, stdout:TextIO | None=None, stderr:TextIO | None=None) -> NoReturn
Report internal error and exit.
funcmypy.evalexpr.evaluate_expression(expr:mypy.nodes.Expression) -> object
Evaluate an expression at runtime.
classmypy.expandtype.ExpandTypeVisitor
Visitor that substitutes type variables with values.
methodmypy.expandtype.ExpandTypeVisitor.expand_type_list_with_unpack(typs:list[Type]) -> list[Type]
Expands a list of types that has an unpack.
methodmypy.expandtype.ExpandTypeVisitor.expand_type_tuple_with_unpack(typs:tuple[Type, ...]) -> list[Type]
Expands a tuple of types that has an unpack.
funcmypy.expandtype.freshen_function_type_vars(callee:F) -> F
Substitute fresh type variables for generic function type variables.
classmypy.exprtotype.TypeTranslationError
Exception raised when an expression is not valid as a type.
classmypy.fastparse.FindAttributeAssign
Check if an AST contains attribute assignments (e.g.
classmypy.fastparse.FindYield
Check if an AST contains yields or yield froms.
funcmypy.fastparse.is_possible_trivial_body(s:list[Statement]) -> bool
Could the statements form a "trivial" function body, such as 'pass'?
funcmypy.fastparse.parse(source:str | bytes, fnam:str, module:str | None, errors:Errors, options:Options | None=None) -> MypyFile
Parse a source file, without doing any semantic analysis.
funcmypy.fastparse.parse_type_ignore_tag(tag:str | None) -> list[str] | None
Parse optional "[code, ...]" tag after "# type: ignore".
funcmypy.find_sources.keyfunc(name:str) -> tuple[bool, int, str]
Determines sort order for directory listing.
funcmypy.find_sources.module_join(parent:str, child:str) -> str
Join module ids, accounting for a possibly empty parent.
funcmypy.find_sources.strip_py(arg:str) -> str | None
Strip a trailing .py or .pyi suffix.
funcmypy.freetree.free_tree(tree:MypyFile) -> None
Free all the ASTs associated with a module.
methodmypy.fscache.FileSystemCache.flush() -> None
Start another transaction and empty all caches.
methodmypy.fscache.FileSystemCache.init_under_package_root(path:str) -> bool
Is this path an __init__.py under a package root?
methodmypy.fscache.FileSystemCache.isfile_case(path:str, prefix:str) -> bool
Return whether path exists and is a file.
classmypy.fswatcher.FileSystemWatcher
Watcher for file system changes among specific paths.
methodmypy.fswatcher.FileSystemWatcher.update_changed(remove:list[str], update:list[str]) -> AbstractSet[str]
Alternative to find_changed() given explicit changes.
classmypy.gclogger.GcLogger
Context manager to log GC stats and overall time.
funcmypy.git.git_revision(dir:str) -> bytes
Get the SHA-1 of the HEAD of a git repository.
funcmypy.git.have_git() -> bool
Can we run the git executable?
funcmypy.git.is_dirty(dir:str) -> bool
Check whether a git repository has uncommitted changes.
funcmypy.git.is_git_repo(dir:str) -> bool
Is the given directory version-controlled with git?
classmypy.graph_utils.topsort
Topological sort using Kahn's algorithm.
classmypy.indirection.TypeIndirectionVisitor
Returns all module references within a particular type.
classmypy.infer.ArgumentInferContext
Type argument inference context.
classmypy.inspections.InspectionEngine
Engine for locating and statically inspecting expressions.
methodmypy.inspections.InspectionEngine.collect_attrs(instances:list[Instance]) -> dict[TypeInfo, list[str]]
Collect attributes from all union/typevar variants.
methodmypy.inspections.InspectionEngine.collect_nodes(expression:RefExpr) -> list[FuncBase | SymbolNode]
Collect nodes that can be referred to by an expression.
methodmypy.inspections.InspectionEngine.expr_attrs(expression:Expression) -> tuple[str, bool]
Format attributes that are valid for a given expression.
methodmypy.inspections.InspectionEngine.expr_type(expression:Expression) -> tuple[str, bool]
Format type for an expression using current options.
methodmypy.inspections.InspectionEngine.expression_def(expression:Expression) -> tuple[str, bool]
Find and format definition location for an expression.
methodmypy.inspections.InspectionEngine.find_module(file:str) -> tuple[State | None, dict[str, object]]
Find module by path, or return a suitable error message.
methodmypy.inspections.InspectionEngine.get_attrs(location:str) -> dict[str, object]
Get attributes of expression(s) at a location.
methodmypy.inspections.InspectionEngine.get_definition(location:str) -> dict[str, object]
Get symbol definitions of expression(s) at a location.
methodmypy.inspections.InspectionEngine.get_type(location:str) -> dict[str, object]
Get types of expression(s) at a location.
methodmypy.inspections.InspectionEngine.reload_module(state:State) -> None
Reload given module while temporary exporting types.
methodmypy.inspections.InspectionEngine.run_inspection(location:str, method:Callable[[Expression], tuple[str, bool]]) -> dict[str, object]
Top-level logic to inspect expression(s) at a location.
funcmypy.inspections.expr_span(expr:Expression) -> str
Format expression span as in mypy error messages.
funcmypy.inspections.find_module_by_fullname(fullname:str, modules:dict[str, State]) -> State | None
Find module by a node fullname.
funcmypy.inspections.find_node(name:str, info:TypeInfo) -> Var | FuncBase | None
Find the node defining member 'name' in given TypeInfo.
funcmypy.inspections.get_instance_fallback(typ:ProperType) -> list[Instance]
Returns the Instance fallback for this type if one exists or None.
classmypy.ipc.BadStatus
Exception raised when there is something wrong with the status file.
classmypy.ipc.IPCBase
Base class for communication between the dmypy client and server.
methodmypy.ipc.IPCBase.frame_from_buffer() -> bytes | None
Return a full frame from the bytes we have in the buffer.
methodmypy.ipc.IPCBase.read_bytes(size:int=MAX_READ) -> bytes
Read bytes from an IPC connection until we have a full frame.
methodmypy.ipc.IPCBase.write_bytes(data:bytes) -> None
Write to an IPC connection.
classmypy.ipc.IPCClient
The client side of an IPC connection.
classmypy.ipc.IPCException
Exception for IPC issues.
funcmypy.ipc.read_status(status_file:str) -> dict[str, object]
Read status file.
funcmypy.ipc.ready_to_read(conns:Sequence[IPCBase], timeout:float | None=None) -> list[int]
Wait until some connections are readable.
funcmypy.ipc.receive(connection:IPCBase) -> ReadBuffer
Receive single encoded IPCMessage frame from a connection.
funcmypy.ipc.send(connection:IPCBase, data:IPCMessage) -> None
Send data to a connection encoded and framed.
classmypy.join.TypeJoinVisitor
Implementation of the least upper bound algorithm.
methodmypy.join.TypeJoinVisitor.join_tuples(s:TupleType, t:TupleType) -> list[Type] | None
Join two tuple types while handling variadic entries.
funcmypy.join.object_from_instance(instance:Instance) -> Instance
Construct the type 'builtins.object' from an instance type.
funcmypy.literals.extract_var_from_literal_hash(key:Key) -> Var | None
If key refers to a Var node, return it.
funcmypy.literals.literal(e:Expression) -> int
Return the literal kind for an expression.
funcmypy.literals.literal_hash(e:Expression) -> Key | None
Generate a hashable, (mostly) opaque key for expressions supported by the binder.
funcmypy.lookup.lookup_fully_qualified(name:str, modules:dict[str, MypyFile], *raise_on_missing:bool=False) -> SymbolTableNode | None
Find a symbol using it fully qualified name.
funcmypy.lookup.lookup_stdlib_typeinfo(fullname:str, modules:dict[str, MypyFile]) -> TypeInfo
Find TypeInfo for a standard library type.
classmypy.main.CapturableVersionAction
Supplement CapturableArgumentParser to handle --version.
funcmypy.main.fail(msg:str, stderr:TextIO, options:Options) -> NoReturn
Fail with a serious error.
funcmypy.main.infer_python_executable(options:Options, special_opts:argparse.Namespace) -> None
Infer the Python executable from the given version.
funcmypy.main.main(*args:list[str] | None=None, *stdout:TextIO=sys.stdout, *stderr:TextIO=sys.stderr, *clean_exit:bool=False) -> None
Main entry point to the type checker.
funcmypy.main.process_cache_map(parser:argparse.ArgumentParser, special_opts:argparse.Namespace, options:Options) -> None
Validate cache_map and copy into options.cache_map.
funcmypy.main.process_package_roots(fscache:FileSystemCache | None, parser:argparse.ArgumentParser, options:Options) -> None
Validate and normalize package_root.
funcmypy.meet.adjust_tuple(left:ProperType, r:ProperType) -> TupleType | None
Find out if `left` is a Tuple[A, ...], and adjust its length to `right`
funcmypy.meet.are_tuples_overlapping(left:Type, right:Type, is_overlapping:Callable[[Type, Type], bool]) -> bool
Returns true if left and right are overlapping tuples.
funcmypy.meet.is_literal_in_union(x:ProperType, y:ProperType) -> bool
Return True if x is a Literal and y is an Union that includes x
funcmypy.meet.meet_types(s:Type, t:Type) -> ProperType
Return the greatest lower bound of two types.
funcmypy.meet.narrow_declared_type(declared:Type, narrowed:Type) -> Type
Return the declared type narrowed down to another type.
funcmypy.meet.typed_dict_mapping_overlap(left:Type, right:Type, overlapping:Callable[[Type, Type], bool]) -> bool
Check if a TypedDict type is overlapping with a Mapping.
funcmypy.memprofile.collect_memory_stats() -> tuple[dict[str, int], dict[str, int]]
Return stats about memory use.
funcmypy.memprofile.find_recursive_objects(objs:list[object]) -> None
Find additional objects referenced by objs and append them to objs.
funcmypy.messages.capitalize(s:str) -> str
Capitalize the first character of a string.
funcmypy.messages.format_type_distinctly(*options:Options, *bare:bool=False, *types:Type) -> tuple[str, ...]
Jointly format types to distinct strings.
funcmypy.messages.ignore_last_known_values(t:UnionType) -> Type
This will avoid types like str | str in error messages.
funcmypy.messages.make_inferred_type_note(context:Context, subtype:Type, supertype:Type, supertype_str:str) -> str
Explain that the user may have forgotten to type a variable.
funcmypy.messages.pretty_callable(tp:CallableType, options:Options, skip_self:bool=False) -> str
Return a nice easily-readable representation of a callable type.
funcmypy.messages.quote_type_string(type_string:str) -> str
Quotes a type representation for use in messages.
funcmypy.messages.strip_quotes(s:str) -> str
Strip a double quote at the beginning and end of the string, if any.
classmypy.metastore.MetadataStore
Generic interface for metadata storage.
methodmypy.metastore.MetadataStore.close() -> None
Release any resources held by the backing store.
methodmypy.metastore.MetadataStore.commit() -> None
If the backing store requires a commit, do it.
methodmypy.metastore.MetadataStore.commit_path(name:str) -> None
Commit changes related to a specific cache path.
methodmypy.metastore.MetadataStore.getmtime(name:str) -> float
Read the mtime of a metadata entry.
methodmypy.metastore.MetadataStore.read(name:str) -> bytes
Read the contents of a metadata entry.
methodmypy.metastore.MetadataStore.remove(name:str) -> None
Delete a metadata entry
methodmypy.metastore.MetadataStore.write(name:str, data:bytes, mtime:float | None=None) -> bool
Write a metadata entry.
classmypy.mixedtraverser.MixedTraverserVisitor
Recursive traversal of both Node and Type objects.
classmypy.modulefinder.BuildSource
A single source file.
classmypy.modulefinder.FindModuleCache
Module finder with integrated cache.
funcmypy.modulefinder.compute_search_paths(sources:list[BuildSource], options:Options, data_dir:str, alt_lib_path:str | None=None) -> SearchPaths
Compute the search paths as specified in PEP 561.
funcmypy.modulefinder.default_lib_path(data_dir:str, pyversion:tuple[int, int], custom_typeshed_dir:str | None) -> list[str]
Return default standard library search paths.
funcmypy.modulefinder.get_search_dirs(python_executable:str | None) -> tuple[list[str], list[str]]
Find package directories for given python.
funcmypy.modulefinder.highest_init_level(fscache:FileSystemCache, id:str, path:str, prefix:str) -> int
Compute the highest level where an __init__ file is found.
funcmypy.modulefinder.verify_module(fscache:FileSystemCache, id:str, path:str, prefix:str) -> bool
Check that all packages containing id have a __init__ file.
classmypy.moduleinspect.ModuleInspect
Perform runtime introspection of modules in a separate process.
methodmypy.moduleinspect.ModuleInspect.close() -> None
Free any resources used.
funcmypy.moduleinspect.get_package_properties(package_id:str) -> ModuleProperties
Use runtime introspection to get information about a module/package.
funcmypy.moduleinspect.worker(tasks:Queue[str], results:Queue[str | ModuleProperties], sys_path:list[str]) -> None
The main loop of a worker introspection process.
classmypy.mro.MroError
Raised if a consistent mro cannot be determined for a class.
funcmypy.mro.calculate_mro(info:TypeInfo, obj_type:Callable[[], Instance] | None=None) -> None
Calculate and set mro (method resolution order).
methodmypy.nativeparse.State.add_error(message:str, line:int, column:int, *blocker:bool=False, *code:str) -> None
Report an error at a specific location.
funcmypy.nativeparse.deserialize_imports(import_bytes:bytes) -> list[ImportBase]
Deserialize import metadata from bytes into mypy AST nodes.
funcmypy.nativeparse.get_executable_if_block_with_overloads(stmt:IfStmt, options:Options) -> tuple[Block | None, IfStmt | None]
Return block from IfStmt that will get executed.
funcmypy.nativeparse.is_stripped_if_stmt(stmt:Statement) -> bool
Check stmt to make sure it is a stripped IfStmt.
funcmypy.nativeparse.read_call_type(state:State, data:ReadBuffer) -> Type
Read Call in type context (Arg/DefaultArg/VarArg/KwArg constructor).
funcmypy.nativeparse.read_parameters(state:State, data:ReadBuffer) -> tuple[list[Argument], bool]
Read function/lambda parameters.
funcmypy.nativeparse.read_type_alias_stmt(state:State, data:ReadBuffer) -> TypeAliasStmt
Read PEP 695 type alias statement.
funcmypy.nativeparse.read_type_params(state:State, data:ReadBuffer) -> list[TypeParam]
Read type parameters (PEP 695 generics).
funcmypy.nativeparse.strip_contents_from_if_stmt(stmt:IfStmt) -> None
Remove contents from IfStmt.
classmypy.nodes.Argument
A single argument in a FuncItem.
classmypy.nodes.AssertTypeExpr
Represents a typing.assert_type(expr, type) call.
classmypy.nodes.AssignmentExpr
Assignment expressions in Python 3.8+, like "a := 2".
classmypy.nodes.AssignmentStmt
Assignment statement.
classmypy.nodes.AwaitExpr
Await expression (await ...).
classmypy.nodes.BytesExpr
Bytes literal
classmypy.nodes.CallExpr
Call expression.
classmypy.nodes.CastExpr
Cast expression cast(type, expr).
classmypy.nodes.ClassDef
Class definition
classmypy.nodes.ComparisonExpr
Comparison expression (e.g.
classmypy.nodes.ComplexExpr
Complex literal
classmypy.nodes.ConditionalExpr
Conditional expression (e.g.
classmypy.nodes.Context
Base type for objects that are valid as error message locations.
classmypy.nodes.DataclassTransformSpec
Specifies how a dataclass-like transform should be applied.
classmypy.nodes.Decorator
A decorated function.
classmypy.nodes.DictExpr
Dictionary literal expression {key: value, ...}.
classmypy.nodes.DictionaryComprehension
Dictionary comprehension (e.g.
classmypy.nodes.EllipsisExpr
Ellipsis (...)
classmypy.nodes.EnumCallExpr
Named tuple expression Enum('name', 'val1 val2 ...').
classmypy.nodes.Expression
An expression node.
classmypy.nodes.ExpressionStmt
An expression as a statement, such as print(s).
classmypy.nodes.FakeExpression
A dummy expression.
classmypy.nodes.FileRawData
Raw (binary) data representing parsed, but not deserialized file.
classmypy.nodes.FloatExpr
Float literal
classmypy.nodes.FuncBase
Abstract base class for function-like nodes.
classmypy.nodes.FuncDef
Function definition.
classmypy.nodes.FuncItem
Base class for nodes usable as overloaded function items.
classmypy.nodes.GeneratorExpr
Generator expression ...
classmypy.nodes.GlobalDecl
Declaration global x, y, ...
classmypy.nodes.Import
import m [as n]
classmypy.nodes.ImportAll
from m import *
classmypy.nodes.ImportBase
Base class for all import statements.
classmypy.nodes.ImportFrom
from m import x [as y], ...
classmypy.nodes.IndexExpr
Index expression x[y].
classmypy.nodes.IntExpr
Integer literal
classmypy.nodes.LambdaExpr
Lambda expression
methodmypy.nodes.LambdaExpr.expr() -> Expression
Return the expression (the body) of the lambda.
classmypy.nodes.ListComprehension
List comprehension (e.g.
classmypy.nodes.ListExpr
List literal expression [...].
classmypy.nodes.MemberExpr
Member access expression x.y
classmypy.nodes.MypyFile
The abstract syntax tree of a single source file.
methodmypy.nodes.MypyFile.local_definitions(*impl_only:bool=False) -> Iterator[Definition]
Return all definitions within the module (including nested).

About this data

These signatures were extracted from the public source of python/mypy using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries