-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use --additional-flags='check-untyped-defs'
when running mypy_primer
#9433
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
Conversation
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Definitely worth experimenting with! I'm not sure it'll do too much for us over what stubtest can do, since most of the things in untyped functions will be Any. |
It looks like this might come at the cost of a performance regression (which is understandable, since we're asking mypy to check a significantly larger quantity of code in some cases) — it took 15 minutes for the four primer jobs to complete on #9442, whereas we usually got the primer comment in 8-9 minutes prior to this PR being merged. |
Three options I can think of:
|
Another 15-minute primer run: https://github.com/python/typeshed/actions/runs/3824023959 |
That's definitely a significant increase in time spent.
|
It's easy to point It's also worth noting that, while there have been a lot of optimisations recently merged, the single most significant potential optimisation is still in the pipeline: python/mypy#14150.
I briefly glanced at the source code, and that indeed seems to be the case
(I'm not a |
I haven't tried, but I feel it should be possible to do that already with the regex route. |
Ah, serves me right for not reading the docs closely enough :) In that case, it would be interesting to see if we can get back the speed increase just by skipping Though as @hauntsaninja says, it still remains to be seen whether using |
I think manticore has been fairly helpful in typeshed CI: https://github.com/python/typeshed/pulls?q=is%3Apr+manticore (PR count isn't super trustworthy, but it's indicative). There's a significant chance that having manticore in CI will be more helpful than having That said, I took a close look, and should be easy to fix the perf issue that manticore is running into. For more forward looking things, I'm disinclined to pursue more complicated sharding strategies than the one I recently implemented. I'm happy to pursue better project selection options for mypy_primer if it makes some typeshed use case happy, although I'm hoping not to grow mypy_primer's project list enough that this becomes necessary. |
I wonder if it's feasible to limit mypy-primer runs for third-party stub changes to only projects that use the library, either directly or indirectly. Perhaps we can somehow get the transitive dependencies of each mypy-primer project using setup.py/PyPI/whatever, then check if the stub package we're changing is in that set. If not, we can skip type-checking the project in mypy-primer. |
I like Jelle's idea in theory. It should be fully doable within typeshed too. And would reduce typeshed's already long mypy_primer runs. If its feasible, it'd be useful even outside this PR. I just don't know how reliable "get the transitive dependencies of each mypy-primer project using setup.py/PyPI/whatever" is. And the added overhead of doing that (even with some sort of caching). |
Yeah, this has been discussed before. It's a good idea, but there are a number of finicky details to consider, and it wouldn't help PRs targeting stdlib (which last time I checked was still a majority of typeshed PRs). Detecting dependencies also has the advantage that we could spit out a relevant project count, which may help calibrate reviewers for how meaningful a "no changes found" is. |
Then maybe this idea deserves its own issue and discussion thread. |
Given that mypy 1.0 may still be a few weeks away from being released, here's a PR to revert in the meantime: We can take another look when mypy 1.0 comes out and see how the performance compares. |
This was suggested by @Avasam in hauntsaninja/mypy_primer#64, and by @Akuli in hauntsaninja/mypy_primer#66. It could conceivably yield much more interesting diffs for some PRs. For example,
comtypes
makes heavy use ofpywin32
, so it shows up a lot in primer diffs for PRs affecting ourpywin32
stubs. But the diffs usually aren't very interesting, because the vast majority ofcomtypes
's functions are untyped, so mypy just ignores them.I think this is worth experimenting with, and if it doesn't work for whatever reason, we can always revert it.