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

Method update

mypy/server/update.py:208–305  ·  view source on GitHub ↗

Update previous build result by processing changed modules. Also propagate changes to other modules as needed, but only process those parts of other modules that are affected by the changes. Retain the existing ASTs and symbol tables of unaffected modules. Reuses or

(
        self,
        changed_modules: list[tuple[str, str]],
        removed_modules: list[tuple[str, str]],
        followed: bool = False,
    )

Source from the content-addressed store, hash-verified

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
229
230 Returns:
231 A list of errors.
232 """
233 self.processed_targets.clear()
234 changed_modules = changed_modules + removed_modules
235 removed_set = {module for module, _ in removed_modules}
236 self.changed_modules = changed_modules
237
238 if not changed_modules:
239 return self.previous_messages
240
241 # Reset find_module's caches for the new build.
242 self.manager.find_module_cache.clear()
243
244 self.triggered = []
245 self.updated_modules = []
246 changed_modules = dedupe_modules(changed_modules + self.stale)
247 initial_set = {id for id, _ in changed_modules}
248 self.manager.log_fine_grained(
249 "==== update %s ====" % ", ".join(repr(id) for id, _ in changed_modules)
250 )
251 if self.previous_targets_with_errors and is_verbose(self.manager):
252 self.manager.log_fine_grained(
253 "previous targets with errors: %s" % sorted(self.previous_targets_with_errors)
254 )
255
256 blocking_error = None
257 if self.blocking_error:
258 # Handle blocking errors first. We'll exit as soon as we find a
259 # module that still has blocking errors.
260 self.manager.log_fine_grained(f"existing blocker: {self.blocking_error[0]}")
261 changed_modules = dedupe_modules([self.blocking_error] + changed_modules)
262 blocking_error = self.blocking_error[0]
263 self.blocking_error = None
264
265 while True:

Callers 15

triggerMethod · 0.95
build_incrementMethod · 0.45
verify_cacheMethod · 0.45
install_packageFunction · 0.45
split_test_casesFunction · 0.45
run_caseMethod · 0.45
visit_mypy_fileMethod · 0.45
merge_dependenciesFunction · 0.45
dump_all_dependenciesFunction · 0.45
update_moduleMethod · 0.45

Calls 14

update_oneMethod · 0.95
dedupe_modulesFunction · 0.85
reprFunction · 0.85
is_verboseFunction · 0.85
sortedFunction · 0.85
setClass · 0.85
log_fine_grainedMethod · 0.80
clearMethod · 0.45
joinMethod · 0.45
targetsMethod · 0.45

Tested by

no test coverage detected