Skip to content

Commit

Permalink
Prove possibly-undefined errors disappear
Browse files Browse the repository at this point in the history
This test fails with the error:

    AssertionError: Command 3 (dmypy check -- bar.py) did not give expected output
    --- Captured stderr call ---
    Expected:
      bar.py:4: error: Name "a" may be undefined  [possibly-undefined] (diff)
      == Return code: 1                             (diff)
    Actual:
      (empty)

This test illustrates that possibly-undefined errors currently disappear
in the same way that 'Unused "type: ignore"' errors do as described in python#9655.

Ref: python#9655
  • Loading branch information
meshy committed Feb 8, 2024
1 parent e5b660f commit 2ead5be
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,22 @@ bar.py:2: error: "type: ignore" comment without error code [ignore-without-code
[file bar.py]
from foo.empty import *
a = 1 # type: ignore

[case testPossiblyUndefinedVarsPreservedAfterRerun]
-- Regression test for https:/python/mypy/issues/9655
$ dmypy start -- --enable-error-code possibly-undefined --no-error-summary
Daemon started
$ dmypy check -- bar.py
bar.py:4: error: Name "a" may be undefined [possibly-undefined]
== Return code: 1
$ dmypy check -- bar.py
bar.py:4: error: Name "a" may be undefined [possibly-undefined]
== Return code: 1

[file foo/__init__.py]
[file foo/empty.py]
[file bar.py]
from foo.empty import *
if False:
a = 1
a

0 comments on commit 2ead5be

Please sign in to comment.