class documentation

class ImportsMapBuilder: (source)

View In Hierarchy

Build an imports map from (short_path, path) pairs.

Method __init__ Undocumented
Method build_from_file Create an ImportsMap from a .imports_info file.
Method build_from_items Create a file mapping from a list of (short path, path) tuples.
Instance Variable options Undocumented
Method _build_multimap Build a multimap from a list of (short_path, path) pairs.
Method _finalize Generate the final imports map.
Method _read_from_file Read the imports_map file.
Method _validate Validate the imports map against the command line arguments.
def __init__(self, options): (source)

Undocumented

def build_from_file(self, path: Optional[str]) -> Optional[ImportsMapType]: (source)

Create an ImportsMap from a .imports_info file. Builds a dict of short_path to full name (e.g. "path/to/file.py" => "$GENDIR/rulename~~pytype-gen/path_to_file.py~~pytype" Args: path: The file with the info (may be None, for do-nothing) Returns: Dict of .py short_path to list of .pytd path or None if no path Raises: ValueError if the imports map is invalid

def build_from_items(self, items: Optional[List[ItemType]], path=None) -> Optional[ImportsMapType]: (source)

Create a file mapping from a list of (short path, path) tuples. Builds a dict of short_path to full name (e.g. "path/to/file.py" => "$GENDIR/rulename~~pytype-gen/path_to_file.py~~pytype" Args: items: A list of (short_path, full_path) tuples. path: The file from which the items were read (for error messages) Returns: Dict of .py short_path to list of .pytd path or None if no items Raises: ValueError if the imports map is invalid

Undocumented

def _build_multimap(self, items: List[ItemType]) -> MultimapType: (source)

Build a multimap from a list of (short_path, path) pairs.

def _finalize(self, imports_multimap: MultimapType, path: str = '') -> ImportsMapType: (source)

Generate the final imports map.

def _read_from_file(self, path) -> List[ItemType]: (source)

Read the imports_map file.

def _validate(self, imports_map: MultimapType) -> List[ItemType]: (source)

Validate the imports map against the command line arguments. Args: imports_map: The map returned by _read_imports_map. Returns: A list of invalid entries, in the form (short_path, long_path)