Skip to content

Conversation

@charris
Copy link
Member

@charris charris commented Oct 21, 2025

No description provided.

@charris charris added 08 - Backport Used to tag backport PRs 41 - Static typing labels Oct 21, 2025
@jorenham
Copy link
Member

I don't think we should backport 600294e (#30041)

@github-actions

This comment has been minimized.

@charris
Copy link
Member Author

charris commented Oct 21, 2025

I am afraid your pushes got lost (again).

@jorenham
Copy link
Member

The mypy failures in numpy/typing/tests/data/reveal/numerictypes.pyi can be resolved by including that entire .pyi here.

But the mypy failure in numpy/typing/tests/data/fail/scalars.pyi can be resolved by removing the __new__ method from class flexible here:

numpy/numpy/__init__.pyi

Lines 5453 to 5455 in 49e4e89

class flexible(_RealMixin, generic[_FlexibleItemT_co], Generic[_FlexibleItemT_co]):
@abstractmethod
def __new__(cls) -> Self: ...

so that it's something like this:

class flexible(_RealMixin, generic[_FlexibleItemT_co], Generic[_FlexibleItemT_co]): ...  # type: ignore[misc]

@jorenham
Copy link
Member

I am afraid your pushes got lost (again).

I did not push anything though

@github-actions

This comment has been minimized.

@jorenham
Copy link
Member

The pyspark primer diff originates from this line:

tmp_val = arg[np._NoValue]  # type: ignore[attr-defined]

where arg is a dict | pd.Series instance.

So the previous attr-defined error now turned into a call-overload error; that's all.

- Update numpy/__init__.pyi
- Update numpy/_core/numerictypes.pyi
@github-actions

This comment has been minimized.

@jorenham
Copy link
Member

The mypy failures in numpy/typing/tests/data/reveal/numerictypes.pyi can be resolved by including that entire .pyi here.

With this the last two failures should be taken care of

@github-actions

This comment has been minimized.

@github-actions
Copy link

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

xarray (https://github.com/pydata/xarray)
+ xarray/compat/npcompat.py: note: In function "isdtype":
+ xarray/compat/npcompat.py:54: error: All conditional function variants must have identical signatures  [misc]
+ xarray/compat/npcompat.py:54: note: Original:
+ xarray/compat/npcompat.py:54: note:     def isdtype(dtype: dtype[Any] | type, kind: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None | tuple[type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None, ...]) -> bool
+ xarray/compat/npcompat.py:54: note: Redefinition:
+ xarray/compat/npcompat.py:54: note:     def isdtype(dtype: dtype[Any] | type[Any], kind: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None | tuple[type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None, ...]) -> bool
- xarray/namedarray/dtypes.py: note: In function "maybe_promote":
- xarray/namedarray/dtypes.py:86: error: Too many arguments for "generic"  [call-arg]

spark (https://github.com/apache/spark)
+ python/pyspark/pandas/series.py:1210: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/pandas/series.py:1210: error: No overload variant of "__getitem__" of "Series" matches argument type "_NoValueType"  [call-overload]
+ python/pyspark/pandas/series.py:1210: note: Error code "call-overload" not covered by "type: ignore" comment
+ python/pyspark/pandas/series.py:1210: note: Possible overload variants:
+ python/pyspark/pandas/series.py:1210: note:     def __getitem__(self, list[str] | Index[Any] | Series[Any] | slice[Any, Any, Any] | Series[builtins.bool] | ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]] | list[builtins.bool] | tuple[Hashable | slice[Any, Any, Any], ...], /) -> Series[Any]
+ python/pyspark/pandas/series.py:1210: note:     def __getitem__(self, str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any], /) -> Any
+ python/pyspark/pandas/series.py:1212: error: Unused "type: ignore" comment  [unused-ignore]

Copy link
Member

@jorenham jorenham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went over it again, and I think it should be good to merge now.

@charris charris merged commit b096d6e into numpy:maintenance/2.3.x Oct 22, 2025
76 checks passed
@charris charris deleted the typing-updates branch October 22, 2025 00:02
@jorenham
Copy link
Member

Thanks @charris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

08 - Backport Used to tag backport PRs 41 - Static typing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants