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

dmypy run won't run, prints "Restarting: configuration changed" when ignore_missing_imports = True is configured #10709

Closed
tadeu opened this issue Jun 24, 2021 · 11 comments · Fixed by #15429
Labels
bug mypy got something wrong topic-daemon dmypy

Comments

@tadeu
Copy link
Contributor

tadeu commented Jun 24, 2021

Bug Report

Since at least v0.902, executing dmypy run in a project that has ignore_missing_imports = True in mypy.ini is not working anymore.

To Reproduce

(Write your steps here:)

  1. Create src/something.py with some code in it, and create mypy.ini with:
[mypy]
files = src
ignore_missing_imports = True
  1. Run dmypy run

Expected Behavior

dmypy run should execute correctly, outputting something like:

Daemon started
src\something.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int")
Found 1 error in 1 file (checked 26 source files)

Actual Behavior

dmypy run keeps showing:

Restarting: configuration changed
Daemon stopped
Daemon started
Response: {'restart': 'configuration changed', 'platform': 'win32', 'python_version': '3_9', 'roundtrip_time': 0.5543885231018066}

even when trying to run it again.

Your Environment

  • Mypy version used: v0.902, v0.910 and 0.920+dev.379622de482ec16dd1676ad6d183dcfca5203194
  • Mypy command-line flags: dmypy run
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
files = src
ignore_missing_imports = True
  • Python version used: 3.9.5
  • Operating system and version: Windows 10 21H1
@tadeu tadeu added the bug mypy got something wrong label Jun 24, 2021
@tadeu
Copy link
Contributor Author

tadeu commented Jun 24, 2021

I guess it has something to do with these changes: 4642a31#diff-eb09ce67c2059bc9c117d4175e0bd34b1d75bbe8a91c3b9f69a8d14a9c8bc09fR330

@tadeu
Copy link
Contributor Author

tadeu commented Jun 24, 2021

A workaround, for now, is to use this undocumented option together:

ignore_missing_imports_per_module = True

as in:

[mypy]
files = src
ignore_missing_imports = True
ignore_missing_imports_per_module = True

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 24, 2021

I can't reproduce this issue, at least on macOS and Python 3.9.0. Can you provide an example file under src/ that triggers the issue? Also can you try this out in a fresh virtualenv?

@tadeu
Copy link
Contributor Author

tadeu commented Jun 24, 2021

I was trying it in a fresh venv, the source was just a dummy file something.py with

something: int = "something"

Perhaps it's only in Windows? There are some if sys.platform == 'win32': in dmypy :)

@emmatyping
Copy link
Collaborator

emmatyping commented Jun 25, 2021

I can indeed repro this on Windows with the latest mypy in a fresh venv... strange

It also appears the .dmypy.json file sticks around afterwards as well...

@adam-grant-hendry
Copy link

It's on my machine on Windows too.

@adam-grant-hendry
Copy link

Interestingly, the "temporary" fix does not work if

enable_error_code = ignore-without-code

is also set.

@MartinBernstorff
Copy link

I'm getting this same error on windows. The same project works fine on MacOS :-)

@Avasam
Copy link
Contributor

Avasam commented Jun 13, 2023

It appears to also be the case with --follow-imports=silent

Edit: nvm [info] dmypy: follow-imports=silent not supported

@ilevkivskyi
Copy link
Member

OK, I think I figured it out, Options() object may not equal to itself after a pickle roundtrip (which is what we use to communicate with the daemon on Windows), because of two reasons:

  • There is a nontrivial bit of code applied to ignore_missing_imports after upnickling that also sets ignore_missing_imports_per_module
  • ErrorCode class doesn't have an __eq__().

The tricky part is that I don't have a Windows machine, but I guess I can tweak Linux code to use Windows logic (and in CI we have Windows).

@ilevkivskyi
Copy link
Member

Can someone who has a Windows machine please check if #15429 fixes their issue?

ilevkivskyi added a commit that referenced this issue Jun 14, 2023
Fixes #10709 

Two changes here:
* Add equality methods to `ErrorCode` because they may appear in options
snapshots
* Use stable comparison for option snapshots, since
`Options.apply_changes()` does some unrelated things with flags

Both are only relevant on Windows where options may roundtrip as:
`options -> snapshot -> pickle -> base64 -> unpickle -> apply_changes`.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants