MCPcopy
hub / github.com/python/mypy / FineGrainedBuildManager

Class FineGrainedBuildManager

mypy/server/update.py:171–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169
170
171class FineGrainedBuildManager:
172 def __init__(self, result: BuildResult) -> None:
173 """Initialize fine-grained build based on a batch build.
174
175 Args:
176 result: Result from the initialized build.
177 The manager and graph will be taken over by this class.
178 manager: State of the build (mutated by this class)
179 graph: Additional state of the build (mutated by this class)
180 """
181 manager = result.manager
182 self.manager = manager
183 self.graph = result.graph
184 self.previous_modules = get_module_to_path_map(self.graph)
185 self.deps = manager.fg_deps
186 # Merge in any root dependencies that may not have been loaded
187 merge_dependencies(manager.load_fine_grained_deps(FAKE_ROOT_MODULE), self.deps)
188 self.previous_targets_with_errors = manager.errors.targets()
189 self.previous_messages: list[str] = result.errors.copy()
190 # Module, if any, that had blocking errors in the last run as (id, path) tuple.
191 self.blocking_error: tuple[str, str] | None = None
192 # Module that we haven't processed yet but that are known to be stale.
193 self.stale: list[tuple[str, str]] = []
194 # Disable the cache so that load_graph doesn't try going back to disk
195 # for the cache.
196 self.manager.cache_enabled = False
197
198 # Some hints to the test suite about what is going on:
199 # Active triggers during the last update
200 self.triggered: list[str] = []
201 # Modules passed to update during the last update
202 self.changed_modules: list[tuple[str, str]] = []
203 # Modules processed during the last update
204 self.updated_modules: list[str] = []
205 # Targets processed during last update (for testing only).
206 self.processed_targets: list[str] = []
207
208 def update(
209 self,
210 changed_modules: list[tuple[str, str]],
211 removed_modules: list[tuple[str, str]],
212 followed: bool = False,
213 ) -> list[str]:
214 """Update previous build result by processing changed modules.
215
216 Also propagate changes to other modules as needed, but only process
217 those parts of other modules that are affected by the changes. Retain
218 the existing ASTs and symbol tables of unaffected modules.
219
220 Reuses original BuildManager and Graph.
221
222 Args:
223 changed_modules: Modules changed since the previous update/build; each is
224 a (module id, path) tuple. Includes modified and added modules.
225 Assume this is correct; it's not validated here.
226 removed_modules: Modules that have been deleted since the previous update
227 or removed from the build.
228 followed: If True, the modules were found through following imports

Callers 2

run_caseMethod · 0.90

Calls

no outgoing calls

Tested by 1

run_caseMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…