-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix dmypy run on Windows #15429
Fix dmypy run on Windows #15429
Conversation
This comment has been minimized.
This comment has been minimized.
OK, great, thanks for confirming! |
I'd like if someone else can confirm too, since my usage is going through a 3rd party extension. Just to make sure it wasn't a fluke. |
I can also repro the issue on a Windows machine, and can also confirm that this patch appears to fix it! (I'm running dmypy from the command line.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it and seems to work.
before:
PS C:\src\mypy-play> python -m mypy.dmypy run .\test.py
Restarting: configuration changed
Daemon stopped
Daemon started
Response: {'restart': 'configuration changed', 'stdout': '', 'stderr': '', 'platform': 'win32', 'python_version': '3_11', 'roundtrip_time': 0.488344669342041}
after applying PR:
PS C:\src\mypy-play> python -m mypy.dmypy run .\test.py
Restarting: configuration changed
Daemon stopped
Daemon started
←[1m←[92mSuccess: no issues found in 42 source files←[0m
PS C:\src\mypy-play> python -m mypy.dmypy run .\test.py
←[1m←[92mSuccess: no issues found in 1 source file←[0m
PS C:\src\mypy-play>
mypy/dmypy_server.py
Outdated
options: Options, | ||
status_file: str, | ||
timeout: int | None = None, | ||
options_snapshot: dict[str, object] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accepted it since it work, but thinking out loud, it feels like it shouldn't be necessary to pass both options and options_snapshot. One or the other should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but then we will need something like "stable compare", which will be a tiny bit slower (this is btw the original way I did it). OTOH, then motivation is much more obvious, so let's go that way indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@svalentin Could you please test again just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Still works:
PS C:\src\mypy-play> python -m mypy.dmypy run .\test.py
Success: no issues found in 1 source file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, I think this is a much more elegant fix
@hauntsaninja It looks like |
It looks like the issue is that mypy-primer can't install winsdk (maybe it's a Windows-only package?), which is specified as one of the packages needed for typechecking Autosplit. If that is indeed the issue, hauntsaninja/mypy_primer#89 should fix it. winsdk was only added to the mypy-primer recipe for Autosplit yesterday, in hauntsaninja/mypy_primer#87 |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #10709
Two changes here:
ErrorCode
because they may appear in options snapshotsOptions.apply_changes()
does some unrelated things with flagsBoth are only relevant on Windows where options may roundtrip as:
options -> snapshot -> pickle -> base64 -> unpickle -> apply_changes
.