CI breaking
Closed this issue · 5 comments
Describe the bug
CI is now breaking likely due to some changes in mypy version.
tests/extension/decimal/array.py:83: error: No overload variant of "__setitem__" of "ndarray" matches argument types "int", "Decimal" [call-overload]
tests/extension/decimal/array.py:83: note: Possible overload variants:
tests/extension/decimal/array.py:83: note: def __setitem__(self, str | list[str], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], /) -> None
tests/extension/decimal/array.py:83: note: def __setitem__(self, SupportsIndex | slice | EllipsisType | _SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]]] | builtins.bool | int | _NestedSequence[builtins.bool | int] | tuple[SupportsIndex | slice | EllipsisType | _SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]]] | builtins.bool | int | _NestedSequence[builtins.bool | int] | None, ...] | None, Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], /) -> None
tests/extension/decimal/array.py:86: error: No overload variant of "__setitem__" of "ndarray" matches argument types "int", "Decimal" [call-overload]
tests/extension/decimal/array.py:86: note: Possible overload variants:
tests/extension/decimal/array.py:86: note: def __setitem__(self, str | list[str], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], /) -> None
tests/extension/decimal/array.py:86: note: def __setitem__(self, SupportsIndex | slice | EllipsisType | _SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]]] | builtins.bool | int | _NestedSequence[builtins.bool | int] | tuple[SupportsIndex | slice | EllipsisType | _SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]] | dtype[integer[Any]]]] | builtins.bool | int | _NestedSequence[builtins.bool | int] | None, ...] | None, Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], /) -> None
tests/test_scalars.py:582: error: Expression is of type "timedelta", not "Timedelta" [assert-type]
tests/test_scalars.py:641: error: Expression is of type "timedelta", not "Timedelta" [assert-type]
Found 4 errors in 2 files (checked [22](https://github.com/pandas-dev/pandas-stubs/actions/runs/12307927720/job/34352450935?pr=1070#step:4:23)8 source files)
To Reproduce
Run poetry run poe test_all.
Please complete the following information:
- OS: [e.g. Windows, Linux, MacOS] All
- OS Version [e.g. 22] latest
- python version 3.10 to 3.12
- version of type checker
- version of installed
pandas-stubs
Additional context
Add any other context about the problem here.
Seems to be linked for the latter two issues with the following changes in numpy:
numpy/numpy@e98a940
Seems like the type is inferred with the numpy code first and whatever pandas stubs does is ignored (I checked on my side in at runtime the type is a pd.Timedelta and not a timedelta like mypy seems to suggest.
It is the upgrade from numpy 2.1.3 to numpy 2.2.0
One temporary solution is to change pyproject.toml to have a constraint so that it picks numpy < 2.2.0
It's related to microsoft/pyright#4088 . See comments elsewhere in test_scalars.py.
pyright is reporting the same 2 errors with the changes made to numpy. I think we should put a similar comment in there with respect to those tests with appropriate ignore statements
Also, the first 2 errors in tests/extension/decimal/array.py are related to a numpy 2.2.0 bug - issue is reported here: numpy/numpy#27964 which is fixed by numpy/numpy#27990
So I think pinning numpy to a version less than 2.2.0 is the way to go for now until a new version is released.