-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Type ignore comments erroneously marked as unused by dmypy #15043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
1ce2f21
7d9c06a
9cd625d
94e5df4
b5cc83f
99eda13
d798c5a
ad94241
22777be
64cbe6b
6e34703
6c378b1
d58936a
6dd9c2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -684,10 +684,11 @@ def refresh_file(module: str, path: str) -> list[str]: | |
|
|
||
| # Find all original modules in graph that were not reached -- they are deleted. | ||
| to_delete = [] | ||
| seen_and_ancestors = self._seen_and_ancestors(seen) | ||
| for module_id in orig_modules: | ||
| if module_id not in graph: | ||
| continue | ||
| if module_id not in seen: | ||
| if module_id not in seen_and_ancestors: | ||
| module_path = graph[module_id].path | ||
| assert module_path is not None | ||
| to_delete.append((module_id, module_path)) | ||
|
|
@@ -715,6 +716,29 @@ def refresh_file(module: str, path: str) -> list[str]: | |
|
|
||
| return messages | ||
|
|
||
| def _seen_and_ancestors(self, seen: set[str]) -> set[str]: | ||
| """Return the set of seen modules along with any ancestors not already in the set. | ||
|
|
||
| For example, given this set: | ||
|
|
||
| {"foo", "foo.bar", "a.b.c"} | ||
|
|
||
| ... we would expect this set to be returned: | ||
|
|
||
| {"foo", "foo.bar", "a.b.c", "a.b", "a"} | ||
|
|
||
| This is used to stop us from deleting ancestor modules from the graph | ||
| when their descendants have been seen. | ||
| """ | ||
| seen_paths = seen.copy() | ||
|
||
| for module_path in seen: | ||
| while module_path := module_path.rpartition(".")[0]: | ||
| if module_path in seen_paths: | ||
|
||
| break | ||
| else: | ||
| seen_paths.add(module_path) | ||
| return seen_paths | ||
|
|
||
| def find_reachable_changed_modules( | ||
| self, | ||
| roots: list[BuildSource], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great docstring, thanks.