(
self, sources: list[BuildSource], is_tty: bool, terminal_width: int
)
| 459 | return self.options.follow_imports == "normal" |
| 460 | |
| 461 | def initialize_fine_grained( |
| 462 | self, sources: list[BuildSource], is_tty: bool, terminal_width: int |
| 463 | ) -> dict[str, Any]: |
| 464 | self.fswatcher = FileSystemWatcher(self.fscache) |
| 465 | t0 = time.time() |
| 466 | self.update_sources(sources) |
| 467 | t1 = time.time() |
| 468 | try: |
| 469 | result = mypy.build.build(sources=sources, options=self.options, fscache=self.fscache) |
| 470 | except mypy.errors.CompileError as e: |
| 471 | output = "".join(s + "\n" for s in e.messages) |
| 472 | if e.use_stdout: |
| 473 | out, err = output, "" |
| 474 | else: |
| 475 | out, err = "", output |
| 476 | return {"out": out, "err": err, "status": 2} |
| 477 | messages = result.errors |
| 478 | self.fine_grained_manager = FineGrainedBuildManager(result) |
| 479 | |
| 480 | original_sources_len = len(sources) |
| 481 | if self.following_imports(): |
| 482 | sources = find_all_sources_in_build(self.fine_grained_manager.graph, sources) |
| 483 | self.update_sources(sources) |
| 484 | |
| 485 | self.previous_sources = sources |
| 486 | |
| 487 | # If we are using the fine-grained cache, build hasn't actually done |
| 488 | # the typechecking on the updated files yet. |
| 489 | # Run a fine-grained update starting from the cached data |
| 490 | if result.used_cache: |
| 491 | t2 = time.time() |
| 492 | # Pull times and hashes out of the saved_cache and stick them into |
| 493 | # the fswatcher, so we pick up the changes. |
| 494 | for state in self.fine_grained_manager.graph.values(): |
| 495 | meta = state.meta |
| 496 | if meta is None: |
| 497 | continue |
| 498 | assert state.path is not None |
| 499 | self.fswatcher.set_file_data( |
| 500 | state.path, |
| 501 | FileData(st_mtime=float(meta.mtime), st_size=meta.size, hash=meta.hash), |
| 502 | ) |
| 503 | |
| 504 | changed, removed = self.find_changed(sources) |
| 505 | changed += self.find_added_suppressed( |
| 506 | self.fine_grained_manager.graph, |
| 507 | set(), |
| 508 | self.fine_grained_manager.manager.search_paths, |
| 509 | ) |
| 510 | |
| 511 | # Find anything that has had its dependency list change |
| 512 | for state in self.fine_grained_manager.graph.values(): |
| 513 | if not state.is_fresh(): |
| 514 | assert state.path is not None |
| 515 | changed.append((state.id, state.path)) |
| 516 | |
| 517 | t3 = time.time() |
| 518 | # Run an update |
no test coverage detected