-
-
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
stubtest: error for pos-only differences for dunder methods, too #12184
Conversation
I think that's the longest rationale I've ever written for deleting a single line of code. |
cc. @hauntsaninja |
Thanks for reminding me to merge that PR, and thanks for all the fixes! I don't think this needs a new config option; we should just remove the special case. But I'll let @hauntsaninja weigh in. |
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 making all of these fixes, looks good!
If you're interested in pulling on this, there are a couple other places where we special case dunders (grep for is_dunder
and SPECIAL_DUNDERS
). In particular, I think the SPECIAL_DUNDERS
check in verify_typeinfo
could be productively removed.
On the design question: I don't think we need a flag to turn these specifically back off. stubtest already has a --ignore-positional-only
for people who don't find this class of error useful. More generally, stubtest operates in a somewhat murky area and so is forced to have several opinions. If we get feedback that those opinions are bad, we should change, but I don't want to accrete complexity preemptively.
I already have a second patch waiting in the wings, I just figured I'd do the smaller one first ;) |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
What's the easiest way to run the tests in |
|
Thanks! I'm still relatively new to pytest 🤦♂️ |
mypy's test setup is also very custom! |
…thon#12184)" This reverts commit 777885f.
This reverts commit 777885f. To help with python/typeshed#7441 and reduce risk of stubtest issues interfering with a mypy release. The extra type correctness here is really minimal. Co-authored-by: hauntsaninja <>
It was decided we cared about this in python/mypy#12184
Description
stubtest currently does not complain if a dunder method in a stub file has an argument that should be positional-only, but is marked in the stub as being positional-or-keyword. This PR proposes to remove this exception.
Removing the exception will increase our confidence in the accuracy of typeshed stubs with regard to positional-only arguments.
The rationale for the exception was the very large number of complaints stubtest had when checking typeshed. However, I have been using this patch over the past few days to file a series of PRs to typeshed, in order to minimise the impact of this PR:
types
typeshed#7220sys
typeshed#7221ctypes
typeshed#7223_tkinter
typeshed#7224xml
typeshed#7225threading.local
typeshed#7227As a result, this PR means that only the following new hits are generated when running stubtest on typeshed:
All of these remaining hits will be resolved by one final outstanding PR to typeshed (EDIT: now merged -- thanks @JelleZijlstra!):
sqlite3
typeshed#7222.The full command I ran to obtain this diff was the following (with
../typeshed
being the path to my clone of typeshed):I ran this command without this patch applied, and with this patch applied. The command was run on Windows, with Python 3.10.
Test Plan
The existing exception does not appear to be tested; this PR does not appear to break any existing tests. I'm happy to add some tests for this change, if they'd be appreciated, however :)
Design question
We could add a new command-line option to turn this exception back on. Thoughts on that?