typeshed
typeshed copied to clipboard
Improve `operator.itemgetter.__call__` generic following mypy 1.11 fix
https://github.com/python/mypy/issues/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 https://github.com/python/typeshed/pull/9117, removes the outdated comment, and adds a regression test.
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]"
There seems to be a variance issue in the interaction with map and/or groupby. But I honestly can't quite figure it out.
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]"
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]"
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:950: 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]"
I'm also not sure why this doesn't work. Still I think for now it's best to postpone (i.e. close) this PR, until this works better.
If you close this, please make it an issue. The behaviour here feels unexpected and seems worth investigating.
Diff from mypy_primer, showing the effect of this PR on open source code:
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]"
altair (https://github.com/vega/altair)
+ altair/utils/core.py:950: error: Key expression in dictionary comprehension has incompatible type "type[SchemaBase] | str"; expected type "str" [misc]
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]"
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]
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]"
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]"
flake8 (https://github.com/pycqa/flake8)
+ src/flake8/checker.py:184: 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:184: note: "itemgetter[int].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
+ src/flake8/checker.py:186: 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:186: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
Diff from mypy_primer, showing the effect of this PR on open source code:
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]"
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/builders/gettext.py: note: In member "__iter__" of class "Catalog":
+ sphinx/builders/gettext.py:92:51: error: Argument "locations" to "Message" has incompatible type "list[str | int]"; expected "list[tuple[str, int]]" [arg-type]
+ sphinx/builders/gettext.py:92: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:203: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:203:63: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
altair (https://github.com/vega/altair)
+ altair/utils/core.py:950: error: Key expression in dictionary comprehension has incompatible type "type[SchemaBase] | str"; expected type "str" [misc]
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]"
flake8 (https://github.com/pycqa/flake8)
+ src/flake8/checker.py:184: 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:184: note: "itemgetter[int].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
+ src/flake8/checker.py:186: 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:186: 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]"
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]
Diff from mypy_primer, showing the effect of this PR on open source code:
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]"
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]
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]"
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/builders/gettext.py: note: In member "__iter__" of class "Catalog":
+ sphinx/builders/gettext.py:92:51: error: Argument "locations" to "Message" has incompatible type "list[str | int]"; expected "list[tuple[str, int]]" [arg-type]
+ sphinx/builders/gettext.py:92: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:203: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:203:63: 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]"
altair (https://github.com/vega/altair)
+ altair/utils/core.py:950: error: Key expression in dictionary comprehension has incompatible type "type[SchemaBase] | str"; expected type "str" [misc]
flake8 (https://github.com/pycqa/flake8)
+ src/flake8/checker.py:184: 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:184: note: "itemgetter[int].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
+ src/flake8/checker.py:186: 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:186: note: "itemgetter[tuple[int, int]].__call__" has type "Callable[[Arg(SupportsGetItem[Any, _T], 'obj')], _T]"
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉