Skip to content

Commit 69cf85e

Browse files
authored
Run Pyrefly on pandas-stubs in CI (#1263)
* pyrefly support * add suppressions * add suppressions * add 3.12+ suppression
1 parent 9c49879 commit 69cf85e

File tree

13 files changed

+33
-14
lines changed

13 files changed

+33
-14
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Run ty on 'pandas-stubs' (using the local stubs) and on the local stubs
3939
run: poetry run poe ty
4040

41+
- name: Run pyrefly on the local stubs
42+
run: poetry run poe pyrefly
43+
4144
- name: Run pyright on 'tests' (using the local stubs) and on the local stubs
4245
run: poetry run poe pyright
4346

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Timestamp(datetime, SupportsIndex):
105105

106106
if sys.version_info >= (3, 12):
107107
@classmethod
108-
def fromtimestamp( # pyright: ignore[reportIncompatibleMethodOverride]
108+
def fromtimestamp( # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
109109
cls, t: float, tz: _tzinfo | str | None = ...
110110
) -> Self: ...
111111
else:
@@ -143,7 +143,7 @@ class Timestamp(datetime, SupportsIndex):
143143
# Override since fold is more precise than datetime.replace(fold:int)
144144
# Here it is restricted to be 0 or 1 using a Literal
145145
# Violation of Liskov substitution principle
146-
def replace( # type:ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
146+
def replace( # type:ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
147147
self,
148148
year: int | None = ...,
149149
month: int | None = ...,

pandas-stubs/core/arrays/datetimelike.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
5050
@property
5151
def shape(self): ...
5252
def reshape(self, *args, **kwargs): ...
53-
def ravel(self, *args, **kwargs): ...
53+
def ravel(self, *args, **kwargs): ... # pyrefly: ignore
5454
def __iter__(self): ...
5555
@property
5656
def asi8(self) -> np.ndarray: ...
@@ -76,7 +76,7 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
7676
def copy(self): ...
7777
def shift(self, periods: int = ..., fill_value=..., axis: int = ...): ...
7878
def searchsorted(self, value, side: str = ..., sorter=...): ...
79-
def repeat(self, repeats, *args, **kwargs): ...
79+
def repeat(self, repeats, *args, **kwargs): ... # pyrefly: ignore
8080
def value_counts(self, dropna: bool = ...): ...
8181
def map(self, mapper): ...
8282
def isna(self): ...

pandas-stubs/core/groupby/generic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class NamedAgg(NamedTuple):
5858

5959
class SeriesGroupBy(GroupBy[Series[S2]], Generic[S2, ByT]):
6060
@overload
61-
def aggregate(
61+
def aggregate( # pyrefly: ignore
6262
self,
6363
func: Callable[Concatenate[Series[S2], P], S3],
6464
/,

pandas-stubs/core/indexes/multi.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MultiIndex(Index):
7373
@property
7474
def codes(self): ...
7575
def set_codes(self, codes, *, level=..., verify_integrity: bool = ...): ...
76-
def copy( # pyright: ignore[reportIncompatibleMethodOverride]
76+
def copy( # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
7777
self, names=..., deep: bool = ...
7878
) -> Self: ...
7979
def __array__(self, dtype=...) -> np.ndarray: ...
@@ -107,7 +107,7 @@ class MultiIndex(Index):
107107
def dropna(self, how: AnyAll = ...) -> Self: ...
108108
def get_level_values(self, level: str | int) -> Index: ...
109109
def unique(self, level=...): ...
110-
def to_frame(
110+
def to_frame( # pyrefly: ignore
111111
self,
112112
index: bool = ...,
113113
name: list[HashableT] = ...,
@@ -153,7 +153,7 @@ class MultiIndex(Index):
153153
def truncate(self, before=..., after=...): ...
154154
def equals(self, other) -> bool: ...
155155
def equal_levels(self, other): ...
156-
def union(self, other, sort=...): ...
156+
def union(self, other, sort=...): ... # pyrefly: ignore
157157
def intersection( # pyright: ignore[reportIncompatibleMethodOverride]
158158
self, other: list | Self, sort: bool = ...
159159
): ...

pandas-stubs/core/indexes/range.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class RangeIndex(Index[int]):
7272
def __floordiv__(self, other): ...
7373
def all(self) -> bool: ...
7474
def any(self) -> bool: ...
75-
def union(
75+
def union( # pyrefly: ignore
7676
self, other: list[HashableT] | Index, sort=...
7777
) -> Index | Index[int] | RangeIndex: ...
7878
@overload # type: ignore[override]

pandas-stubs/core/indexing.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ _IndexSliceTuple: TypeAlias = tuple[
1616

1717
_IndexSliceUnion: TypeAlias = slice | _IndexSliceTuple
1818

19-
_IndexSliceUnionT = TypeVar("_IndexSliceUnionT", bound=_IndexSliceUnion)
19+
_IndexSliceUnionT = TypeVar(
20+
"_IndexSliceUnionT", bound=_IndexSliceUnion # pyrefly: ignore
21+
)
2022

2123
class _IndexSlice:
2224
def __getitem__(self, arg: _IndexSliceUnionT) -> _IndexSliceUnionT: ...

pandas-stubs/core/resample.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ _SeriesGroupByFuncArgs: TypeAlias = (
6262
)
6363

6464
class Resampler(BaseGroupBy[NDFrameT]):
65-
grouper: BinGrouper # pyright: ignore[reportIncompatibleVariableOverride] # variance incompatibility
65+
grouper: BinGrouper # pyright: ignore[reportIncompatibleVariableOverride] # pyrefly: ignore # variance incompatibility
6666
binner: DatetimeIndex | TimedeltaIndex | PeriodIndex
6767
exclusions: frozenset[Hashable]
6868
ax: Index

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
15551555
def first_valid_index(self) -> Scalar: ...
15561556
def last_valid_index(self) -> Scalar: ...
15571557
@overload
1558-
def value_counts(
1558+
def value_counts( # pyrefly: ignore
15591559
self,
15601560
normalize: Literal[False] = ...,
15611561
sort: _bool = ...,

pandas-stubs/core/window/ewm.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ExponentialMovingWindowGroupby(
5454
class OnlineExponentialMovingWindow(ExponentialMovingWindow[NDFrameT]):
5555
def reset(self) -> None: ...
5656
def aggregate(self, func, *args, **kwargs): ...
57-
def std(self, bias: bool = ..., *args, **kwargs): ...
57+
def std(self, bias: bool = ..., *args, **kwargs): ... # pyrefly: ignore
5858
def corr(
5959
self,
6060
other: DataFrame | Series | None = ...,
@@ -69,6 +69,6 @@ class OnlineExponentialMovingWindow(ExponentialMovingWindow[NDFrameT]):
6969
numeric_only: bool = ...,
7070
): ...
7171
def var(self, bias: bool = ..., numeric_only: bool = ...): ...
72-
def mean(
72+
def mean( # pyrefly: ignore
7373
self, *args, update: NDFrameT | None = ..., update_times: None = ..., **kwargs
7474
) -> NDFrameT: ...

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ python = ">=3.10"
3434
types-pytz = ">= 2022.1.1"
3535
numpy = ">= 1.23.5"
3636
ty = "^0.0.1a8"
37+
pyrefly = "^0.21.0"
3738

3839
[tool.poetry.group.dev.dependencies]
3940
mypy = "1.16.0"
@@ -108,6 +109,10 @@ script = "scripts.test:test(dist=True, type_checker='mypy')"
108109
help = "Run ty on pandas-stubs"
109110
script = "scripts.test.run:ty"
110111

112+
[tool.poe.tasks.pyrefly]
113+
help = "Run pyrefly on pandas-stubs"
114+
script = "scripts.test.run:pyrefly"
115+
111116
[tool.poe.tasks.pyright]
112117
help = "Run pyright on 'tests' (using the local stubs) and on the local stubs"
113118
script = "scripts.test.run:pyright_src"

scripts/test/_step.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
name="Run ty on 'pandas-stubs' (using the local stubs) and on the local stubs",
1010
run=run.ty,
1111
)
12+
pyrefly_src = Step(
13+
name="Run pyrefly on the local stubs",
14+
run=run.pyrefly,
15+
)
1216
pyright_src = Step(
1317
name="Run pyright on 'tests' (using the local stubs) and on the local stubs",
1418
run=run.pyright_src,

scripts/test/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,8 @@ def released_mypy():
156156
def ty():
157157
cmd = ["ty", "check", "pandas-stubs"]
158158
subprocess.run(cmd, check=True)
159+
160+
161+
def pyrefly():
162+
cmd = ["pyrefly", "check", "pandas-stubs"]
163+
subprocess.run(cmd, check=True)

0 commit comments

Comments
 (0)