From c4e1568c0b55e87d685a3a9aa38eb86a01ac18be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Diridollou?= Date: Thu, 18 Dec 2025 16:34:43 -0500 Subject: [PATCH 1/2] GH1318 Add defaults to pandas/core/indexes --- pandas-stubs/core/indexes/accessors.pyi | 26 +++--- pandas-stubs/core/indexes/category.pyi | 2 +- pandas-stubs/core/indexes/interval.pyi | 106 +++++++++++------------ pandas-stubs/core/indexes/timedeltas.pyi | 22 ++--- 4 files changed, 79 insertions(+), 77 deletions(-) diff --git a/pandas-stubs/core/indexes/accessors.pyi b/pandas-stubs/core/indexes/accessors.pyi index 61d24d45c..5014eaca3 100644 --- a/pandas-stubs/core/indexes/accessors.pyi +++ b/pandas-stubs/core/indexes/accessors.pyi @@ -180,32 +180,32 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]): def round( self, freq: Frequency | None, - ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ..., + ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = "raise", nonexistent: ( Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta | Timedelta - ) = ..., + ) = "raise", ) -> _DTTimestampTimedeltaReturnType: ... def floor( self, freq: Frequency | None, - ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ..., + ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = "raise", nonexistent: ( Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta | Timedelta - ) = ..., + ) = "raise", ) -> _DTTimestampTimedeltaReturnType: ... def ceil( self, freq: Frequency | None, - ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ..., + ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = "raise", nonexistent: ( Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta | Timedelta - ) = ..., + ) = "raise", ) -> _DTTimestampTimedeltaReturnType: ... _DTNormalizeReturnType = TypeVar( @@ -231,14 +231,14 @@ class _DatetimeLikeNoTZMethods( def tz_localize( self, tz: TimeZones, - ambiguous: TimeAmbiguous = ..., - nonexistent: TimeNonexistent = ..., + ambiguous: TimeAmbiguous = "raise", + nonexistent: TimeNonexistent = "raise", ) -> _DTNormalizeReturnType: ... def tz_convert(self, tz: TimeZones) -> _DTNormalizeReturnType: ... def normalize(self) -> _DTNormalizeReturnType: ... def strftime(self, date_format: str) -> _DTStrKindReturnType: ... - def month_name(self, locale: str | None = ...) -> _DTStrKindReturnType: ... - def day_name(self, locale: str | None = ...) -> _DTStrKindReturnType: ... + def month_name(self, locale: str | None = None) -> _DTStrKindReturnType: ... + def day_name(self, locale: str | None = None) -> _DTStrKindReturnType: ... class _DatetimeNoTZProperties( _DatetimeLikeOps[ @@ -359,12 +359,12 @@ class _PeriodProperties( def to_timestamp( self, freq: PeriodFrequency | None = None, - how: TimestampConvention = ..., + how: TimestampConvention = "start", ) -> _PeriodDTAReturnTypes: ... def asfreq( self, freq: PeriodFrequency | None = None, - how: Literal["E", "END", "FINISH", "S", "START", "BEGIN"] = ..., + how: Literal["E", "END", "FINISH", "S", "START", "BEGIN"] = "E", ) -> _PeriodPAReturnTypes: ... class PeriodIndexFieldOps( @@ -432,7 +432,7 @@ class DatetimeIndexProperties( def tzinfo(self) -> _tzinfo | None: ... def to_pydatetime(self) -> np_1darray_object: ... def std( - self, axis: int | None = ..., ddof: int = ..., skipna: bool = ... + self, axis: int | None = None, ddof: int = 1, skipna: bool = True ) -> Timedelta: ... class TimedeltaIndexProperties( diff --git a/pandas-stubs/core/indexes/category.pyi b/pandas-stubs/core/indexes/category.pyi index 930d78cbd..aea12cf77 100644 --- a/pandas-stubs/core/indexes/category.pyi +++ b/pandas-stubs/core/indexes/category.pyi @@ -23,7 +23,7 @@ class CategoricalIndex(ExtensionIndex[S1], PandasDelegate): def array(self) -> Categorical: ... # type: ignore[override] # pyrefly: ignore[bad-override] def __new__( cls, - data: Iterable[S1] = ..., + data: Iterable[S1], categories: ListLike | None = None, ordered: bool | None = None, dtype: Dtype | None = None, diff --git a/pandas-stubs/core/indexes/interval.pyi b/pandas-stubs/core/indexes/interval.pyi index c968845c8..2b196c15f 100644 --- a/pandas-stubs/core/indexes/interval.pyi +++ b/pandas-stubs/core/indexes/interval.pyi @@ -99,51 +99,51 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): def __new__( cls, data: Sequence[IntervalT], - closed: IntervalClosedType = ..., - dtype: IntervalDtype | None = ..., - copy: bool = ..., - name: Hashable = ..., - verify_integrity: bool = ..., + closed: IntervalClosedType | None = None, + dtype: IntervalDtype | None = None, + copy: bool = False, + name: Hashable = None, + verify_integrity: bool = True, ) -> IntervalIndex[IntervalT]: ... @overload @classmethod def from_breaks( # pyright: ignore[reportOverlappingOverload] cls, breaks: _EdgesInt, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType | None = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[int]]: ... @overload @classmethod def from_breaks( cls, breaks: _EdgesFloat, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType | None = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[float]]: ... @overload @classmethod def from_breaks( cls, breaks: _EdgesTimestamp, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType | None = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[pd.Timestamp]]: ... @overload @classmethod def from_breaks( cls, breaks: _EdgesTimedelta, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType | None = None, + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[pd.Timedelta]]: ... @overload @classmethod @@ -151,10 +151,10 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): cls, left: _EdgesInt, right: _EdgesInt, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[int]]: ... @overload @classmethod @@ -162,10 +162,10 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): cls, left: _EdgesFloat, right: _EdgesFloat, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[float]]: ... @overload @classmethod @@ -173,10 +173,10 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): cls, left: _EdgesTimestamp, right: _EdgesTimestamp, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[pd.Timestamp]]: ... @overload @classmethod @@ -184,20 +184,20 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): cls, left: _EdgesTimedelta, right: _EdgesTimedelta, - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[Interval[pd.Timedelta]]: ... @overload @classmethod def from_tuples( # pyright: ignore[reportOverlappingOverload] cls, data: Sequence[tuple[int, int]], - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[pd.Interval[int]]: ... # Ignore misc here due to intentional overlap between int and float @overload @@ -205,10 +205,10 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): def from_tuples( cls, data: Sequence[tuple[float, float]], - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[pd.Interval[float]]: ... @overload @classmethod @@ -219,10 +219,10 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): | tuple[dt.datetime, dt.datetime] | tuple[np.datetime64, np.datetime64] ], - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[pd.Interval[pd.Timestamp]]: ... @overload @classmethod @@ -233,10 +233,10 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin): | tuple[dt.timedelta, dt.timedelta] | tuple[np.timedelta64, np.timedelta64] ], - closed: IntervalClosedType = ..., - name: Hashable = ..., - copy: bool = ..., - dtype: IntervalDtype | None = ..., + closed: IntervalClosedType = "right", + name: Hashable = None, + copy: bool = False, + dtype: IntervalDtype | None = None, ) -> IntervalIndex[pd.Interval[pd.Timedelta]]: ... def to_tuples(self, na_tuple: bool = True) -> pd.Index: ... @overload diff --git a/pandas-stubs/core/indexes/timedeltas.pyi b/pandas-stubs/core/indexes/timedeltas.pyi index f9e0a17ed..0f3c9bc37 100644 --- a/pandas-stubs/core/indexes/timedeltas.pyi +++ b/pandas-stubs/core/indexes/timedeltas.pyi @@ -26,6 +26,7 @@ from typing_extensions import ( ) from pandas._libs import Timedelta +from pandas._libs.lib import _NoDefaultDoNotUse from pandas._libs.tslibs import BaseOffset from pandas._libs.tslibs.period import Period from pandas._typing import ( @@ -59,12 +60,13 @@ class TimedeltaIndex( ): def __new__( cls, - data: Sequence[timedelta | Timedelta | np.timedelta64 | float] | AxesData = ..., - freq: Frequency = ..., - closed: object = ..., - dtype: Literal[" Self: ... # various ignores needed for mypy, as we do want to restrict what can be used in # arithmetic for these types @@ -168,7 +170,7 @@ def timedelta_range( freq: Frequency | Timedelta | timedelta | None = None, name: Hashable | None = None, closed: Literal["left", "right"] | None = None, - unit: None | str = ..., + unit: None | str = None, ) -> TimedeltaIndex: ... @overload def timedelta_range( @@ -178,7 +180,7 @@ def timedelta_range( freq: Frequency | Timedelta | timedelta | None = None, name: Hashable | None = None, closed: Literal["left", "right"] | None = None, - unit: None | str = ..., + unit: None | str = None, ) -> TimedeltaIndex: ... @overload def timedelta_range( @@ -188,7 +190,7 @@ def timedelta_range( freq: Frequency | Timedelta | timedelta | None = None, name: Hashable | None = None, closed: Literal["left", "right"] | None = None, - unit: None | str = ..., + unit: None | str = None, ) -> TimedeltaIndex: ... @overload def timedelta_range( @@ -198,5 +200,5 @@ def timedelta_range( *, name: Hashable | None = None, closed: Literal["left", "right"] | None = None, - unit: None | str = ..., + unit: None | str = None, ) -> TimedeltaIndex: ... From 539c8812bc2e2880cdd6d6368bf7fc681c8d5c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Diridollou?= Date: Thu, 18 Dec 2025 17:15:07 -0500 Subject: [PATCH 2/2] GH1318 Add defaults to pandas/core/arrays --- pandas-stubs/core/arrays/boolean.pyi | 6 +- pandas-stubs/core/arrays/masked.pyi | 4 +- pandas-stubs/core/arrays/sparse/array.pyi | 16 ++- pandas-stubs/core/arrays/sparse/dtype.pyi | 4 +- pandas-stubs/core/indexes/base.pyi | 160 ++++++++++------------ pandas-stubs/core/indexes/multi.pyi | 32 ++--- 6 files changed, 108 insertions(+), 114 deletions(-) diff --git a/pandas-stubs/core/arrays/boolean.pyi b/pandas-stubs/core/arrays/boolean.pyi index 478ef8f9a..59e89c33e 100644 --- a/pandas-stubs/core/arrays/boolean.pyi +++ b/pandas-stubs/core/arrays/boolean.pyi @@ -22,13 +22,13 @@ class BooleanDtype(ExtensionDtype): class BooleanArray(BaseMaskedArray): def __init__( - self, values: np_ndarray_bool, mask: np_ndarray_bool, copy: bool = ... + self, values: np_ndarray_bool, mask: np_ndarray_bool, copy: bool = False ) -> None: ... @property def dtype(self): ... def __setitem__(self, key, value) -> None: ... - def any(self, *, skipna: bool = ..., **kwargs: Any): ... - def all(self, *, skipna: bool = ..., **kwargs: Any): ... + def any(self, *, skipna: bool = True, **kwargs: Any): ... + def all(self, *, skipna: bool = True, **kwargs: Any): ... def __and__( self, other: ( diff --git a/pandas-stubs/core/arrays/masked.pyi b/pandas-stubs/core/arrays/masked.pyi index 89bf39012..5c0376b26 100644 --- a/pandas-stubs/core/arrays/masked.pyi +++ b/pandas-stubs/core/arrays/masked.pyi @@ -27,11 +27,11 @@ class BaseMaskedArray(ExtensionArray, ExtensionOpsMixin): def __invert__(self): ... def to_numpy( self, - dtype: npt.DTypeLike | None = ..., + dtype: npt.DTypeLike | None = None, copy: bool = False, na_value: Scalar = ..., ) -> np_1darray: ... - __array_priority__: int = ... + __array_priority__: int = 1000 def __array__( self, dtype: NpDtype | None = None, copy: bool | None = None ) -> np_1darray: ... diff --git a/pandas-stubs/core/arrays/sparse/array.pyi b/pandas-stubs/core/arrays/sparse/array.pyi index b10e64059..7a9aae767 100644 --- a/pandas-stubs/core/arrays/sparse/array.pyi +++ b/pandas-stubs/core/arrays/sparse/array.pyi @@ -12,6 +12,8 @@ from pandas.core.arrays import ( from typing_extensions import Self from pandas._typing import ( + AxisInt, + DtypeArg, NpDtype, ScalarIndexer, SequenceIndexer, @@ -28,9 +30,9 @@ class SparseArray(ExtensionArray, ExtensionOpsMixin): data, sparse_index=..., fill_value=..., - kind: str = ..., - dtype=..., - copy: bool = ..., + kind: str = "integer", + dtype: DtypeArg | None = None, + copy: bool = False, ) -> None: ... @classmethod def from_spmatrix(cls, data) -> Self: ... @@ -73,10 +75,10 @@ class SparseArray(ExtensionArray, ExtensionOpsMixin): def to_dense(self): ... def nonzero(self): ... def all(self, axis=..., *args: Any, **kwargs: Any): ... - def any(self, axis: int = ..., *args: Any, **kwargs: Any): ... - def sum(self, axis: int = 0, *args: Any, **kwargs: Any): ... - def cumsum(self, axis: int = ..., *args: Any, **kwargs: Any): ... - def mean(self, axis: int = ..., *args: Any, **kwargs: Any): ... + def any(self, axis: AxisInt = 0, *args: Any, **kwargs: Any): ... + def sum(self, axis: AxisInt = 0, *args: Any, **kwargs: Any): ... + def cumsum(self, axis: AxisInt = 0, *args: Any, **kwargs: Any): ... + def mean(self, axis: AxisInt = 0, *args: Any, **kwargs: Any): ... @property def T(self): ... def __abs__(self): ... diff --git a/pandas-stubs/core/arrays/sparse/dtype.pyi b/pandas-stubs/core/arrays/sparse/dtype.pyi index 23b736e3b..290470d18 100644 --- a/pandas-stubs/core/arrays/sparse/dtype.pyi +++ b/pandas-stubs/core/arrays/sparse/dtype.pyi @@ -11,7 +11,9 @@ from pandas.core.dtypes.dtypes import ( class SparseDtype(ExtensionDtype): def __init__( - self, dtype: Dtype | npt.DTypeLike = ..., fill_value: Scalar | None = ... + self, + dtype: Dtype | npt.DTypeLike = ..., + fill_value: Scalar | None = None, ) -> None: ... @property def fill_value(self) -> Scalar | None: ... diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index 2a409930b..c91d57afb 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -154,20 +154,20 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): cls, data: Sequence[bool | np.bool_] | IndexOpsMixin[bool] | np_ndarray_bool, *, - dtype: Literal["bool"] | type_t[bool | np.bool_] = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: Literal["bool"] | type_t[bool | np.bool_] | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[bool]: ... @overload def __new__( cls, data: Sequence[int | np.integer] | IndexOpsMixin[int] | np_ndarray_anyint, *, - dtype: Literal["int"] | type_t[int | np.integer] = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: Literal["int"] | type_t[int | np.integer] | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[int]: ... @overload def __new__( @@ -175,27 +175,27 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: Literal["int"] | type_t[int | np.integer], - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[int]: ... @overload def __new__( cls, data: Sequence[float | np.floating] | np_ndarray_float | FloatingArray, dtype: None = None, - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[float]: ... @overload def __new__( cls, data: AxesData, dtype: FloatNotNumpy16DtypeArg, - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[float]: ... @overload def __new__( @@ -206,10 +206,10 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): | np_ndarray_complex ), *, - dtype: Literal["complex"] | type_t[complex | np.complexfloating] = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: Literal["complex"] | type_t[complex | np.complexfloating] | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[complex]: ... @overload def __new__( @@ -217,9 +217,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: Literal["complex"] | type_t[complex | np.complexfloating], - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Index[complex]: ... # special overloads with dedicated Index-subclasses @overload @@ -229,10 +229,10 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): Sequence[np.datetime64 | datetime] | IndexOpsMixin[datetime] | DatetimeIndex ), *, - dtype: TimestampDtypeArg = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: TimestampDtypeArg | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> DatetimeIndex: ... @overload def __new__( @@ -240,19 +240,19 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: TimestampDtypeArg, - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> DatetimeIndex: ... @overload def __new__( cls, data: Sequence[Period] | IndexOpsMixin[Period], *, - dtype: PeriodDtype = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: PeriodDtype | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> PeriodIndex: ... @overload def __new__( @@ -260,19 +260,19 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: PeriodDtype, - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> PeriodIndex: ... @overload def __new__( cls, data: Sequence[np.timedelta64 | timedelta] | IndexOpsMixin[timedelta], *, - dtype: TimedeltaDtypeArg = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: TimedeltaDtypeArg | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> TimedeltaIndex: ... @overload def __new__( @@ -280,9 +280,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: TimedeltaDtypeArg, - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> TimedeltaIndex: ... @overload def __new__( @@ -290,19 +290,19 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: CategoryDtypeArg, - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> CategoricalIndex: ... @overload def __new__( cls, data: Sequence[Interval[_OrderableT]] | IndexOpsMixin[Interval[_OrderableT]], *, - dtype: Literal["Interval"] = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: Literal["Interval"] | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> IntervalIndex[Interval[_OrderableT]]: ... @overload def __new__( @@ -310,40 +310,30 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): data: AxesData, *, dtype: Literal["Interval"], - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> IntervalIndex[Interval[Any]]: ... - @overload - def __new__( - cls, - data: DatetimeIndex, - *, - dtype: TimestampDtypeArg | None = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., - ) -> DatetimeIndex: ... # generic overloads @overload def __new__( cls, data: Iterable[S1] | IndexOpsMixin[S1], *, - dtype: type[S1] = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: type[S1] | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Self: ... @overload def __new__( cls, - data: AxesData = ..., + data: AxesData | None = None, *, dtype: type[S1], - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Self: ... # fallback overload @overload @@ -351,10 +341,10 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): cls, data: AxesData, *, - dtype: Dtype = ..., - copy: bool = ..., - name: Hashable = ..., - tupleize_cols: bool = ..., + dtype: Dtype | None = None, + copy: bool = False, + name: Hashable = None, + tupleize_cols: bool = True, ) -> Self: ... @property def str( @@ -374,11 +364,11 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): def __len__(self) -> int: ... if sys.version_info >= (3, 11): def __array__( - self, dtype: _str | np.dtype = ..., copy: bool | None = ... + self, dtype: _str | np.dtype | None = None, copy: bool | None = None ) -> np_1darray: ... else: def __array__( - self, dtype: _str | np.dtype[Any] = ..., copy: bool | None = ... + self, dtype: _str | np.dtype[Any] | None = None, copy: bool | None = None ) -> np_1darray: ... @property @@ -413,12 +403,12 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): def repeat( self, repeats: int | AnyArrayLikeInt | Sequence[int], axis: None = None ) -> Self: ... - def copy(self, name: Hashable = ..., deep: bool = False) -> Self: ... + def copy(self, name: Hashable = None, deep: bool = False) -> Self: ... def format( self, - name: bool = ..., - formatter: Callable[..., Any] | None = ..., - na_rep: _str = ..., + name: bool = False, + formatter: Callable[..., Any] | None = None, + na_rep: _str = "NaN", ) -> list[_str]: ... def to_series( self, index: Index | None = None, name: Hashable | None = None @@ -466,7 +456,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): def fillna(self, value: Scalar) -> Index: ... def dropna(self, how: AnyAll = "any") -> Self: ... def unique(self, level: Hashable | None = None) -> Self: ... - def drop_duplicates(self, *, keep: DropKeep = ...) -> Self: ... + def drop_duplicates(self, *, keep: DropKeep = "first") -> Self: ... def duplicated(self, keep: DropKeep = "first") -> np_1darray_bool: ... def __and__(self, other: Never) -> Never: ... def __rand__(self, other: Never) -> Never: ... @@ -488,7 +478,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): def symmetric_difference( self, other: list[S1] | Self, - result_name: Hashable = ..., + result_name: Hashable = None, sort: bool | None = None, ) -> Self: ... def get_loc(self, key: Label) -> int | slice | np_1darray_bool: ... diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index b7de51d47..2f720f92b 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -41,41 +41,41 @@ from pandas._typing import ( class MultiIndex(Index): def __new__( cls, - levels: Sequence[SequenceNotStr[Hashable]] = ..., - codes: Sequence[Sequence[int]] = ..., - sortorder: int | None = ..., - names: SequenceNotStr[Hashable] = ..., - copy: bool = ..., - name: SequenceNotStr[Hashable] = ..., - verify_integrity: bool = ..., + levels: Sequence[SequenceNotStr[Hashable]] | None = None, + codes: Sequence[Sequence[int]] | None = None, + sortorder: int | None = None, + names: SequenceNotStr[Hashable] | None = None, + copy: bool = False, + name: SequenceNotStr[Hashable] | None = None, + verify_integrity: bool = True, ) -> Self: ... @classmethod def from_arrays( cls, arrays: Sequence[Axes], - sortorder: int | None = ..., - names: SequenceNotStr[Hashable] = ..., + sortorder: int | None = None, + names: SequenceNotStr[Hashable] | None = None, ) -> Self: ... @classmethod def from_tuples( cls, tuples: Iterable[tuple[Hashable, ...]], - sortorder: int | None = ..., - names: SequenceNotStr[Hashable] = ..., + sortorder: int | None = None, + names: SequenceNotStr[Hashable] | None = None, ) -> Self: ... @classmethod def from_product( cls, iterables: Sequence[SequenceNotStr[Hashable] | pd.Series | pd.Index | range], - sortorder: int | None = ..., - names: SequenceNotStr[Hashable] = ..., + sortorder: int | None = None, + names: SequenceNotStr[Hashable] | None = None, ) -> Self: ... @classmethod def from_frame( cls, df: pd.DataFrame, - sortorder: int | None = ..., - names: SequenceNotStr[Hashable] = ..., + sortorder: int | None = None, + names: SequenceNotStr[Hashable] | None = None, ) -> Self: ... @property # Should be read-only def levels(self) -> list[Index]: ... @@ -114,7 +114,7 @@ class MultiIndex(Index): verify_integrity: bool = True, ) -> MultiIndex: ... def copy( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore - self, names: SequenceNotStr[Hashable] = ..., deep: bool = False + self, names: SequenceNotStr[Hashable] | None = None, deep: bool = False ) -> Self: ... def view(self, cls: NumpyNotTimeDtypeArg | NumpyTimedeltaDtypeArg | NumpyTimestampDtypeArg | type[np_ndarray] | None = None) -> MultiIndex: ... # type: ignore[override] # pyrefly: ignore[bad-override] # pyright: ignore[reportIncompatibleMethodOverride] if sys.version_info >= (3, 11):