module documentation

Mypy type checker command line tool.

Class AugmentedHelpFormatter Undocumented
Class CapturableArgumentParser Override ArgumentParser methods that use sys.stdout/sys.stderr directly.
Class CapturableVersionAction Supplement CapturableArgumentParser to handle --version.
Exception PythonExecutableInferenceError Represents a failure to infer the version or executable while searching.
Function fail Fail with a serious error.
Function infer_python_executable Infer the Python executable from the given version.
Function install_types Install stub packages using pip if some missing stubs were detected.
Function invert_flag_name Undocumented
Function main Main entry point to the type checker.
Function maybe_write_junit_xml Undocumented
Function process_cache_map Validate cache_map and copy into options.cache_map.
Function process_options Parse command line arguments.
Function process_package_roots Validate and normalize package_root.
Function python_executable_prefix Undocumented
Function read_types_packages_to_install Undocumented
Function run_build Undocumented
Function show_messages Undocumented
Function stat_proxy Undocumented
Constant DESCRIPTION Undocumented
Constant flag_prefix_map Undocumented
Constant flag_prefix_pairs Undocumented
Constant FOOTER Undocumented
Constant HEADER Undocumented
Constant MEM_PROFILE Undocumented
Function _python_executable_from_version Undocumented
def fail(msg: str, stderr: TextIO, options: Options) -> NoReturn: (source)

Fail with a serious error.

def infer_python_executable(options: Options, special_opts: argparse.Namespace): (source)

Infer the Python executable from the given version. This function mutates options based on special_opts to infer the correct Python executable to use.

def install_types(formatter: util.FancyFormatter, options: Options, *, after_run: bool = False, non_interactive: bool = False) -> bool: (source)

Install stub packages using pip if some missing stubs were detected.

def invert_flag_name(flag: str) -> str: (source)

Undocumented

def main(*, args: list[str]|None = None, stdout: TextIO = sys.stdout, stderr: TextIO = sys.stderr, clean_exit: bool = False): (source)

Main entry point to the type checker. Args: args: Custom command-line arguments. If not given, sys.argv[1:] will be used. clean_exit: Don't hard kill the process on exit. This allows catching SystemExit.

def maybe_write_junit_xml(td: float, serious: bool, messages: list[str], options: Options): (source)

Undocumented

def process_cache_map(parser: argparse.ArgumentParser, special_opts: argparse.Namespace, options: Options): (source)

Validate cache_map and copy into options.cache_map.

def process_options(args: list[str], stdout: TextIO|None = None, stderr: TextIO|None = None, require_targets: bool = True, server_options: bool = False, fscache: FileSystemCache|None = None, program: str = 'mypy', header: str = HEADER) -> tuple[list[BuildSource], Options]: (source)

Parse command line arguments. If a FileSystemCache is passed in, and package_root options are given, call fscache.set_package_root() to set the cache's package root.

def process_package_roots(fscache: FileSystemCache|None, parser: argparse.ArgumentParser, options: Options): (source)

Validate and normalize package_root.

def python_executable_prefix(v: str) -> list[str]: (source)

Undocumented

def read_types_packages_to_install(cache_dir: str, after_run: bool) -> list[str]: (source)

Undocumented

def run_build(sources: list[BuildSource], options: Options, fscache: FileSystemCache, t0: float, stdout: TextIO, stderr: TextIO) -> tuple[build.BuildResult|None, list[str], bool]: (source)

Undocumented

def show_messages(messages: list[str], f: TextIO, formatter: util.FancyFormatter, options: Options): (source)

Undocumented

def stat_proxy(path: str) -> os.stat_result: (source)

Undocumented

DESCRIPTION: str = (source)

Undocumented

Value
'''
Mypy is a program that will type check your Python code.

Pass in any files or folders you want to type check. Mypy will
recursively traverse any provided folders to find .py files:

    $ mypy my_program.py my_src_folder
...
flag_prefix_map: dict[str, str] = (source)

Undocumented

Value
{}
flag_prefix_pairs: list = (source)

Undocumented

Value
[('allow', 'disallow'), ('show', 'hide')]

Undocumented

Value
'''Environment variables:
  Define MYPYPATH for additional module search path entries.
  Define MYPY_CACHE_DIR to override configuration cache_dir path.'''

Undocumented

Value
'''%(prog)s [-h] [-v] [-V] [more options; see below]
            [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]'''
MEM_PROFILE: bool = (source)

Undocumented

Value
False
def _python_executable_from_version(python_version: tuple[int, int]) -> str: (source)

Undocumented