diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23c60e403..e5f878a04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/pandas-stubs/_libs/tslibs/timestamps.pyi b/pandas-stubs/_libs/tslibs/timestamps.pyi index 795f98a9a..b986c186a 100644 --- a/pandas-stubs/_libs/tslibs/timestamps.pyi +++ b/pandas-stubs/_libs/tslibs/timestamps.pyi @@ -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: @@ -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 = ..., diff --git a/pandas-stubs/core/arrays/datetimelike.pyi b/pandas-stubs/core/arrays/datetimelike.pyi index 8348d1f02..8b1c6ac6d 100644 --- a/pandas-stubs/core/arrays/datetimelike.pyi +++ b/pandas-stubs/core/arrays/datetimelike.pyi @@ -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: ... @@ -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): ... diff --git a/pandas-stubs/core/groupby/generic.pyi b/pandas-stubs/core/groupby/generic.pyi index 1cfab095e..b07554de8 100644 --- a/pandas-stubs/core/groupby/generic.pyi +++ b/pandas-stubs/core/groupby/generic.pyi @@ -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], /, diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index ce5780344..8a017d828 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -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: ... @@ -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] = ..., @@ -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 = ... ): ... diff --git a/pandas-stubs/core/indexes/range.pyi b/pandas-stubs/core/indexes/range.pyi index 776daea15..1576fc1d6 100644 --- a/pandas-stubs/core/indexes/range.pyi +++ b/pandas-stubs/core/indexes/range.pyi @@ -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] diff --git a/pandas-stubs/core/indexing.pyi b/pandas-stubs/core/indexing.pyi index d9516d478..2e3f0237f 100644 --- a/pandas-stubs/core/indexing.pyi +++ b/pandas-stubs/core/indexing.pyi @@ -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: ... diff --git a/pandas-stubs/core/resample.pyi b/pandas-stubs/core/resample.pyi index 6495a290a..d53da8a0f 100644 --- a/pandas-stubs/core/resample.pyi +++ b/pandas-stubs/core/resample.pyi @@ -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 diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 1982d54bc..246c29429 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -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 = ..., diff --git a/pandas-stubs/core/window/ewm.pyi b/pandas-stubs/core/window/ewm.pyi index cc9d8cbb7..15e48ef28 100644 --- a/pandas-stubs/core/window/ewm.pyi +++ b/pandas-stubs/core/window/ewm.pyi @@ -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 = ..., @@ -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: ... diff --git a/pyproject.toml b/pyproject.toml index a78d5df00..860a20af6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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" diff --git a/scripts/test/_step.py b/scripts/test/_step.py index 127ae9b60..129cd0b18 100644 --- a/scripts/test/_step.py +++ b/scripts/test/_step.py @@ -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, diff --git a/scripts/test/run.py b/scripts/test/run.py index a8a9a8758..359fac5b1 100644 --- a/scripts/test/run.py +++ b/scripts/test/run.py @@ -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)