-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
no keyword arguments for certain mapping methods #15085
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
base: main
Are you sure you want to change the base?
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: pyodide (https://github.com/pyodide/pyodide)
- pyodide-build/pyodide_build/xbuildenv_releases.py:220: note: def get(self, str, /, default: str) -> str
+ pyodide-build/pyodide_build/xbuildenv_releases.py:220: note: def get(self, str, str, /) -> str
- pyodide-build/pyodide_build/xbuildenv_releases.py:220: note: def [_T] get(self, str, /, default: _T) -> str | _T
+ pyodide-build/pyodide_build/xbuildenv_releases.py:220: note: def [_T] get(self, str, _T, /) -> str | _T
starlette (https://github.com/encode/starlette)
+ tests/test_datastructures.py:171: error: No overload variant of "get" of "Mapping" matches argument types "str", "None" [call-overload]
+ tests/test_datastructures.py:171: note: Possible overload variants:
+ tests/test_datastructures.py:171: note: def get(self, str, /) -> str | None
+ tests/test_datastructures.py:171: note: def get(self, str, str, /) -> str
+ tests/test_datastructures.py:171: note: def [_T] get(self, str, _T, /) -> str | _T
+ tests/test_datastructures.py:287: error: No overload variant of "get" of "Mapping" matches argument types "str", "None" [call-overload]
+ tests/test_datastructures.py:287: note: Possible overload variants:
+ tests/test_datastructures.py:287: note: def get(self, str, /) -> str | None
+ tests/test_datastructures.py:287: note: def get(self, str, str, /) -> str
+ tests/test_datastructures.py:287: note: def [_T] get(self, str, _T, /) -> str | _T
+ tests/test_datastructures.py:371: error: No overload variant of "get" of "Mapping" matches argument types "str", "None" [call-overload]
+ tests/test_datastructures.py:371: note: Possible overload variants:
+ tests/test_datastructures.py:371: note: def get(self, str, /) -> UploadFile | str | None
+ tests/test_datastructures.py:371: note: def get(self, str, UploadFile | str, /) -> UploadFile | str
+ tests/test_datastructures.py:371: note: def [_T] get(self, str, _T, /) -> UploadFile | str | _T
+ tests/test_datastructures.py:406: error: No overload variant of "get" of "Mapping" matches argument types "str", "None" [call-overload]
+ tests/test_datastructures.py:406: note: Possible overload variants:
+ tests/test_datastructures.py:406: note: def get(self, Any, /) -> Any | None
+ tests/test_datastructures.py:406: note: def get(self, Any, Any, /) -> Any
+ tests/test_datastructures.py:406: note: def [_T] get(self, Any, _T, /) -> Any | _T
discord.py (https://github.com/Rapptz/discord.py)
- ...typeshed_to_test/stdlib/typing.pyi:1040: note: "update" of "TypedDict" defined here
+ ...typeshed_to_test/stdlib/typing.pyi:1045: note: "update" of "TypedDict" defined here
steam.py (https://github.com/Gobot1234/steam.py)
- steam/ext/commands/utils.py:43: note: def get(self, str, /, default: _VT) -> _VT
+ steam/ext/commands/utils.py:43: note: def get(self, str, _VT, /) -> _VT
- steam/ext/commands/utils.py:43: note: def [_T] get(self, str, /, default: _T) -> _VT | _T
+ steam/ext/commands/utils.py:43: note: def [_T] get(self, str, _T, /) -> _VT | _T
- steam/ext/commands/utils.py:52: note: def pop(self, str, /, default: _VT) -> _VT
+ steam/ext/commands/utils.py:52: note: def pop(self, str, _VT, /) -> _VT
- steam/ext/commands/utils.py:52: note: def [_T] pop(self, str, /, default: _T) -> _VT | _T
+ steam/ext/commands/utils.py:52: note: def [_T] pop(self, str, _T, /) -> _VT | _T
operator (https://github.com/canonical/operator)
- ops/model.py:1016: note: def get(self, str, /, default: Binding) -> Binding
+ ops/model.py:1016: note: def get(self, str, Binding, /) -> Binding
- ops/model.py:1016: note: def [_T] get(self, str, /, default: _T) -> Binding | _T
+ ops/model.py:1016: note: def [_T] get(self, str, _T, /) -> Binding | _T
|
|
It looks like Starlette's unit tests are the only new issue from mypy primer. The others just look like changes to existing messages. |
srittau
left a comment
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, primer does indeed look surprisingly decent.
Can you also try to remove the # type: ignore and associated comment from dict.get()?
addresses #13432
implementing what was suggested by Jelle here #13432 (comment)
In making this change, I found that we were already lying about the positional-only information for the
keyparameter,(
keyis also positional-or-keyword in_collections_abc.py)and both the
keyanddefaultparameters ofMutableMapping.setdefaultSo this is also adding consistency.