Find suppressed modules that have been added (and not included in seen). Args: seen: reachable modules we've seen before (mutated here!!). Needed to accumulate all modules encountered during update and remove everything that no longer exists.
(
self, graph: mypy.build.Graph, seen: set[str], search_paths: SearchPaths
)
| 778 | return [BuildSource(graph[dep].path, dep, followed=True) for dep in state.dependencies] |
| 779 | |
| 780 | def find_added_suppressed( |
| 781 | self, graph: mypy.build.Graph, seen: set[str], search_paths: SearchPaths |
| 782 | ) -> list[tuple[str, str]]: |
| 783 | """Find suppressed modules that have been added (and not included in seen). |
| 784 | |
| 785 | Args: |
| 786 | seen: reachable modules we've seen before (mutated here!!). |
| 787 | Needed to accumulate all modules encountered during update and remove |
| 788 | everything that no longer exists. |
| 789 | |
| 790 | Return suppressed, added modules. |
| 791 | """ |
| 792 | all_suppressed = set() |
| 793 | for state in graph.values(): |
| 794 | all_suppressed |= state.suppressed_set |
| 795 | |
| 796 | # Filter out things that shouldn't actually be considered suppressed. |
| 797 | # |
| 798 | # TODO: Figure out why these are treated as suppressed |
| 799 | all_suppressed = { |
| 800 | module |
| 801 | for module in all_suppressed |
| 802 | if module not in graph and not ignore_suppressed_imports(module) |
| 803 | } |
| 804 | |
| 805 | # Optimization: skip top-level packages that are obviously not |
| 806 | # there, to avoid calling the relatively slow find_module() |
| 807 | # below too many times. |
| 808 | packages = {module.split(".", 1)[0] for module in all_suppressed} |
| 809 | packages = filter_out_missing_top_level_packages(packages, search_paths, self.fscache) |
| 810 | |
| 811 | # TODO: Namespace packages |
| 812 | |
| 813 | finder = FindModuleCache(search_paths, self.fscache, self.options) |
| 814 | |
| 815 | found = [] |
| 816 | |
| 817 | for module in all_suppressed: |
| 818 | top_level_pkg = module.split(".", 1)[0] |
| 819 | if top_level_pkg not in packages: |
| 820 | # Fast path: non-existent top-level package |
| 821 | continue |
| 822 | result = finder.find_module(module, fast_path=True) |
| 823 | if isinstance(result, str) and module not in seen: |
| 824 | # When not following imports, we only follow imports to .pyi files. |
| 825 | if not self.following_imports() and not result.endswith(".pyi"): |
| 826 | continue |
| 827 | found.append((module, result)) |
| 828 | seen.add(module) |
| 829 | |
| 830 | return found |
| 831 | |
| 832 | def increment_output( |
| 833 | self, messages: list[str], sources: list[BuildSource], is_tty: bool, terminal_width: int |
no test coverage detected