-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
make the default positional-or-keyword in Mapping.get and MutableMapping.pop #6694
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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I can't reproduce the mypy_primer errors locally. For example, with
|
Nevermind. I think the mypy_primer run for my first broken commit finished after the one for the fixed commit. |
This comment has been minimized.
This comment has been minimized.
I don't think this is the right solution. dict is by far the most common MutableMapping, so if you can't do something on dict, you shouldn't be able to do it on MutableMapping. The errors in the mypy issue should instead be fixed with a more precise type for |
I disagree. The whole point of the mixin methods in |
I wish there was a way to say "subclasses get this, but it's not a part of the interface that the ABC represents". |
I see a couple ways to solve this:
|
Option 2 works for stubs defined inside the typeshed project, but doesn't work for your Average Joe creating his own (type-checked) custom mapping type for an application script. Joe's going to be pretty confused when he gets spurious "can't pass a keyword argument to I vote for Option 1. |
It would be just amazing to fix |
I think CPython developers would say "it has worked for a long time", and do nothing about it. https://bugs.python.org/issue29935 |
Here's another option:
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
I believe that's what this PR does. |
So it does, I should have checked. |
Fixes python/mypy#11831
I don't think it makes sense for
default
to be positional-only inMapping.get
andMutableMapping.pop
, because classes that inherit from them without overridingget
orpop
(such asos.environ
) can be called with a keyword argumentdefault="lol"
, and people actually want to do that.