You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mypy tests: Allow per distribution strictness options #1526
We should try turning on the --disallow-incomplete-defs flag from python/mypy#3744. This can catch issues where we forget type annotations for some function arguments in a stub.
I'm interested in tackling at least the stdlib side of this. Would it be better to do this as individual, more well thought-out PRs for each module, or one much larger commit that only does relatively general types
In general, smaller PRs are easier to review, but too many PRs can also become cumbersome. It might be best to have one PR per package if a package has a few changes needed and a few PRs for packages that only have few changes.
I am not sure we should enable either. I prefer to have unannotated types over using Any. I also prefer unannotated types over not having definitions or using "incomplete" markers. Enabling these warnings would raise the bar for contributions, with more complex libraries significantly.
I agree on both points! (Although it's reasonable to aspire to turning this on as a lint for stdlib one day, since we're close to completion and hopefully the stdlib isn't changing too drastically).
My point with the above was just that --disallow-untyped-defs is more in line with what I want for identifying stubs that need improvement (in the stub context, it can be a surprise that --disallow-incomplete-defs doesn't complain about definitions that are missing types entirely). If someone is using these flags to improve typeshed, it's a good thing to know.
Once we've migrated to modular typeshed, it should be easy to add support for specifying stricness options for each distribution separately in the metadata file. This wouldn't directly help with the stdlib, since stdlib would be distributed as a single entity.
Activity
gvanrossum commentedon Aug 7, 2017
Good idea.
ilinum commentedon Aug 10, 2017
I agree :)
There are a lot of errors (little over 5000).
Here is the gist with all the errors it produces.
Not sure if the effort to fix all of them so we can enable the flag is worth it.
OddBloke commentedon Aug 17, 2017
Considering only the
mypy --python-version 3.6 --strict-optional --disallow-incomplete-defsfailures, the breakdown between stdlib/third-party isso enabling this just for the stdlib initially might make addressing them more tractable?
(Full breakdown by module at https://gist.github.com/OddBloke/dbd78409dcd53bdbb6b3b8571bd29720)
CraftSpider commentedon Dec 30, 2019
I'm interested in tackling at least the stdlib side of this. Would it be better to do this as individual, more well thought-out PRs for each module, or one much larger commit that only does relatively general types
srittau commentedon Jan 3, 2020
In general, smaller PRs are easier to review, but too many PRs can also become cumbersome. It might be best to have one PR per package if a package has a few changes needed and a few PRs for packages that only have few changes.
hauntsaninja commentedon Jun 11, 2020
Note
--disallow-untyped-defsis actually stricter than--disallow-incomplete-defsand should be preferred.srittau commentedon Jun 11, 2020
I am not sure we should enable either. I prefer to have unannotated types over using
Any. I also prefer unannotated types over not having definitions or using "incomplete" markers. Enabling these warnings would raise the bar for contributions, with more complex libraries significantly.hauntsaninja commentedon Jun 11, 2020
I agree on both points! (Although it's reasonable to aspire to turning this on as a lint for stdlib one day, since we're close to completion and hopefully the stdlib isn't changing too drastically).
My point with the above was just that
--disallow-untyped-defsis more in line with what I want for identifying stubs that need improvement (in the stub context, it can be a surprise that--disallow-incomplete-defsdoesn't complain about definitions that are missing types entirely). If someone is using these flags to improve typeshed, it's a good thing to know.srittau commentedon Jun 11, 2020
Good point about stdlib.
JukkaL commentedon Jun 11, 2020
Once we've migrated to modular typeshed, it should be easy to add support for specifying stricness options for each distribution separately in the metadata file. This wouldn't directly help with the stdlib, since stdlib would be distributed as a single entity.
[-]Perhaps run mypy with --disallow-incomplete-defs[/-][+]mypy tests: Allow per distribution strictness options[/+]srittau commentedon Sep 17, 2020
I renamed this ticket to what I believe the consensus of the discussion is. Please revert if you don't agree.
Allow per distribution mypy strictness options (#5169)
srittau commentedon Jun 8, 2021
I've removed the "deferred" label as this could now be implemented.
JelleZijlstra commentedon Apr 27, 2023
Fixed in #5169