Skip to content

Commit

Permalink
Fix disappearing errors when re-running dmypy check
Browse files Browse the repository at this point in the history
This which fixes issue
python#9655 wherein some types of error
would be lost when a file was re-processed by dmypy. Regression tests
are also included.

This also fixes another error where sometimes files would not be
re-processed by dmypy if the only error in the file was either "unused
type ignore" or "ignore without code".
  • Loading branch information
meshy committed Dec 20, 2023
1 parent 3b2fc89 commit d2ad908
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -722,6 +722,8 @@ def generate_unused_ignore_errors(self, file: str) -> None:
blocker=False,
only_once=False,
allow_dups=False,
origin=(self.file, [line]),
target=self.target_module,
)
self._add_error_info(file, info)

Expand Down Expand Up @@ -774,6 +776,8 @@ def generate_ignore_without_code_errors(
blocker=False,
only_once=False,
allow_dups=False,
origin=(self.file, [line]),
target=self.target_module,
)
self._add_error_info(file, info)

Expand Down
6 changes: 6 additions & 0 deletions mypy/server/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ def restore(ids: list[str]) -> None:
state.type_check_first_pass()
state.type_check_second_pass()
state.detect_possibly_undefined_vars()
state.generate_unused_ignore_notes()
state.generate_ignore_without_code_notes()
t2 = time.time()
state.finish_passes()
t3 = time.time()
Expand Down Expand Up @@ -1028,6 +1030,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 d2ad908

Please sign in to comment.