| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I can't reproduce the mypy_primer errors locally. For example, with black's literals.py, I get: (env) akuli@akuli-desktop:~/typeshed$ mv .mypy_cache/ /tmp/ (env) akuli@akuli-desktop:~/typeshed$ mypy --custom-typeshed-dir . literals.py Success: no issues found in 1 source file (env) akuli@akuli-desktop:~/typeshed$ mypy --version mypy 0.930 |
Sorry, something went wrong.
|
Nevermind. I think the mypy_primer run for my first broken commit finished after the one for the fixed commit. |
Sorry, something went wrong.
|
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 os.environ. |
Sorry, something went wrong.
I disagree. The whole point of the mixin methods in collections.abc.(Mutable)Mapping is that you don't have to override them if you're creating a custom mapping type; you define the abstract methods, and then the mixin methods come "for free". But if we have these parameters as positional-only in (Mutable)Mapping, we're saying anybody using these classes to create a custom mapping type has to manually override these mixin methods if they want the type-checker to be happy with them passing keyword arguments. |
Sorry, something went wrong.
|
I wish there was a way to say "subclasses get this, but it's not a part of the interface that the ABC represents". |
Sorry, something went wrong.
|
I see a couple ways to solve this:
|
Sorry, something went wrong.
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 .get()" errors, despite these methods being pos-or-keyword in the CPython source code. I vote for Option 1. |
Sorry, something went wrong.
|
It would be just amazing to fix dict (and other) signatures in CPython 😒 |
Sorry, something went wrong.
|
I think CPython developers would say "it has worked for a long time", and do nothing about it. https://bugs.python.org/issue29935 |
Sorry, something went wrong.
|
Here's another option:
|
Sorry, something went wrong.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
|
I believe that's what this PR does. |
Sorry, something went wrong.
|
So it does, I should have checked. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes python/mypy#11831
I don't think it makes sense for default to be positional-only in Mapping.get and MutableMapping.pop, because classes that inherit from them without overriding get or pop (such as os.environ) can be called with a keyword argument default="lol", and people actually want to do that.