class documentation

class FileSystemCache: (source)

Known subclasses: mypy.test.test_find_sources.FakeFSCache

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method exists Undocumented
Method exists_case Return whether path exists - checking path components in case sensitive fashion, up to prefix.
Method flush Start another transaction and empty all caches.
Method hash_digest Undocumented
Method init_under_package_root Is this path an __init__.py under a package root?
Method isdir Undocumented
Method isfile Undocumented
Method isfile_case Return whether path exists and is a file.
Method listdir Undocumented
Method read Undocumented
Method samefile Undocumented
Method set_package_root Undocumented
Method stat Undocumented
Instance Variable exists_case_cache Undocumented
Instance Variable fake_package_cache Undocumented
Instance Variable hash_cache Undocumented
Instance Variable isfile_case_cache Undocumented
Instance Variable listdir_cache Undocumented
Instance Variable listdir_error_cache Undocumented
Instance Variable package_root Undocumented
Instance Variable read_cache Undocumented
Instance Variable read_error_cache Undocumented
Instance Variable stat_cache Undocumented
Instance Variable stat_error_cache Undocumented
Method _fake_init Prime the cache with a fake __init__.py file.
def __init__(self): (source)

Undocumented

def exists(self, path: str) -> bool: (source)

Undocumented

def exists_case(self, path: str, prefix: str) -> bool: (source)

Return whether path exists - checking path components in case sensitive fashion, up to prefix.

def flush(self): (source)

Start another transaction and empty all caches.

def hash_digest(self, path: str) -> str: (source)

Undocumented

def init_under_package_root(self, path: str) -> bool: (source)

Is this path an __init__.py under a package root? This is used to detect packages that don't contain __init__.py files, which is needed to support Bazel. The function should only be called for non-existing files. It will return True if it refers to a __init__.py file that Bazel would create, so that at runtime Python would think the directory containing it is a package. For this to work you must pass one or more package roots using the --package-root flag. As an exceptional case, any directory that is a package root itself will not be considered to contain a __init__.py file. This is different from the rules Bazel itself applies, but is necessary for mypy to properly distinguish packages from other directories. See https://docs.bazel.build/versions/master/be/python.html, where this behavior is described under legacy_create_init.

def isdir(self, path: str) -> bool: (source)

Undocumented

def isfile(self, path: str) -> bool: (source)

Undocumented

def isfile_case(self, path: str, prefix: str) -> bool: (source)

Return whether path exists and is a file. On case-insensitive filesystems (like Mac or Windows) this returns False if the case of path's last component does not exactly match the case found in the filesystem. We check also the case of other path components up to prefix. For example, if path is 'user-stubs/pack/mod.pyi' and prefix is 'user-stubs', we check that the case of 'pack' and 'mod.py' matches exactly, 'user-stubs' will be case insensitive on case insensitive filesystems. The caller must ensure that prefix is a valid file system prefix of path.

def listdir(self, path: str) -> list[str]: (source)

Undocumented

def read(self, path: str) -> bytes: (source)

Undocumented

def samefile(self, f1: str, f2: str) -> bool: (source)

Undocumented

def set_package_root(self, package_root: list[str]): (source)

Undocumented

def stat(self, path: str) -> os.stat_result: (source)

Undocumented

exists_case_cache: dict[str, bool] = (source)

Undocumented

fake_package_cache: set[str] = (source)

Undocumented

hash_cache: dict[str, str] = (source)

Undocumented

isfile_case_cache: dict[str, bool] = (source)

Undocumented

listdir_cache: dict[str, list[str]] = (source)

Undocumented

listdir_error_cache: dict[str, OSError] = (source)

Undocumented

package_root = (source)

Undocumented

read_cache: dict[str, bytes] = (source)

Undocumented

read_error_cache: dict[str, Exception] = (source)

Undocumented

Undocumented

stat_error_cache: dict[str, OSError] = (source)

Undocumented

def _fake_init(self, path: str) -> os.stat_result: (source)

Prime the cache with a fake __init__.py file. This makes code that looks for path believe an empty file by that name exists. Should only be called after init_under_package_root() returns True.