Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Fix file reloading in dmypy with --export-types#16359
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mypy/dmypy_server.py Outdated
| changed+= [ | ||
| (bs.module,bs.path) | ||
| forbsinsources | ||
| ifbs.pathand (bs.module,bs.path)notinchanged |
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.
This is quadratic, and it could be slow if there are many files and many that are changed. Maybe construct a temporary set fromchanged and use it in thenot in changed check?
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.
Yes, good point, fixed now.
mypy/dmypy_server.py Outdated
| changed+= [ | ||
| (bs.module,bs.path) | ||
| forbsinsources | ||
| ifbs.pathand (bs.module,bs.path)notinchanged |
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.
Similar to above. Maybe move this to a helper function to avoid code duplication?
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.
Moved to a helper function.
mypy/test/testfinegrained.py Outdated
| options.use_fine_grained_cache=self.use_cacheandnotbuild_cache | ||
| options.cache_fine_grained=self.use_cache | ||
| options.local_partial_types=True | ||
| options.export_types=True |
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.
What's the purpose of this change?
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.
Starting the daemon with this option set toTrue is cleaner forinspect unit tests, I made this explicit now (so it will not slow down other fine grained tests).
| defrun_check(self,server:Server,sources:list[BuildSource])->list[str]: | ||
| response=server.check(sources,export_types=True,is_tty=False,terminal_width=-1) | ||
| response=server.check(sources,export_types=False,is_tty=False,terminal_width=-1) |
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.
Hmm why do we haveexport_types=False here, but true above?
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.
Passing it explicitly on each run will force reloading files. Putting it in options from the start is IMO cleaner.
Diff frommypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py): typechecking got 1.09x faster (138.5s -> 127.5s)(Performance measurements are based on a single noisy sample) |
JukkaL left a comment
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.
Thanks for the updates!
Fixes#15794Unfortunately, this requires to pass `--export-types` to `dmypy run` ifone wants to inspect a file that was previously kicked out of the build.
The script format changelog entries based on commit history and has somerules to filter out some changes, such as typeshed sync and changescherry-picked to the previous release branch.Example of how to run it:```$ python misc/generate_changelog.py 1.7Generating changelog for 1.7Previous release was 1.6Merge base:d7b2451NOTE: Drop "Fix crash on ParamSpec unification (for real)", since it was in previous release branchNOTE: Drop "Fix crash on ParamSpec unification", since it was in previous release branchNOTE: Drop "Fix mypyc regression with pretty", since it was in previous release branchNOTE: Drop "Clear cache when adding --new-type-inference", since it was in previous release branchNOTE: Drop "Match note error codes to import error codes", since it was in previous release branchNOTE: Drop "Make PEP 695 constructs give a reasonable error message", since it was in previous release branchNOTE: Drop "Fix ParamSpec inference for callback protocols", since it was in previous release branchNOTE: Drop "Try upgrading tox", since it was in previous release branchNOTE: Drop "Optimize Unpack for failures", since it was in previous release branch * Fix crash on unpack call special-casing (Ivan Levkivskyi, PR [16381](#16381)) * Fix file reloading in dmypy with --export-types (Ivan Levkivskyi, PR [16359](#16359)) * Fix daemon crash caused by deleted submodule (Jukka Lehtosalo, PR [16370](#16370))...```
Fixes#15794
Unfortunately, this requires to pass
--export-typestodmypy runif one wants to inspect a file that was previously kicked out of the build.