-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Improve operator.itemgetter.__call__
generic following mypy 1.11 fix
#13489
Open
Avasam
wants to merge
8
commits into
python:main
Choose a base branch
from
Avasam:Improve-operator.itemgetter-generic-following-mypy-1.11-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improve operator.itemgetter.__call__
generic following mypy 1.11 fix
#13489
Avasam
wants to merge
8
commits into
python:main
from
Avasam:Improve-operator.itemgetter-generic-following-mypy-1.11-fix
+41
−11
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
operator.itemgetter
generic following mypy 1.11 fix
…-fix' of https://github.com/Avasam/typeshed into Improve-operator.itemgetter-generic-following-mypy-1.11-fix
This comment has been minimized.
This comment has been minimized.
There seems to be a variance issue in the interaction with |
This comment has been minimized.
This comment has been minimized.
operator.itemgetter
generic following mypy 1.11 fixoperator.itemgetter.__call__
generic following mypy 1.11 fix
Diff from mypy_primer, showing the effect of this PR on open source code: sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/builders/gettext.py: note: In member "__iter__" of class "Catalog":
+ sphinx/builders/gettext.py:93:51: error: Argument "locations" to "Message" has incompatible type "list[str | int]"; expected "list[tuple[str, int]]" [arg-type]
+ sphinx/builders/gettext.py:93:68: error: Argument "uuids" to "Message" has incompatible type "list[str | int]"; expected "list[str]" [arg-type]
+ sphinx/ext/intersphinx/_load.py: note: In function "load_mappings":
+ sphinx/ext/intersphinx/_load.py:200:63: error: Argument "key" to "sorted" has incompatible type "itemgetter[tuple[int, int]]"; expected "Callable[[tuple[str, int, dict[str, dict[str, _InventoryItem]]]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
+ sphinx/ext/intersphinx/_load.py:200:63: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
rich (https://github.com/Textualize/rich)
+ rich/text.py:247: error: Argument "key" to "sort" of "list" has incompatible type "itemgetter[tuple[int, int]]"; expected "Callable[[tuple[int, bool, str | Style]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
+ rich/text.py:247: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
+ rich/columns.py:153: error: Argument 1 to "Constrain" has incompatible type "int | ConsoleRenderable | RichCast | str"; expected "ConsoleRenderable | RichCast | str" [arg-type]
+ rich/columns.py:160: error: Argument 1 has incompatible type "int | ConsoleRenderable | RichCast | str"; expected "ConsoleRenderable | RichCast | str" [arg-type]
+ rich/columns.py:170: error: Argument 1 has incompatible type "*list[int | ConsoleRenderable | RichCast | str | None]"; expected "ConsoleRenderable | RichCast | str | None" [arg-type]
+ rich/layout.py:362: error: Argument "key" to "sorted" has incompatible type "itemgetter[int]"; expected "Callable[[tuple[Layout, Region]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
+ rich/layout.py:362: note: "itemgetter[int].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
altair (https://github.com/vega/altair)
+ altair/utils/core.py:948: error: Key expression in dictionary comprehension has incompatible type "type[SchemaBase] | str"; expected type "str" [misc]
graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/type/validate.py:562: error: Argument 1 to "join" of "str" has incompatible type "map[str | GraphQLInputField]"; expected "Iterable[str]" [arg-type]
bidict (https://github.com/jab/bidict)
+ bidict/_iter.py: note: In function "inverted":
+ bidict/_iter.py:52:16: error: Argument 1 to "map" has incompatible type "itemgetter[tuple[int, int]]"; expected "Callable[[tuple[KT, VT]], tuple[VT, KT]]" [arg-type]
+ bidict/_iter.py:52:16: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
flake8 (https://github.com/pycqa/flake8)
+ src/flake8/checker.py:186: error: Argument "key" to "sort" of "list" has incompatible type "itemgetter[int]"; expected "Callable[[tuple[str, list[tuple[str, int, int, str, str | None]], dict[str, int]]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
+ src/flake8/checker.py:186: note: "itemgetter[int].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
+ src/flake8/checker.py:188: error: Argument "key" to "sort" of "list" has incompatible type "itemgetter[tuple[int, int]]"; expected "Callable[[tuple[str, int, int, str, str | None]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
+ src/flake8/checker.py:188: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
core (https://github.com/home-assistant/core)
+ homeassistant/util/language.py:194: error: Argument "key" to "sorted" has incompatible type "itemgetter[int]"; expected "Callable[[tuple[Dialect, tuple[float, float], str]], SupportsDunderLT[Any] | SupportsDunderGT[Any]]" [arg-type]
+ homeassistant/util/language.py:194: note: "itemgetter[int].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
python/mypy#14032 has been fixed in mypy 1.11.0 (I didn't go as far as to search for the exact commit).
This updates
operator.itemgetter
to include a change I originally wanted to do in #9117, removes the outdated comment, and adds a regression test.