Skip to content

Run Pyrefly on pandas-stubs in CI #1263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
- name: Run ty on 'pandas-stubs' (using the local stubs) and on the local stubs
run: poetry run poe ty

- name: Run pyrefly on the local stubs
run: poetry run poe pyrefly

- name: Run pyright on 'tests' (using the local stubs) and on the local stubs
run: poetry run poe pyright

Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Timestamp(datetime, SupportsIndex):

if sys.version_info >= (3, 12):
@classmethod
def fromtimestamp( # pyright: ignore[reportIncompatibleMethodOverride]
def fromtimestamp( # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
cls, t: float, tz: _tzinfo | str | None = ...
) -> Self: ...
else:
Expand Down Expand Up @@ -143,7 +143,7 @@ class Timestamp(datetime, SupportsIndex):
# Override since fold is more precise than datetime.replace(fold:int)
# Here it is restricted to be 0 or 1 using a Literal
# Violation of Liskov substitution principle
def replace( # type:ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def replace( # type:ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
self,
year: int | None = ...,
month: int | None = ...,
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/arrays/datetimelike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
@property
def shape(self): ...
def reshape(self, *args, **kwargs): ...
def ravel(self, *args, **kwargs): ...
def ravel(self, *args, **kwargs): ... # pyrefly: ignore
def __iter__(self): ...
@property
def asi8(self) -> np.ndarray: ...
Expand All @@ -76,7 +76,7 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
def copy(self): ...
def shift(self, periods: int = ..., fill_value=..., axis: int = ...): ...
def searchsorted(self, value, side: str = ..., sorter=...): ...
def repeat(self, repeats, *args, **kwargs): ...
def repeat(self, repeats, *args, **kwargs): ... # pyrefly: ignore
def value_counts(self, dropna: bool = ...): ...
def map(self, mapper): ...
def isna(self): ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/groupby/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class NamedAgg(NamedTuple):

class SeriesGroupBy(GroupBy[Series[S2]], Generic[S2, ByT]):
@overload
def aggregate(
def aggregate( # pyrefly: ignore
self,
func: Callable[Concatenate[Series[S2], P], S3],
/,
Expand Down
6 changes: 3 additions & 3 deletions pandas-stubs/core/indexes/multi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MultiIndex(Index):
@property
def codes(self): ...
def set_codes(self, codes, *, level=..., verify_integrity: bool = ...): ...
def copy( # pyright: ignore[reportIncompatibleMethodOverride]
def copy( # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore
self, names=..., deep: bool = ...
) -> Self: ...
def __array__(self, dtype=...) -> np.ndarray: ...
Expand Down Expand Up @@ -107,7 +107,7 @@ class MultiIndex(Index):
def dropna(self, how: AnyAll = ...) -> Self: ...
def get_level_values(self, level: str | int) -> Index: ...
def unique(self, level=...): ...
def to_frame(
def to_frame( # pyrefly: ignore
self,
index: bool = ...,
name: list[HashableT] = ...,
Expand Down Expand Up @@ -153,7 +153,7 @@ class MultiIndex(Index):
def truncate(self, before=..., after=...): ...
def equals(self, other) -> bool: ...
def equal_levels(self, other): ...
def union(self, other, sort=...): ...
def union(self, other, sort=...): ... # pyrefly: ignore
def intersection( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: list | Self, sort: bool = ...
): ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/indexes/range.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RangeIndex(Index[int]):
def __floordiv__(self, other): ...
def all(self) -> bool: ...
def any(self) -> bool: ...
def union(
def union( # pyrefly: ignore
self, other: list[HashableT] | Index, sort=...
) -> Index | Index[int] | RangeIndex: ...
@overload # type: ignore[override]
Expand Down
4 changes: 3 additions & 1 deletion pandas-stubs/core/indexing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ _IndexSliceTuple: TypeAlias = tuple[

_IndexSliceUnion: TypeAlias = slice | _IndexSliceTuple

_IndexSliceUnionT = TypeVar("_IndexSliceUnionT", bound=_IndexSliceUnion)
_IndexSliceUnionT = TypeVar(
"_IndexSliceUnionT", bound=_IndexSliceUnion # pyrefly: ignore
)

class _IndexSlice:
def __getitem__(self, arg: _IndexSliceUnionT) -> _IndexSliceUnionT: ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/resample.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _SeriesGroupByFuncArgs: TypeAlias = (
)

class Resampler(BaseGroupBy[NDFrameT]):
grouper: BinGrouper # pyright: ignore[reportIncompatibleVariableOverride] # variance incompatibility
grouper: BinGrouper # pyright: ignore[reportIncompatibleVariableOverride] # pyrefly: ignore # variance incompatibility
binner: DatetimeIndex | TimedeltaIndex | PeriodIndex
exclusions: frozenset[Hashable]
ax: Index
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
def first_valid_index(self) -> Scalar: ...
def last_valid_index(self) -> Scalar: ...
@overload
def value_counts(
def value_counts( # pyrefly: ignore
self,
normalize: Literal[False] = ...,
sort: _bool = ...,
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/window/ewm.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ExponentialMovingWindowGroupby(
class OnlineExponentialMovingWindow(ExponentialMovingWindow[NDFrameT]):
def reset(self) -> None: ...
def aggregate(self, func, *args, **kwargs): ...
def std(self, bias: bool = ..., *args, **kwargs): ...
def std(self, bias: bool = ..., *args, **kwargs): ... # pyrefly: ignore
def corr(
self,
other: DataFrame | Series | None = ...,
Expand All @@ -69,6 +69,6 @@ class OnlineExponentialMovingWindow(ExponentialMovingWindow[NDFrameT]):
numeric_only: bool = ...,
): ...
def var(self, bias: bool = ..., numeric_only: bool = ...): ...
def mean(
def mean( # pyrefly: ignore
self, *args, update: NDFrameT | None = ..., update_times: None = ..., **kwargs
) -> NDFrameT: ...
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ python = ">=3.10"
types-pytz = ">= 2022.1.1"
numpy = ">= 1.23.5"
ty = "^0.0.1a8"
pyrefly = "^0.21.0"

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

[tool.poe.tasks.pyrefly]
help = "Run pyrefly on pandas-stubs"
script = "scripts.test.run:pyrefly"

[tool.poe.tasks.pyright]
help = "Run pyright on 'tests' (using the local stubs) and on the local stubs"
script = "scripts.test.run:pyright_src"
Expand Down
4 changes: 4 additions & 0 deletions scripts/test/_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
name="Run ty on 'pandas-stubs' (using the local stubs) and on the local stubs",
run=run.ty,
)
pyrefly_src = Step(
name="Run pyrefly on the local stubs",
run=run.pyrefly,
)
pyright_src = Step(
name="Run pyright on 'tests' (using the local stubs) and on the local stubs",
run=run.pyright_src,
Expand Down
5 changes: 5 additions & 0 deletions scripts/test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,8 @@ def released_mypy():
def ty():
cmd = ["ty", "check", "pandas-stubs"]
subprocess.run(cmd, check=True)


def pyrefly():
cmd = ["pyrefly", "check", "pandas-stubs"]
subprocess.run(cmd, check=True)