Skip to content

Commit

Permalink
Ensure errors persist after dmypy update
Browse files Browse the repository at this point in the history
Before this change, if a module was removed with `update` in the
`FineGrainedBuildManager`, then some errors would not re-appear.

This change ensures that three types of error are maintained when
running `reprocess_nodes`:

- possibly undefined vars
- unused ignores
- ignores without codes

By adding targets to ErrorInfos, this also fixes an issue where unused
ignore and ignores without codes errors didn't get re-processed when
they were the only issue in the file.

Fixes python#9655
  • Loading branch information
meshy committed Mar 13, 2023
1 parent 6094fc4 commit fa65250
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ def generate_unused_ignore_errors(self, file: str) -> None:
False,
False,
False,
origin=(self.file, None),
target=self.target_module,
)
self._add_error_info(file, info)

Expand Down Expand Up @@ -720,6 +722,8 @@ def generate_ignore_without_code_errors(
False,
False,
False,
origin=(self.file, None),
target=self.target_module,
)
self._add_error_info(file, info)

Expand Down
4 changes: 4 additions & 0 deletions mypy/server/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,10 @@ def key(node: FineGrainedDeferredNode) -> int:
if graph[module_id].type_checker().check_second_pass():
more = True

graph[module_id].detect_possibly_undefined_vars()
graph[module_id].generate_unused_ignore_notes()
graph[module_id].generate_ignore_without_code_notes()

if manager.options.export_types:
manager.all_types.update(graph[module_id].type_map())

Expand Down

0 comments on commit fa65250

Please sign in to comment.