Skip to content
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

Daemonized mypy ignores errors on files that previously passed (cache bug) #18131

Open
emernic opened this issue Nov 9, 2024 · 3 comments
Open
Labels
bug mypy got something wrong topic-daemon dmypy topic-incremental

Comments

@emernic
Copy link

emernic commented Nov 9, 2024

Bug Report
dmypy is failing to notice type errors when they are introduced into a file that has already passed type checking. I'm observing this even on extremely minimal examples. It seems like once a file passes checks once it is never checked again by dmypy.

Specifically, this seems to happen when dmypy is given a package. Explicitly passing the filename still gives the expected errors.

To Reproduce
Create a package called test_package containing an empty __init__.py and a file called test.py with the contents:

a: int = 1
b: int = "foo"

Run the following commands:

$ dmypy run -- -p test_package
test_package/test.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 2 source files)

# Comment out line 2 of test.py

$ dmypy run -- -p test_package
Success: no issues found in 2 source files

# Uncomment line 2 of test.py

$ dmypy run -- -p test_package
Success: no issues found in 2 source files

Expected Behavior
The last command should raise the "Incompatible types in assignment" error.

Actual Behavior
No issues are found, despite the contents of test.py being exactly the same as the first run.

Your Environment

  • Mypy version used: 1.13.0
  • Mypy command-line flags: (see examples above)
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11.6
@emernic emernic added the bug mypy got something wrong label Nov 9, 2024
@brianschubert
Copy link
Collaborator

Thanks for the report!

I'm having some trouble reproducing this locally. After uncommenting the second line in test_package/test.py and re-running dmypy run -- -p test_package, I'm getting the original error as expected.

Can you think of any other details that might help narrow this down?

@emernic
Copy link
Author

emernic commented Nov 9, 2024

I just tried and failed reproduce it on another machine running the same Python and mypy versions, so it's definitely environment-specific. There's a lot going on in the environment I'm seeing the error in (it's a GitHub Codespace with git, pre-commit, poetry, and a lot of other stuff) so I might not have time to isolate the determining factor for quite a while. Feel free to close.

@hauntsaninja
Copy link
Collaborator

Could be the same issue as #15677 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-daemon dmypy topic-incremental
Projects
None yet
Development

No branches or pull requests

3 participants