Update list.{count, index, remove} to accept object type#15472
Update list.{count, index, remove} to accept object type#15472randolf-scholz wants to merge 2 commits intopython:mainfrom
object type#15472Conversation
This comment has been minimized.
This comment has been minimized.
|
Hm, not exactly sure what's going on with def count(self, value: Any, /) -> int:
"""Return the number of occurrences of `value`."""
raise NotImplementedError
def index(self, value: Any, /) -> int:
"""Return the first index of `value`."""
raise NotImplementedErrorthen after we make EDIT: I am starting to think that this may be related to mypy interal solver semantics. we removed some constrains, so now it may find solutions for the |
|
Diff from mypy_primer, showing the effect of this PR on open source code: optuna (https://github.com/optuna/optuna)?target=https://github.com
+ tests/visualization_tests/test_rank.py:699: error: Need type annotation for "x2" [var-annotated]
pwndbg (https://github.com/pwndbg/pwndbg)?target=https://github.com
+ pwndbg/aglib/elf.py:448: error: Unused "type: ignore" comment [unused-ignore]
colour (https://github.com/colour-science/colour)?target=https://github.com
- colour/utilities/network.py:1772: error: Argument 1 to "remove" of "list" has incompatible type "PortNode"; expected "Self" [arg-type]
- colour/notation/munsell.py:2573: error: Argument 1 to "index" of "list" has incompatible type "tuple[Any, Any, Any]"; expected "tuple[float, float]" [arg-type]
- colour/notation/munsell.py:2578: error: Argument 1 to "index" of "list" has incompatible type "tuple[Any, Any, Any]"; expected "tuple[float, float]" [arg-type]
- colour/notation/munsell.py:2585: error: Argument 1 to "index" of "list" has incompatible type "tuple[Any, Any, Any]"; expected "tuple[float, float]" [arg-type]
- colour/notation/munsell.py:2590: error: Argument 1 to "index" of "list" has incompatible type "tuple[Any, Any, Any]"; expected "tuple[float, float]" [arg-type]
- colour/plotting/models.py:1457: error: Incompatible types in assignment (expression has type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]", variable has type "ndarray[tuple[Any, ...], dtype[Any]]") [assignment]
+ colour/plotting/models.py:1457: error: Incompatible types in assignment (expression has type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]", variable has type "ndarray[Any, Any]") [assignment]
xarray (https://github.com/pydata/xarray)?target=https://github.com
+ xarray/tests/test_concat.py: note: In function "create_typed_datasets":
+ xarray/tests/test_concat.py:112: error: Argument 1 to "reshape" has incompatible type "list[Timedelta]"; expected "_SupportsArray[dtype[Never]] | _NestedSequence[_SupportsArray[dtype[Never]]]" [arg-type]
+ xarray/tests/test_concat.py: note: At top level:
+ xarray/tests/test_backends.py:2062: error: Need type annotation for "expected" [var-annotated]
dedupe (https://github.com/dedupeio/dedupe)?target=https://github.com
+ dedupe/labeler.py:410: error: List item 1 has incompatible type "Iterable[Literal[0, 1]]"; expected "_SupportsArray[dtype[signedinteger[_64Bit]]] | _NestedSequence[_SupportsArray[dtype[signedinteger[_64Bit]]]]" [list-item]
pandas (https://github.com/pandas-dev/pandas)?target=https://github.com
+ pandas/core/dtypes/dtypes.py:974: error: Need type annotation for "np_dtype" [var-annotated]
+ pandas/core/dtypes/dtypes.py:975: error: Argument 1 has incompatible type "list[dtype[Any] | ExtensionDtype]"; expected "_SupportsArray[dtype[Never]] | _NestedSequence[_SupportsArray[dtype[Never]]]" [arg-type]
+ pandas/core/arrays/sparse/array.py:1452: error: Need type annotation for "sparse_values" [var-annotated]
+ pandas/plotting/_matplotlib/misc.py:170: error: Need type annotation for "s" [var-annotated]
+ pandas/plotting/_matplotlib/core.py:1205: error: List item 0 has incompatible type "Number | number[Any, int | float | complex]"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]" [list-item]
jax (https://github.com/google/jax)?target=https://github.com
+ jax/experimental/key_reuse/_core.py:395: error: Unused "type: ignore" comment [unused-ignore]
scipy-stubs (https://github.com/scipy/scipy-stubs)?target=https://github.com
+ tests/special/test_ufuncs.pyi:69: error: Argument 1 to "__call__" of "_UFunc11f" has incompatible type "list[complex]"; expected "CanArrayND[floating[_16Bit] | integer[Any] | numpy.bool[builtins.bool], tuple[Any, ...]] | SequenceND[CanArrayND[floating[_16Bit] | integer[Any] | numpy.bool[builtins.bool], tuple[Any, ...]]] | SequenceND[JustFloat | int]" [arg-type]
+ tests/special/test_ufuncs.pyi:69: note: "list" is missing following "CanArrayND" protocol member:
+ tests/special/test_ufuncs.pyi:69: note: __array__
|
Partially fixes #15271