From 1265dbcb0b0d0a19513cc8d48a3526f42a9d20da Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Sat, 1 Nov 2025 12:37:56 +0100 Subject: [PATCH 1/3] simplify missing --- .pre-commit-config.yaml | 4 +- pandas-stubs/_libs/missing.pyi | 213 +++++++++++++-------------------- pyproject.toml | 6 +- 3 files changed, 88 insertions(+), 135 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be433f52b..22cfd261b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ ci: autofix_prs: false repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.2 + rev: v0.14.3 hooks: - id: ruff-check args: [--exit-non-zero-on-fix] @@ -14,7 +14,7 @@ repos: additional_dependencies: [ tomli ] args: [-L, "THIRDPARTY"] - repo: https://github.com/PyCQA/isort - rev: 6.0.1 + rev: 7.0.0 hooks: - id: isort - repo: https://github.com/psf/black diff --git a/pandas-stubs/_libs/missing.pyi b/pandas-stubs/_libs/missing.pyi index f0bf682e3..5b716bba8 100644 --- a/pandas-stubs/_libs/missing.pyi +++ b/pandas-stubs/_libs/missing.pyi @@ -5,236 +5,189 @@ from typing import ( overload, ) -from pandas import ( - Index, - Series, -) +import numpy as np from pandas.core.arrays.boolean import BooleanArray +from pandas.core.indexes.base import Index +from pandas.core.series import Series from typing_extensions import Self +from pandas._typing import Scalar + class NAType: def __new__(cls, *args: Any, **kwargs: Any) -> Self: ... def __format__(self, format_spec: str) -> str: ... def __hash__(self) -> int: ... def __reduce__(self) -> str: ... @overload - def __add__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __add__(self, other: Series, /) -> Series: ... @overload - def __add__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __add__(self, other: Index, /) -> Index: ... @overload - def __add__(self, other: object, /) -> NAType: ... + def __add__(self, other: Scalar, /) -> NAType: ... @overload - def __radd__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __radd__(self, other: Series, /) -> Series: ... @overload - def __radd__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __radd__(self, other: Index, /) -> Index: ... @overload - def __radd__(self, other: object, /) -> NAType: ... + def __radd__(self, other: Scalar, /) -> NAType: ... @overload - def __sub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __sub__(self, other: Series, /) -> Series: ... @overload - def __sub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __sub__(self, other: Index, /) -> Index: ... @overload - def __sub__(self, other: object, /) -> NAType: ... + def __sub__(self, other: Scalar, /) -> NAType: ... @overload - def __rsub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rsub__(self, other: Series, /) -> Series: ... @overload - def __rsub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rsub__(self, other: Index, /) -> Index: ... @overload - def __rsub__(self, other: object, /) -> NAType: ... + def __rsub__(self, other: Scalar, /) -> NAType: ... @overload - def __mul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __mul__(self, other: Series, /) -> Series: ... @overload - def __mul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __mul__(self, other: Index, /) -> Index: ... @overload - def __mul__(self, other: object, /) -> NAType: ... + def __mul__(self, other: Scalar, /) -> NAType: ... @overload - def __rmul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rmul__(self, other: Series, /) -> Series: ... @overload - def __rmul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rmul__(self, other: Index, /) -> Index: ... @overload - def __rmul__(self, other: object, /) -> NAType: ... - def __matmul__(self, other: object, /) -> NAType: ... - def __rmatmul__(self, other: object, /) -> NAType: ... + def __rmul__(self, other: Scalar, /) -> NAType: ... + def __matmul__(self, other: Scalar, /) -> NAType: ... + def __rmatmul__(self, other: Scalar, /) -> NAType: ... @overload - def __truediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __truediv__(self, other: Series, /) -> Series: ... @overload - def __truediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __truediv__(self, other: Index, /) -> Index: ... @overload - def __truediv__(self, other: object, /) -> NAType: ... + def __truediv__(self, other: Scalar, /) -> NAType: ... @overload - def __rtruediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rtruediv__(self, other: Series, /) -> Series: ... @overload - def __rtruediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rtruediv__(self, other: Index, /) -> Index: ... @overload - def __rtruediv__(self, other: object, /) -> NAType: ... + def __rtruediv__(self, other: Scalar, /) -> NAType: ... @overload - def __floordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __floordiv__(self, other: Series, /) -> Series: ... @overload - def __floordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __floordiv__(self, other: Index, /) -> Index: ... @overload - def __floordiv__(self, other: object, /) -> NAType: ... + def __floordiv__(self, other: Scalar, /) -> NAType: ... @overload - def __rfloordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rfloordiv__(self, other: Series, /) -> Series: ... @overload - def __rfloordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rfloordiv__(self, other: Index, /) -> Index: ... @overload - def __rfloordiv__(self, other: object, /) -> NAType: ... + def __rfloordiv__(self, other: Scalar, /) -> NAType: ... @overload - def __mod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __mod__(self, other: Series, /) -> Series: ... @overload - def __mod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __mod__(self, other: Index, /) -> Index: ... @overload - def __mod__(self, other: object, /) -> NAType: ... + def __mod__(self, other: Scalar, /) -> NAType: ... @overload - def __rmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rmod__(self, other: Series, /) -> Series: ... @overload - def __rmod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rmod__(self, other: Index, /) -> Index: ... @overload - def __rmod__(self, other: object, /) -> NAType: ... + def __rmod__(self, other: Scalar, /) -> NAType: ... @overload - def __divmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> tuple[Series, Series]: ... + def __divmod__(self, other: Series, /) -> tuple[Series, Series]: ... @overload - def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap] + def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ... @overload - def __divmod__(self, other: object, /) -> tuple[NAType, NAType]: ... + def __divmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ... @overload - def __rdivmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> tuple[Series, Series]: ... + def __rdivmod__(self, other: Series, /) -> tuple[Series, Series]: ... @overload - def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap] + def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ... @overload - def __rdivmod__(self, other: object, /) -> tuple[NAType, NAType]: ... + def __rdivmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ... @overload # type: ignore[override] - def __eq__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series[bool]: ... + def __eq__(self, other: Series, /) -> Series[bool]: ... @overload - def __eq__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] + def __eq__(self, other: Index, /) -> BooleanArray: ... @overload def __eq__( # pyright: ignore[reportIncompatibleMethodOverride] - self, other: object, / + self, other: Scalar, / ) -> NAType: ... @overload # type: ignore[override] - def __ne__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series[bool]: ... + def __ne__(self, other: Series, /) -> Series[bool]: ... @overload - def __ne__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] + def __ne__(self, other: Index, /) -> BooleanArray: ... @overload def __ne__( # pyright: ignore[reportIncompatibleMethodOverride] - self, other: object, / + self, other: Scalar, / ) -> NAType: ... @overload - def __le__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series[bool]: ... + def __le__(self, other: Series, /) -> Series[bool]: ... @overload - def __le__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] + def __le__(self, other: Index, /) -> BooleanArray: ... @overload - def __le__(self, other: object, /) -> NAType: ... + def __le__(self, other: Scalar, /) -> NAType: ... @overload - def __lt__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series[bool]: ... + def __lt__(self, other: Series, /) -> Series[bool]: ... @overload - def __lt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] + def __lt__(self, other: Index, /) -> BooleanArray: ... @overload - def __lt__(self, other: object, /) -> NAType: ... + def __lt__(self, other: Scalar, /) -> NAType: ... @overload - def __gt__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series[bool]: ... + def __gt__(self, other: Series, /) -> Series[bool]: ... @overload - def __gt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] + def __gt__(self, other: Index, /) -> BooleanArray: ... @overload - def __gt__(self, other: object, /) -> NAType: ... + def __gt__(self, other: Scalar, /) -> NAType: ... @overload - def __ge__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series[bool]: ... + def __ge__(self, other: Series, /) -> Series[bool]: ... @overload - def __ge__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] + def __ge__(self, other: Index, /) -> BooleanArray: ... @overload - def __ge__(self, other: object, /) -> NAType: ... + def __ge__(self, other: Scalar, /) -> NAType: ... def __neg__(self) -> NAType: ... def __pos__(self) -> NAType: ... def __abs__(self) -> NAType: ... def __invert__(self) -> NAType: ... @overload - def __pow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __pow__(self, other: Series, /) -> Series: ... @overload - def __pow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __pow__(self, other: Index, /) -> Index: ... @overload - def __pow__(self, other: object, /) -> NAType: ... + def __pow__(self, other: complex, /) -> NAType: ... @overload - def __rpow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rpow__(self, other: Series, /) -> Series: ... @overload - def __rpow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rpow__(self, other: Index, /) -> Index: ... @overload - def __rpow__(self, other: object, /) -> NAType: ... + def __rpow__(self, other: complex, /) -> NAType: ... @overload - def __and__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] + def __and__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] @overload def __and__(self, other: bool | NAType, /) -> NAType: ... @overload - def __rand__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] + def __rand__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] @overload def __rand__(self, other: bool, /) -> NAType: ... @overload - def __or__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] + def __or__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] @overload def __or__(self, other: bool | NAType, /) -> NAType: ... @overload - def __ror__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] + def __ror__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] @overload def __ror__(self, other: bool | NAType, /) -> NAType: ... @overload - def __xor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __xor__(self, other: Series, /) -> Series: ... @overload - def __xor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __xor__(self, other: Index, /) -> Index: ... @overload - def __xor__(self, other: object, /) -> NAType: ... + def __xor__(self, other: bool | np.bool, /) -> NAType: ... @overload - def __rxor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] - self, other: Series, / - ) -> Series: ... + def __rxor__(self, other: Series, /) -> Series: ... @overload - def __rxor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] + def __rxor__(self, other: Index, /) -> Index: ... @overload - def __rxor__(self, other: object, /) -> NAType: ... + def __rxor__(self, other: bool | np.bool, /) -> NAType: ... __array_priority__: int def __array_ufunc__( self, ufunc: Callable[..., Any], method: str, *inputs: Any, **kwargs: Any diff --git a/pyproject.toml b/pyproject.toml index fa9ac2b70..2fea16836 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,15 +42,15 @@ pandas = "2.3.3" pyarrow = ">=10.0.1" pytest = ">=8.4.2" pyright = ">=1.1.407" -ty = ">=0.0.1a24" +ty = ">=0.0.1a25" pyrefly = ">=0.38.2" poethepoet = ">=0.16.5" loguru = ">=0.6.0" typing-extensions = ">=4.4.0" matplotlib = ">=3.10.1" -pre-commit = ">=2.19.0" +pre-commit = ">=4.3.0" black = ">=25.9.0" -isort = ">=6.0.1" +isort = ">=7.0.0" openpyxl = ">=3.0.10" numexpr = ">=2.13.1" lxml = ">=4.9.1" From fac22749965369335ed50106a466e215504dc70b Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Sun, 2 Nov 2025 13:39:11 +0100 Subject: [PATCH 2/3] pyrefly --- pandas-stubs/_libs/missing.pyi | 8 ++++++-- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandas-stubs/_libs/missing.pyi b/pandas-stubs/_libs/missing.pyi index 5b716bba8..4c2ffa22d 100644 --- a/pandas-stubs/_libs/missing.pyi +++ b/pandas-stubs/_libs/missing.pyi @@ -105,7 +105,9 @@ class NAType: @overload def __rdivmod__(self, other: Scalar, /) -> tuple[NAType, NAType]: ... @overload # type: ignore[override] - def __eq__(self, other: Series, /) -> Series[bool]: ... + def __eq__( # pyrefly: ignore[bad-override] + self, other: Series, / + ) -> Series[bool]: ... @overload def __eq__(self, other: Index, /) -> BooleanArray: ... @overload @@ -113,7 +115,9 @@ class NAType: self, other: Scalar, / ) -> NAType: ... @overload # type: ignore[override] - def __ne__(self, other: Series, /) -> Series[bool]: ... + def __ne__( # pyrefly: ignore[bad-override] + self, other: Series, / + ) -> Series[bool]: ... @overload def __ne__(self, other: Index, /) -> BooleanArray: ... @overload diff --git a/pyproject.toml b/pyproject.toml index 2fea16836..fad5ae7a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ pyarrow = ">=10.0.1" pytest = ">=8.4.2" pyright = ">=1.1.407" ty = ">=0.0.1a25" -pyrefly = ">=0.38.2" +pyrefly = ">=0.39.4" poethepoet = ">=0.16.5" loguru = ">=0.6.0" typing-extensions = ">=4.4.0" From e37bd232acd2ba369890d313211e3e49a806f040 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Sun, 2 Nov 2025 14:16:38 +0100 Subject: [PATCH 3/3] mypy + py310 --- pandas-stubs/_libs/missing.pyi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandas-stubs/_libs/missing.pyi b/pandas-stubs/_libs/missing.pyi index 4c2ffa22d..4b7f244b9 100644 --- a/pandas-stubs/_libs/missing.pyi +++ b/pandas-stubs/_libs/missing.pyi @@ -1,4 +1,5 @@ from collections.abc import Callable +import sys from typing import ( Any, Literal, @@ -28,8 +29,13 @@ class NAType: def __radd__(self, other: Series, /) -> Series: ... @overload def __radd__(self, other: Index, /) -> Index: ... - @overload - def __radd__(self, other: Scalar, /) -> NAType: ... + if sys.version_info >= (3, 11): + @overload + def __radd__(self, other: Scalar, /) -> NAType: ... + else: + @overload + def __radd__(self, other: Scalar, /) -> NAType: ... # type: ignore[misc] + @overload def __sub__(self, other: Series, /) -> Series: ... @overload