Skip to content

Commit 78067f4

Browse files
committed
fix: error comes from pyright
1 parent 5099a1a commit 78067f4

File tree

12 files changed

+76
-47
lines changed

12 files changed

+76
-47
lines changed

pandas-stubs/core/generic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,6 @@ class NDFrame(indexing.IndexingMixin):
430430
origin: TimeGrouperOrigin | TimestampConvertibleTypes = "start_day",
431431
offset: TimedeltaConvertibleTypes | None = None,
432432
group_keys: _bool = False,
433-
) -> DatetimeIndexResampler[Self]: ...
433+
) -> DatetimeIndexResampler[Self]: ... # pyrefly: ignore[bad-specialization]
434434
@final
435435
def take(self, indices: TakeIndexer, axis: Axis = 0, **kwargs: Any) -> Self: ...

pandas-stubs/core/groupby/generic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class DFCallable3(Protocol[P]): # ty: ignore[invalid-argument-type]
229229
class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT, _TT]):
230230
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
231231
@overload # type: ignore[override]
232-
def apply(
232+
def apply( # pyrefly: ignore[bad-override]
233233
self,
234234
func: DFCallable1[P],
235235
/,

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ class GroupBy(BaseGroupBy[NDFrameT]):
255255
def bfill(self, limit: int | None = ...) -> NDFrameT: ...
256256
@final
257257
@property
258-
def nth(self) -> GroupByNthSelector[Self]: ...
258+
def nth(
259+
self,
260+
) -> GroupByNthSelector[Self]: ... # pyrefly: ignore[bad-specialization]
259261
@final
260262
def quantile(
261263
self,

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class Index(IndexOpsMixin[S1]):
279279
@property
280280
def str(
281281
self,
282-
) -> StringMethods[
282+
) -> StringMethods[ # pyrefly: ignore[bad-specialization]
283283
Self,
284284
MultiIndex,
285285
np_1darray[np.bool],

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
11981198
@property
11991199
def str(
12001200
self,
1201-
) -> StringMethods[
1201+
) -> StringMethods[ # pyrefly: ignore[bad-specialization]
12021202
Self,
12031203
DataFrame,
12041204
Series[bool],

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ pandas = "2.3.2"
4141
pyarrow = ">=10.0.1"
4242
pytest = ">=7.1.2"
4343
pyright = ">=1.1.405"
44-
ty = "^0.0.1a9"
45-
pyrefly = "^0.21.0"
44+
ty = ">=0.0.1a20"
45+
pyrefly = ">=0.32.0"
4646
poethepoet = ">=0.16.5"
4747
loguru = ">=0.6.0"
4848
typing-extensions = ">=4.4.0"
4949
matplotlib = ">=3.10.1"
5050
pre-commit = ">=2.19.0"
51-
black = ">=23.3.0"
52-
isort = ">=5.12.0"
51+
black = ">=25.1.0"
52+
isort = ">=6.0.1"
5353
openpyxl = ">=3.0.10"
5454
tables = { version = ">=3.10.1", python = "<4" }
5555
lxml = ">=4.9.1"

tests/indexes/arithmetic/test_add.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from typing import Any
2+
13
import numpy as np
2-
from numpy import typing as npt # noqa: F401
34
import pandas as pd
45
from typing_extensions import (
56
Never,
@@ -61,18 +62,22 @@ def test_add_i_numpy_array() -> None:
6162
# `numpy` typing gives the corresponding `ndarray`s in the static type
6263
# checking, where our `__radd__` cannot override. At runtime, they return
6364
# `Index`s.
64-
# `mypy` thinks the return types are `Any`, which is a bug.
65+
# microsoft/pyright#10924
6566
check(
66-
assert_type(b + left_i, "npt.NDArray[np.bool_]"), pd.Index # type: ignore[assert-type]
67+
assert_type(b + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
68+
pd.Index,
6769
)
6870
check(
69-
assert_type(i + left_i, "npt.NDArray[np.int64]"), pd.Index # type: ignore[assert-type]
71+
assert_type(i + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
72+
pd.Index,
7073
)
7174
check(
72-
assert_type(f + left_i, "npt.NDArray[np.float64]"), pd.Index # type: ignore[assert-type]
75+
assert_type(f + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
76+
pd.Index,
7377
)
7478
check(
75-
assert_type(c + left_i, "npt.NDArray[np.complex128]"), pd.Index # type: ignore[assert-type]
79+
assert_type(c + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
80+
pd.Index,
7681
)
7782

7883

tests/indexes/arithmetic/test_sub.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from typing import NoReturn
1+
from typing import Any
22

33
import numpy as np
4-
from numpy import typing as npt # noqa: F401
54
import pandas as pd
65
from typing_extensions import assert_type
76

@@ -59,16 +58,22 @@ def test_sub_i_numpy_array() -> None:
5958
# `numpy` typing gives the corresponding `ndarray`s in the static type
6059
# checking, where our `__rsub__` cannot override. At runtime, they return
6160
# `Index`s.
62-
# `mypy` thinks the return types are `Any`, which is a bug.
63-
check(assert_type(b - left_i, NoReturn), pd.Index) # type: ignore[assert-type]
61+
# microsoft/pyright#10924
6462
check(
65-
assert_type(i - left_i, "npt.NDArray[np.int64]"), pd.Index # type: ignore[assert-type]
63+
assert_type(b - left_i, Any), # pyright: ignore[reportAssertTypeFailure]
64+
pd.Index,
6665
)
6766
check(
68-
assert_type(f - left_i, "npt.NDArray[np.float64]"), pd.Index # type: ignore[assert-type]
67+
assert_type(i - left_i, Any), # pyright: ignore[reportAssertTypeFailure]
68+
pd.Index,
6969
)
7070
check(
71-
assert_type(c - left_i, "npt.NDArray[np.complex128]"), pd.Index # type: ignore[assert-type]
71+
assert_type(f - left_i, Any), # pyright: ignore[reportAssertTypeFailure]
72+
pd.Index,
73+
)
74+
check(
75+
assert_type(c - left_i, Any), # pyright: ignore[reportAssertTypeFailure]
76+
pd.Index,
7277
)
7378

7479

tests/series/arithmetic/test_add.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
)
55

66
import numpy as np
7-
from numpy import typing as npt # noqa: F401
87
import pandas as pd
98
from typing_extensions import (
109
Never,
@@ -95,18 +94,22 @@ def test_add_i_numpy_array() -> None:
9594
# `numpy` typing gives the corresponding `ndarray`s in the static type
9695
# checking, where our `__radd__` cannot override. At runtime, they return
9796
# `Series`s.
98-
# `mypy` thinks the return types are `Any`, which is a bug.
97+
# microsoft/pyright#10924
9998
check(
100-
assert_type(b + left_i, "npt.NDArray[np.bool_]"), pd.Series # type: ignore[assert-type]
99+
assert_type(b + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
100+
pd.Series,
101101
)
102102
check(
103-
assert_type(i + left_i, "npt.NDArray[np.int64]"), pd.Series # type: ignore[assert-type]
103+
assert_type(i + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
104+
pd.Series,
104105
)
105106
check(
106-
assert_type(f + left_i, "npt.NDArray[np.float64]"), pd.Series # type: ignore[assert-type]
107+
assert_type(f + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
108+
pd.Series,
107109
)
108110
check(
109-
assert_type(c + left_i, "npt.NDArray[np.complex128]"), pd.Series # type: ignore[assert-type]
111+
assert_type(c + left_i, Any), # pyright: ignore[reportAssertTypeFailure]
112+
pd.Series,
110113
)
111114

112115
check(assert_type(left_i.add(b), pd.Series), pd.Series)

tests/series/arithmetic/test_mul.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from typing import Any
2+
13
import numpy as np
2-
from numpy import typing as npt # noqa: F401
34
import pandas as pd
45
from typing_extensions import assert_type
56

@@ -76,18 +77,22 @@ def test_mul_numpy_array() -> None:
7677
# `numpy` typing gives the corresponding `ndarray`s in the static type
7778
# checking, where our `__rmul__` cannot override. At runtime, they return
7879
# `Series`s.
79-
# `mypy` thinks the return types are `Any`, which is a bug.
80+
# microsoft/pyright#10924
8081
check(
81-
assert_type(b * left_i, "npt.NDArray[np.bool_]"), pd.Series # type: ignore[assert-type]
82+
assert_type(b * left_i, Any), # pyright: ignore[reportAssertTypeFailure]
83+
pd.Series,
8284
)
8385
check(
84-
assert_type(i * left_i, "npt.NDArray[np.int64]"), pd.Series # type: ignore[assert-type]
86+
assert_type(i * left_i, Any), # pyright: ignore[reportAssertTypeFailure]
87+
pd.Series,
8588
)
8689
check(
87-
assert_type(f * left_i, "npt.NDArray[np.float64]"), pd.Series # type: ignore[assert-type]
90+
assert_type(f * left_i, Any), # pyright: ignore[reportAssertTypeFailure]
91+
pd.Series,
8892
)
8993
check(
90-
assert_type(c * left_i, "npt.NDArray[np.complex128]"), pd.Series # type: ignore[assert-type]
94+
assert_type(c * left_i, Any), # pyright: ignore[reportAssertTypeFailure]
95+
pd.Series,
9196
)
9297

9398
check(assert_type(left_i.mul(b), pd.Series), pd.Series)

0 commit comments

Comments
 (0)