Repository navigation
mypy tests: Allow per distribution strictness options #1526
Description
Activity
Good idea.
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.
Considering only the
mypy --python-version 3.6 --strict-optional --disallow-incomplete-defsfailures, the breakdown between stdlib/third-party is$ cut -d/ -f1 < out | sort | uniq -c 77 stdlib 895 third_party
so enabling this just for the stdlib initially might make addressing them more tractable?
(Full breakdown by module at https://gist.github.com/OddBloke/dbd78409dcd53bdbb6b3b8571bd29720)
- addedproject: policyOrganization of the typeshed projectOrganization of the typeshed project
on Oct 28, 2018 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.
Note
--disallow-untyped-defsis actually stricter than--disallow-incomplete-defsand should be preferred.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.Reacted by Shantanu and Alex WaygoodI 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.Good point about stdlib.
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.
Reacted by Sebastian Rittau- addedstatus: deferredIssue or PR deferred until some precondition is fixedIssue or PR deferred until some precondition is fixed
on Sep 17, 2020 - changed the title
[-]Perhaps run mypy with --disallow-incomplete-defs[/-][+]mypy tests: Allow per distribution strictness options[/+]on Sep 17, 2020 I renamed this ticket to what I believe the consensus of the discussion is. Please revert if you don't agree.
- added a commit that references this issue
on Apr 8, 2021 - removedstatus: deferredIssue or PR deferred until some precondition is fixedIssue or PR deferred until some precondition is fixed
on Jun 8, 2021 I've removed the "deferred" label as this could now be implemented.
- addedproject: infrastructuretypeshed build, test, documentation, or distribution relatedtypeshed build, test, documentation, or distribution relatedand removedproject: policyOrganization of the typeshed projectOrganization of the typeshed project
on Aug 23, 2021 Fixed in #5169
We should try turning on the
--disallow-incomplete-defsflag from python/mypy#3744. This can catch issues where we forget type annotations for some function arguments in a stub.