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

Method fine_grained_increment

mypy/dmypy_server.py:549–601  ·  view source on GitHub ↗

Perform a fine-grained type checking increment. If remove and update are None, determine changed paths by using fswatcher. Otherwise, assume that only these files have changes. Args: sources: sources passed on the command line remove: paths of files

(
        self,
        sources: list[BuildSource],
        remove: list[str] | None = None,
        update: list[str] | None = None,
        explicit_export_types: bool = False,
    )

Source from the content-addressed store, hash-verified

547 return {"out": "".join(s + "\n" for s in messages), "err": "", "status": status}
548
549 def fine_grained_increment(
550 self,
551 sources: list[BuildSource],
552 remove: list[str] | None = None,
553 update: list[str] | None = None,
554 explicit_export_types: bool = False,
555 ) -> list[str]:
556 """Perform a fine-grained type checking increment.
557
558 If remove and update are None, determine changed paths by using
559 fswatcher. Otherwise, assume that only these files have changes.
560
561 Args:
562 sources: sources passed on the command line
563 remove: paths of files that have been removed
564 update: paths of files that have been changed or created
565 explicit_export_types: --export-type was passed in a check command
566 (as opposite to being set in dmypy start)
567 """
568 assert self.fine_grained_manager is not None
569 manager = self.fine_grained_manager.manager
570
571 t0 = time.time()
572 if remove is None and update is None:
573 # Use the fswatcher to determine which files were changed
574 # (updated or added) or removed.
575 self.update_sources(sources)
576 changed, removed = self.find_changed(sources)
577 else:
578 # Use the remove/update lists to update fswatcher.
579 # This avoids calling stat() for unchanged files.
580 changed, removed = self.update_changed(sources, remove or [], update or [])
581 if explicit_export_types:
582 # If --export-types is given, we need to force full re-checking of all
583 # explicitly passed files, since we need to visit each expression.
584 add_all_sources_to_changed(sources, changed)
585 changed += self.find_added_suppressed(
586 self.fine_grained_manager.graph, set(), manager.search_paths
587 )
588 manager.search_paths = compute_search_paths(sources, manager.options, manager.data_dir)
589 t1 = time.time()
590 manager.log(f"fine-grained increment: find_changed: {t1 - t0:.3f}s")
591 messages = self.fine_grained_manager.update(changed, removed)
592 t2 = time.time()
593 manager.log(f"fine-grained increment: update: {t2 - t1:.3f}s")
594 manager.add_stats(
595 find_changes_time=t1 - t0,
596 fg_update_time=t2 - t1,
597 files_changed=len(removed) + len(changed),
598 )
599
600 self.previous_sources = sources
601 return messages
602
603 def fine_grained_increment_follow_imports(
604 self, sources: list[BuildSource], explicit_export_types: bool = False

Callers 2

cmd_recheckMethod · 0.95
checkMethod · 0.95

Calls 11

update_sourcesMethod · 0.95
find_changedMethod · 0.95
update_changedMethod · 0.95
find_added_suppressedMethod · 0.95
compute_search_pathsFunction · 0.90
setClass · 0.85
lenFunction · 0.85
add_statsMethod · 0.80
logMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected