module documentation

Public interface to top-level pytype functions.

Class AnalysisResult Preserve all state and results from running pytype.
Function check_or_generate_pyi Returns results from running pytype.
Function check_py Check the types of a string of source code.
Function generate_pyi Run the inferencer on a string of source code, producing output.
Function get_pytype_version Undocumented
Function handle_errors Handle the errorlog according to the given options.
Function parse_pyi Tries parsing a PYI file.
Function print_error_doc_url Undocumented
Function process_one_file Check a .py file or generate a .pyi for it, according to options.
Function read_source_file Undocumented
Function wrap_pytype_exceptions Catch pytype errors and reraise them as a single exception type.
Function write_pickle Dump a pickle of the ast to a file.
Constant ERROR_DOC_URL Undocumented
Variable log Undocumented
Function _call Helper function to call analyze.check/infer_types.
Function _set_verbosity_from Decorator to set the verbosity for a function that takes an options arg.
Function _write_pyi_output Undocumented
@_set_verbosity_from(posarg=0)
def check_or_generate_pyi(options, loader=None, ctx=None) -> AnalysisResult: (source)

Returns results from running pytype. Args: options: config.Options object. loader: load_pytd.Loader object. ctx: A context Returns: A tuple, (errors.ErrorLog, PYI Ast as string or None, AST or None).

def check_py(src, options=None, loader=None, ctx=None): (source)

Check the types of a string of source code.

def generate_pyi(src, options=None, loader=None, ctx=None): (source)

Run the inferencer on a string of source code, producing output. Args: src: The source code. options: config.Options object. loader: A load_pytd.Loader instance. ctx: A context Returns: A tuple, (errors.ErrorLog, PYI Ast as string, TypeDeclUnit). Raises: CompileError: If we couldn't parse the input file. UsageError: If the input filepath is invalid.

def get_pytype_version(): (source)

Undocumented

@_set_verbosity_from(posarg=1)
def handle_errors(errorlog, options): (source)

Handle the errorlog according to the given options.

@_set_verbosity_from(posarg=0)
def parse_pyi(options): (source)

Tries parsing a PYI file.

def print_error_doc_url(errorlog): (source)

Undocumented

@_set_verbosity_from(posarg=0)
def process_one_file(options): (source)

Check a .py file or generate a .pyi for it, according to options. Args: options: config.Options object. Returns: An error code (0 means no error).

def read_source_file(input_filename, open_function=open): (source)

Undocumented

@contextlib.contextmanager
def wrap_pytype_exceptions(exception_type, filename=''): (source)

Catch pytype errors and reraise them as a single exception type. NOTE: This will also wrap non-pytype errors thrown within the body of the code block; it is therefore recommended to use this to wrap a single function call. Args: exception_type: The class to wrap exceptions in. filename: A filename to use in error messages. Yields: nothing, just calls the code block.

@_set_verbosity_from(posarg=1)
def write_pickle(ast, options, loader=None): (source)

Dump a pickle of the ast to a file.

ERROR_DOC_URL: str = (source)

Undocumented

Value
'https://google.github.io/pytype/errors.html'

Undocumented

@_set_verbosity_from(posarg=2)
def _call(analyze_types, src, options, loader, *, ctx=None): (source)

Helper function to call analyze.check/infer_types.

def _set_verbosity_from(posarg): (source)

Decorator to set the verbosity for a function that takes an options arg. Assumes that the function has an argument named `options` that is a config.Options object. Arguments: posarg: The index of `options` in the positional arguments. Returns: The decorator.

def _write_pyi_output(options, contents, filename): (source)

Undocumented