Skip to content

GH851 Change use of NoDefault to make it more private #1262

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 2 commits into from
Jun 25, 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
2 changes: 1 addition & 1 deletion pandas-stubs/_libs/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class _NoDefault(Enum):
no_default = ...

no_default: Final = _NoDefault.no_default
NoDefault: TypeAlias = Literal[_NoDefault.no_default]
_NoDefaultDoNotUse: TypeAlias = Literal[_NoDefault.no_default] # noqa: PYI047

def infer_dtype(value: object, skipna: bool = ...) -> str: ...
def is_iterator(obj: object) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/api/typing/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from pandas.core.window import (
)

from pandas._libs import NaTType as NaTType
from pandas._libs.lib import NoDefault as NoDefault
from pandas._libs.lib import _NoDefaultDoNotUse as _NoDefaultDoNotUse
from pandas._libs.missing import NAType as NAType

from pandas.io.json._json import JsonReader as JsonReader
Expand Down
66 changes: 33 additions & 33 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ from typing_extensions import (
)
import xarray as xr

from pandas._libs.lib import NoDefault
from pandas._libs.lib import _NoDefaultDoNotUse
from pandas._libs.missing import NAType
from pandas._libs.tslibs import BaseOffset
from pandas._libs.tslibs.nattype import NaTType
Expand Down Expand Up @@ -1107,192 +1107,192 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: Scalar,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Scalar, Literal[True]]: ...
@overload
def groupby(
self,
by: Scalar,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Scalar, Literal[False]]: ...
@overload
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: DatetimeIndex,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Timestamp, Literal[True]]: ...
@overload
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: DatetimeIndex,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Timestamp, Literal[False]]: ...
@overload
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: TimedeltaIndex,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Timedelta, Literal[True]]: ...
@overload
def groupby(
self,
by: TimedeltaIndex,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Timedelta, Literal[False]]: ...
@overload
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: PeriodIndex,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Period, Literal[True]]: ...
@overload
def groupby(
self,
by: PeriodIndex,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Period, Literal[False]]: ...
@overload
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: IntervalIndex[IntervalT],
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[IntervalT, Literal[True]]: ...
@overload
def groupby(
self,
by: IntervalIndex[IntervalT],
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[IntervalT, Literal[False]]: ...
@overload
def groupby( # type: ignore[overload-overlap] # pyright: ignore reportOverlappingOverload
self,
by: MultiIndex | GroupByObjectNonScalar | None = ...,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[tuple, Literal[True]]: ...
@overload
def groupby( # type: ignore[overload-overlap]
self,
by: MultiIndex | GroupByObjectNonScalar | None = ...,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[tuple, Literal[False]]: ...
@overload
def groupby( # pyright: ignore reportOverlappingOverload
self,
by: Series[SeriesByT],
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[SeriesByT, Literal[True]]: ...
@overload
def groupby(
self,
by: Series[SeriesByT],
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[SeriesByT, Literal[False]]: ...
@overload
def groupby(
self,
by: CategoricalIndex | Index | Series,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Any, Literal[True]]: ...
@overload
def groupby(
self,
by: CategoricalIndex | Index | Series,
axis: AxisIndex | NoDefault = ...,
axis: AxisIndex | _NoDefaultDoNotUse = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = ...,
sort: _bool = ...,
group_keys: _bool = ...,
observed: _bool | NoDefault = ...,
observed: _bool | _NoDefaultDoNotUse = ...,
dropna: _bool = ...,
) -> DataFrameGroupBy[Any, Literal[False]]: ...
def pivot(
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ from typing_extensions import (
Self,
)

from pandas._libs.lib import NoDefault
from pandas._libs.lib import _NoDefaultDoNotUse
from pandas._typing import (
Axis,
CompressionOptions,
Expand Down Expand Up @@ -404,7 +404,7 @@ class NDFrame(indexing.IndexingMixin):
def resample(
self,
rule: Frequency | dt.timedelta,
axis: Axis | NoDefault = ...,
axis: Axis | _NoDefaultDoNotUse = ...,
closed: Literal["right", "left"] | None = ...,
label: Literal["right", "left"] | None = ...,
convention: ToTimestampHow = ...,
Expand Down
34 changes: 23 additions & 11 deletions pandas-stubs/core/groupby/groupby.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ from typing_extensions import (
TypeAlias,
)

from pandas._libs.lib import NoDefault
from pandas._libs.lib import _NoDefaultDoNotUse
from pandas._libs.tslibs import BaseOffset
from pandas._typing import (
S1,
Expand Down Expand Up @@ -283,39 +283,51 @@ class GroupBy(BaseGroupBy[NDFrameT]):
ascending: bool = ...,
na_option: str = ...,
pct: bool = ...,
axis: AxisInt | NoDefault = ...,
axis: AxisInt | _NoDefaultDoNotUse = ...,
) -> NDFrameT: ...
@final
def cumprod(self, axis: Axis | NoDefault = ..., *args, **kwargs) -> NDFrameT: ...
def cumprod(
self, axis: Axis | _NoDefaultDoNotUse = ..., *args, **kwargs
) -> NDFrameT: ...
@final
def cumsum(self, axis: Axis | NoDefault = ..., *args, **kwargs) -> NDFrameT: ...
def cumsum(
self, axis: Axis | _NoDefaultDoNotUse = ..., *args, **kwargs
) -> NDFrameT: ...
@final
def cummin(
self, axis: AxisInt | NoDefault = ..., numeric_only: bool = ..., **kwargs
self,
axis: AxisInt | _NoDefaultDoNotUse = ...,
numeric_only: bool = ...,
**kwargs,
) -> NDFrameT: ...
@final
def cummax(
self, axis: AxisInt | NoDefault = ..., numeric_only: bool = ..., **kwargs
self,
axis: AxisInt | _NoDefaultDoNotUse = ...,
numeric_only: bool = ...,
**kwargs,
) -> NDFrameT: ...
@final
def shift(
self,
periods: int | Sequence[int] = ...,
freq: Frequency | None = ...,
axis: Axis | NoDefault = ...,
axis: Axis | _NoDefaultDoNotUse = ...,
fill_value=...,
suffix: str | None = ...,
) -> NDFrameT: ...
@final
def diff(self, periods: int = ..., axis: AxisInt | NoDefault = ...) -> NDFrameT: ...
def diff(
self, periods: int = ..., axis: AxisInt | _NoDefaultDoNotUse = ...
) -> NDFrameT: ...
@final
def pct_change(
self,
periods: int = ...,
fill_method: Literal["bfill", "ffill"] | None | NoDefault = ...,
limit: int | None | NoDefault = ...,
fill_method: Literal["bfill", "ffill"] | None | _NoDefaultDoNotUse = ...,
limit: int | None | _NoDefaultDoNotUse = ...,
freq=...,
axis: Axis | NoDefault = ...,
axis: Axis | _NoDefaultDoNotUse = ...,
) -> NDFrameT: ...
@final
def head(self, n: int = ...) -> NDFrameT: ...
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/groupby/grouper.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from pandas import (
from pandas.core.resample import TimeGrouper
from typing_extensions import Self

from pandas._libs.lib import NoDefault
from pandas._libs.lib import _NoDefaultDoNotUse
from pandas._typing import (
ArrayLike,
Axis,
Expand All @@ -42,7 +42,7 @@ class Grouper:
cls,
key: KeysArgType | None = ...,
level: Level | ListLikeHashable[Level] | None = ...,
axis: Axis | NoDefault = ...,
axis: Axis | _NoDefaultDoNotUse = ...,
sort: bool = ...,
dropna: bool = ...,
) -> Self: ...
Expand Down
Loading