MCPcopy Index your code
hub / github.com/python/mypy / BuildSourceSet

Class BuildSourceSet

mypy/modulefinder.py:148–169  ·  view source on GitHub ↗

Helper to efficiently test a file's membership in a set of build sources.

Source from the content-addressed store, hash-verified

146
147
148class BuildSourceSet:
149 """Helper to efficiently test a file's membership in a set of build sources."""
150
151 def __init__(self, sources: list[BuildSource]) -> None:
152 self.source_text_present = False
153 self.source_modules: dict[str, str] = {}
154 self.source_paths: set[str] = set()
155
156 for source in sources:
157 if source.text is not None:
158 self.source_text_present = True
159 if source.path:
160 self.source_paths.add(source.path)
161 if source.module:
162 self.source_modules[source.module] = source.path or ""
163
164 def is_source(self, file: MypyFile) -> bool:
165 return (
166 (file.path and file.path in self.source_paths)
167 or file._fullname in self.source_modules
168 or self.source_text_present
169 )
170
171
172class FindModuleCache:

Callers 3

build_innerFunction · 0.90
setup_worker_managerFunction · 0.90
_make_managerMethod · 0.85

Calls

no outgoing calls

Tested by 1

_make_managerMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…