Closed
Description
What happened?
Mypy fails on main with numpy >= 2
xarray/core/npcompat.py: note: In function "isdtype":
xarray/core/npcompat.py:48: error: All conditional function variants must have identical signatures [misc]
xarray/core/npcompat.py:48: note: Original:
xarray/core/npcompat.py:48: note: def isdtype(dtype: dtype[Any] | type[Any], kind: dtype[Any] | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] | None | tuple[dtype[Any] | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] | None, ...]) -> bool
xarray/core/npcompat.py:48: note: Redefinition:
xarray/core/npcompat.py:48: note: def isdtype(dtype: Any, kind: Any) -> Any
xarray/core/dataset.py:34: error: Module "numpy" has no attribute "RankWarning" [attr-defined]
xarray/core/dataset.py:34: error: Name "RankWarning" already defined (possibly by an import) [no-redef]
xarray/tests/test_namedarray.py: note: In class "TestNamedArray":
xarray/tests/test_namedarray.py:183: error: Argument 2 to "NamedArray" has incompatible type "ndarray[Any, dtype[Any]]"; expected "_arrayfunction[Any, Never] | _arrayapi[Any, Never]" [arg-type]
xarray/tests/test_namedarray.py: note: In member "test_duck_array_class" of class "TestNamedArray":
xarray/tests/test_namedarray.py:344: error: Argument 1 to "check_duck_array_typevar" has incompatible type "ndarray[Any, dtype[signedinteger[_64Bit]]]"; expected "_arrayfunction[Any, Never] | _arrayapi[Any, Never]" [arg-type]
xarray/tests/test_namedarray.py: note: In member "test_warn_on_repeated_dimension_names" of class "TestNamedArray":
xarray/tests/test_namedarray.py:563: error: Argument 2 to "NamedArray" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "_arrayfunction[Any, Never] | _arrayapi[Any, Never]" [arg-type]
xarray/tests/test_strategies.py: note: In member "test_make_strategies_namespace" of class "TestVariablesStrategy":
xarray/tests/test_strategies.py:220: error: Module "numpy" has no attribute "array_api" [attr-defined]
xarray/tests/test_strategies.py:220: note: Error code "attr-defined" not covered by "type: ignore" comment
xarray/tests/test_plot.py: note: In member "pass_in_axis" of class "PlotTestCase":
xarray/tests/test_plot.py:162: error: Value of type "Axes | ndarray[Any, Any]" is not indexable [index]
xarray/tests/test_plot.py:163: error: Value of type "Axes | ndarray[Any, Any]" is not indexable [index]
xarray/tests/test_plot.py: note: In member "test_1d_x_y_kw" of class "TestPlot":
xarray/tests/test_plot.py:245: error: Item "Axes" of "Axes | ndarray[Any, Any]" has no attribute "flat" [union-attr]
xarray/tests/test_plot.py: note: In member "test_colorbar_kwargs" of class "Common2dMixin":
xarray/tests/test_plot.py:1569: error: "Axes" object is not iterable [misc]
xarray/tests/test_plot.py:1579: error: "Axes" object is not iterable [misc]
xarray/tests/test_plot.py: note: In function "test_plot1d_default_rcparams":
xarray/tests/test_plot.py:3375: error: Argument 1 to "assert_allclose" has incompatible type "tuple[float, float, float] | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]"; expected "_SupportsArray[dtype[numpy.bool | number[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool | number[Any]]]] | builtins.bool | int | float | complex | _NestedSequence[builtins.bool | int | float | complex] | _SupportsArray[dtype[object_]] | _NestedSequence[_SupportsArray[dtype[object_]]]" [arg-type]
xarray/tests/test_plot.py:3382: error: Argument 1 to "assert_allclose" has incompatible type "tuple[float, float, float] | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]"; expected "_SupportsArray[dtype[numpy.bool | number[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool | number[Any]]]] | builtins.bool | int | float | complex | _NestedSequence[builtins.bool | int | float | complex] | _SupportsArray[dtype[object_]] | _NestedSequence[_SupportsArray[dtype[object_]]]" [arg-type]
xarray/tests/test_plot.py:3394: error: Argument 1 to "assert_allclose" has incompatible type "tuple[float, float, float] | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]"; expected "_SupportsArray[dtype[numpy.bool | number[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool | number[Any]]]] | builtins.bool | int | float | complex | _NestedSequence[builtins.bool | int | float | complex] | _SupportsArray[dtype[object_]] | _NestedSequence[_SupportsArray[dtype[object_]]]" [arg-type]
xarray/tests/test_dataset.py:22: error: Module "numpy" has no attribute "RankWarning" [attr-defined]
xarray/tests/test_dataset.py:22: error: Name "RankWarning" already defined (possibly by an import) [no-redef]
xarray/tests/test_dataset.py:87: error: Module "numpy" has no attribute "trapz" [attr-defined]
xarray/tests/test_dataarray.py:20: error: Module "numpy" has no attribute "RankWarning" [attr-defined]
xarray/tests/test_dataarray.py:20: error: Name "RankWarning" already defined (possibly by an import) [no-redef]