class documentation

class Typeshed: (source)

View In Hierarchy

A typeshed installation. The location is either retrieved from the environment variable "TYPESHED_HOME" (if set) or otherwise assumed to be directly under pytype (i.e., /{some_path}/pytype/typeshed).

Method __init__ Initializer.
Method blacklisted_modules Return the blacklist, as a list of module names. E.g. ["x", "y.z"].
Method get_all_module_names Get the names of all modules in typeshed or bundled with pytype.
Method get_module_file Get the contents of a typeshed .pyi file.
Method get_pytd_paths Gets the paths to pytype's version-specific pytd files.
Method get_typeshed_paths Gets the paths to typeshed's version-specific pyi files.
Method read_blacklist Read the typeshed blacklist.
Constant MISSING_FILE Undocumented
Property missing Set of known-missing typeshed modules, as strings of paths.
Method _get_missing_modules Gets module names from the `missing` list.
Method _is_module_in_typeshed Undocumented
Method _list_modules Lists modules for _get_module_names_in_path.
Method _load_missing Undocumented
Method _load_stdlib_versions Loads the contents of typeshed/stdlib/VERSIONS.
Method _load_third_party_packages Loads package and Python version information for typeshed/stubs/.
Method _lookup_stdlib_version Looks up the prefix chain until we find the module in stdlib/VERSIONS.
Instance Variable _missing Undocumented
Instance Variable _stdlib_versions Undocumented
Instance Variable _store Undocumented
Instance Variable _third_party_packages Undocumented
def __init__(self, missing_modules: Collection[str] = ()): (source)

Initializer. Args: missing_modules: A collection of modules in the format 'stdlib/module_name', which will be combined with the contents of MISSING_FILE to form a set of missing modules for which pytype will not report errors.

def blacklisted_modules(self): (source)

Return the blacklist, as a list of module names. E.g. ["x", "y.z"].

def get_all_module_names(self, python_version): (source)

Get the names of all modules in typeshed or bundled with pytype.

def get_module_file(self, namespace, module, version): (source)

Get the contents of a typeshed .pyi file. Arguments: namespace: selects a top-level directory within typeshed/ Allowed values are "stdlib" and "third_party". "third_party" corresponds to the the typeshed/stubs/ directory. module: module name (e.g., "sys" or "__builtins__"). Can contain dots, if it's a submodule. Package names should omit the "__init__" suffix (e.g., pass in "os", not "os.__init__"). version: The Python version. (major, minor) Returns: A tuple with the filename and contents of the file Raises: IOError: if file not found

def get_pytd_paths(self): (source)

Gets the paths to pytype's version-specific pytd files.

def get_typeshed_paths(self): (source)

Gets the paths to typeshed's version-specific pyi files.

def read_blacklist(self): (source)

Read the typeshed blacklist.

MISSING_FILE = (source)

Undocumented

Value
None

Set of known-missing typeshed modules, as strings of paths.

def _get_missing_modules(self): (source)

Gets module names from the `missing` list.

def _is_module_in_typeshed(self, module_parts, version): (source)

Undocumented

def _list_modules(self, path, python_version): (source)

Lists modules for _get_module_names_in_path.

def _load_missing(self): (source)

Undocumented

def _load_stdlib_versions(self): (source)

Loads the contents of typeshed/stdlib/VERSIONS. VERSIONS lists the stdlib modules with the Python version in which they were first added, in the format `{module}: {min_major}.{min_minor}-` or `{module}: {min_major}.{min_minor}-{max_major}.{max_minor}`. Returns: A mapping from module name to version range in the format {name: ((min_major, min_minor), (max_major, max_minor))} The max tuple can be `None`.

def _load_third_party_packages(self): (source)

Loads package and Python version information for typeshed/stubs/. stubs/ contains type information for third-party packages. Each top-level directory corresponds to one PyPI package and contains one or more modules, plus a metadata file (METADATA.toml). The top-level directory may contain a @tests subdirectory for typeshed testing. Returns: A mapping from module name to a set of package names.

def _lookup_stdlib_version(self, module_parts: Sequence[str]): (source)

Looks up the prefix chain until we find the module in stdlib/VERSIONS.

_missing = (source)

Undocumented

_stdlib_versions = (source)

Undocumented

Undocumented

_third_party_packages = (source)

Undocumented