Skip to content

Commit ae4b20d

Browse files
meshyAlexWaygood
andcommitted
Ensure errors persist after file change
Before this change, when a module was changed, some errors would not re-appear. This change ensures that unused-ignore and ignore-without-code errors are maintained when a module is re-analyzed after it changes. We use Python to print a newline to the end of the file, which doesn't run afoul of issues with newlines on Windows, unlike `echo`. Co-authored-by: AlexWaygood <[email protected]>
1 parent 5057f82 commit ae4b20d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mypy/server/update.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ def restore(ids: list[str]) -> None:
667667
state.type_check_first_pass()
668668
state.type_check_second_pass()
669669
state.detect_possibly_undefined_vars()
670+
state.generate_unused_ignore_notes()
671+
state.generate_ignore_without_code_notes()
670672
t2 = time.time()
671673
state.finish_passes()
672674
t3 = time.time()

test-data/unit/daemon.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ Daemon started
564564
$ dmypy check -- bar.py
565565
bar.py:2: error: Unused "type: ignore" comment
566566
== Return code: 1
567-
$ echo '' >> bar.py
567+
$ {python} -c "print('\n')" >> bar.py
568568
$ dmypy check -- bar.py
569569
bar.py:2: error: Unused "type: ignore" comment
570570
== Return code: 1
@@ -582,7 +582,7 @@ Daemon started
582582
$ dmypy check -- bar.py
583583
bar.py:2: error: "type: ignore" comment without error code [ignore-without-code]
584584
== Return code: 1
585-
$ echo '' >> bar.py
585+
$ {python} -c "print('\n')" >> bar.py
586586
$ dmypy check -- bar.py
587587
bar.py:2: error: "type: ignore" comment without error code [ignore-without-code]
588588
== Return code: 1

0 commit comments

Comments
 (0)