MCPcopy Create free account
hub / github.com/python/mypy / FakeFSCache

Class FakeFSCache

mypy/test/test_find_sources.py:16–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class FakeFSCache(FileSystemCache):
17 def __init__(self, files: set[str]) -> None:
18 self.files = {os.path.abspath(f) for f in files}
19
20 def isfile(self, path: str) -> bool:
21 return path in self.files
22
23 def isdir(self, path: str) -> bool:
24 if not path.endswith(os.sep):
25 path += os.sep
26 return any(f.startswith(path) for f in self.files)
27
28 def listdir(self, path: str) -> list[str]:
29 if not path.endswith(os.sep):
30 path += os.sep
31 return list({f[len(path) :].split(os.sep)[0] for f in self.files if f.startswith(path)})
32
33 def init_under_package_root(self, path: str) -> bool:
34 return False
35
36
37def normalise_path(path: str) -> str:

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…