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

Method cmd_recheck

mypy/dmypy_server.py:368–417  ·  view source on GitHub ↗

Check the same list of files we checked most recently. If remove/update is given, they modify the previous list; if all are None, stat() is called for each file in the previous list.

(
        self,
        is_tty: bool,
        terminal_width: int,
        export_types: bool,
        remove: list[str] | None = None,
        update: list[str] | None = None,
    )

Source from the content-addressed store, hash-verified

366 return self.check(sources, export_types, is_tty, terminal_width)
367
368 def cmd_recheck(
369 self,
370 is_tty: bool,
371 terminal_width: int,
372 export_types: bool,
373 remove: list[str] | None = None,
374 update: list[str] | None = None,
375 ) -> dict[str, object]:
376 """Check the same list of files we checked most recently.
377
378 If remove/update is given, they modify the previous list;
379 if all are None, stat() is called for each file in the previous list.
380 """
381 t0 = time.time()
382 if not self.fine_grained_manager:
383 return {"error": "Command 'recheck' is only valid after a 'check' command"}
384 sources = self.previous_sources
385 if remove:
386 removals = set(remove)
387 sources = [s for s in sources if s.path and s.path not in removals]
388 if update:
389 # Sort list of file updates by extension, so *.pyi files are first.
390 update.sort(key=lambda f: os.path.splitext(f)[1], reverse=True)
391
392 known = {s.path for s in sources if s.path}
393 added = [p for p in update if p not in known]
394 try:
395 added_sources = create_source_list(added, self.options, self.fscache)
396 except InvalidSourceList as err:
397 return {"out": "", "err": str(err), "status": 2}
398 sources = sources + added_sources # Make a copy!
399 t1 = time.time()
400 manager = self.fine_grained_manager.manager
401 manager.log(f"fine-grained increment: cmd_recheck: {t1 - t0:.3f}s")
402 old_export_types = self.options.export_types
403 self.options.export_types = self.options.export_types or export_types
404 if not self.following_imports():
405 messages = self.fine_grained_increment(
406 sources, remove, update, explicit_export_types=export_types
407 )
408 else:
409 assert remove is None and update is None
410 messages = self.fine_grained_increment_follow_imports(
411 sources, explicit_export_types=export_types
412 )
413 res = self.increment_output(messages, sources, is_tty, terminal_width)
414 self.flush_caches()
415 self.update_stats(res)
416 self.options.export_types = old_export_types
417 return res
418
419 def check(
420 self, sources: list[BuildSource], export_types: bool, is_tty: bool, terminal_width: int

Callers

nothing calls this directly

Calls 11

following_importsMethod · 0.95
increment_outputMethod · 0.95
flush_cachesMethod · 0.95
update_statsMethod · 0.95
create_source_listFunction · 0.90
setClass · 0.85
strClass · 0.85
sortMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected