Skip to content

Commit 9c49879

Browse files
GH851 Change use of NoDefault to make it more private (#1262)
* GH851 Change use of NoDefault to make it more private * GH851 Change use of NoDefault to make it more private
1 parent 3d14748 commit 9c49879

File tree

18 files changed

+119
-107
lines changed

18 files changed

+119
-107
lines changed

pandas-stubs/_libs/lib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class _NoDefault(Enum):
1414
no_default = ...
1515

1616
no_default: Final = _NoDefault.no_default
17-
NoDefault: TypeAlias = Literal[_NoDefault.no_default]
17+
_NoDefaultDoNotUse: TypeAlias = Literal[_NoDefault.no_default] # noqa: PYI047
1818

1919
def infer_dtype(value: object, skipna: bool = ...) -> str: ...
2020
def is_iterator(obj: object) -> bool: ...

pandas-stubs/api/typing/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ from pandas.core.window import (
2121
)
2222

2323
from pandas._libs import NaTType as NaTType
24-
from pandas._libs.lib import NoDefault as NoDefault
24+
from pandas._libs.lib import _NoDefaultDoNotUse as _NoDefaultDoNotUse
2525
from pandas._libs.missing import NAType as NAType
2626

2727
from pandas.io.json._json import JsonReader as JsonReader

pandas-stubs/core/frame.pyi

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ from typing_extensions import (
7272
)
7373
import xarray as xr
7474

75-
from pandas._libs.lib import NoDefault
75+
from pandas._libs.lib import _NoDefaultDoNotUse
7676
from pandas._libs.missing import NAType
7777
from pandas._libs.tslibs import BaseOffset
7878
from pandas._libs.tslibs.nattype import NaTType
@@ -1107,192 +1107,192 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
11071107
def groupby( # pyright: ignore reportOverlappingOverload
11081108
self,
11091109
by: Scalar,
1110-
axis: AxisIndex | NoDefault = ...,
1110+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11111111
level: IndexLabel | None = ...,
11121112
as_index: Literal[True] = True,
11131113
sort: _bool = ...,
11141114
group_keys: _bool = ...,
1115-
observed: _bool | NoDefault = ...,
1115+
observed: _bool | _NoDefaultDoNotUse = ...,
11161116
dropna: _bool = ...,
11171117
) -> DataFrameGroupBy[Scalar, Literal[True]]: ...
11181118
@overload
11191119
def groupby(
11201120
self,
11211121
by: Scalar,
1122-
axis: AxisIndex | NoDefault = ...,
1122+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11231123
level: IndexLabel | None = ...,
11241124
as_index: Literal[False] = ...,
11251125
sort: _bool = ...,
11261126
group_keys: _bool = ...,
1127-
observed: _bool | NoDefault = ...,
1127+
observed: _bool | _NoDefaultDoNotUse = ...,
11281128
dropna: _bool = ...,
11291129
) -> DataFrameGroupBy[Scalar, Literal[False]]: ...
11301130
@overload
11311131
def groupby( # pyright: ignore reportOverlappingOverload
11321132
self,
11331133
by: DatetimeIndex,
1134-
axis: AxisIndex | NoDefault = ...,
1134+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11351135
level: IndexLabel | None = ...,
11361136
as_index: Literal[True] = True,
11371137
sort: _bool = ...,
11381138
group_keys: _bool = ...,
1139-
observed: _bool | NoDefault = ...,
1139+
observed: _bool | _NoDefaultDoNotUse = ...,
11401140
dropna: _bool = ...,
11411141
) -> DataFrameGroupBy[Timestamp, Literal[True]]: ...
11421142
@overload
11431143
def groupby( # pyright: ignore reportOverlappingOverload
11441144
self,
11451145
by: DatetimeIndex,
1146-
axis: AxisIndex | NoDefault = ...,
1146+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11471147
level: IndexLabel | None = ...,
11481148
as_index: Literal[False] = ...,
11491149
sort: _bool = ...,
11501150
group_keys: _bool = ...,
1151-
observed: _bool | NoDefault = ...,
1151+
observed: _bool | _NoDefaultDoNotUse = ...,
11521152
dropna: _bool = ...,
11531153
) -> DataFrameGroupBy[Timestamp, Literal[False]]: ...
11541154
@overload
11551155
def groupby( # pyright: ignore reportOverlappingOverload
11561156
self,
11571157
by: TimedeltaIndex,
1158-
axis: AxisIndex | NoDefault = ...,
1158+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11591159
level: IndexLabel | None = ...,
11601160
as_index: Literal[True] = True,
11611161
sort: _bool = ...,
11621162
group_keys: _bool = ...,
1163-
observed: _bool | NoDefault = ...,
1163+
observed: _bool | _NoDefaultDoNotUse = ...,
11641164
dropna: _bool = ...,
11651165
) -> DataFrameGroupBy[Timedelta, Literal[True]]: ...
11661166
@overload
11671167
def groupby(
11681168
self,
11691169
by: TimedeltaIndex,
1170-
axis: AxisIndex | NoDefault = ...,
1170+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11711171
level: IndexLabel | None = ...,
11721172
as_index: Literal[False] = ...,
11731173
sort: _bool = ...,
11741174
group_keys: _bool = ...,
1175-
observed: _bool | NoDefault = ...,
1175+
observed: _bool | _NoDefaultDoNotUse = ...,
11761176
dropna: _bool = ...,
11771177
) -> DataFrameGroupBy[Timedelta, Literal[False]]: ...
11781178
@overload
11791179
def groupby( # pyright: ignore reportOverlappingOverload
11801180
self,
11811181
by: PeriodIndex,
1182-
axis: AxisIndex | NoDefault = ...,
1182+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11831183
level: IndexLabel | None = ...,
11841184
as_index: Literal[True] = True,
11851185
sort: _bool = ...,
11861186
group_keys: _bool = ...,
1187-
observed: _bool | NoDefault = ...,
1187+
observed: _bool | _NoDefaultDoNotUse = ...,
11881188
dropna: _bool = ...,
11891189
) -> DataFrameGroupBy[Period, Literal[True]]: ...
11901190
@overload
11911191
def groupby(
11921192
self,
11931193
by: PeriodIndex,
1194-
axis: AxisIndex | NoDefault = ...,
1194+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
11951195
level: IndexLabel | None = ...,
11961196
as_index: Literal[False] = ...,
11971197
sort: _bool = ...,
11981198
group_keys: _bool = ...,
1199-
observed: _bool | NoDefault = ...,
1199+
observed: _bool | _NoDefaultDoNotUse = ...,
12001200
dropna: _bool = ...,
12011201
) -> DataFrameGroupBy[Period, Literal[False]]: ...
12021202
@overload
12031203
def groupby( # pyright: ignore reportOverlappingOverload
12041204
self,
12051205
by: IntervalIndex[IntervalT],
1206-
axis: AxisIndex | NoDefault = ...,
1206+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12071207
level: IndexLabel | None = ...,
12081208
as_index: Literal[True] = True,
12091209
sort: _bool = ...,
12101210
group_keys: _bool = ...,
1211-
observed: _bool | NoDefault = ...,
1211+
observed: _bool | _NoDefaultDoNotUse = ...,
12121212
dropna: _bool = ...,
12131213
) -> DataFrameGroupBy[IntervalT, Literal[True]]: ...
12141214
@overload
12151215
def groupby(
12161216
self,
12171217
by: IntervalIndex[IntervalT],
1218-
axis: AxisIndex | NoDefault = ...,
1218+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12191219
level: IndexLabel | None = ...,
12201220
as_index: Literal[False] = ...,
12211221
sort: _bool = ...,
12221222
group_keys: _bool = ...,
1223-
observed: _bool | NoDefault = ...,
1223+
observed: _bool | _NoDefaultDoNotUse = ...,
12241224
dropna: _bool = ...,
12251225
) -> DataFrameGroupBy[IntervalT, Literal[False]]: ...
12261226
@overload
12271227
def groupby( # type: ignore[overload-overlap] # pyright: ignore reportOverlappingOverload
12281228
self,
12291229
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1230-
axis: AxisIndex | NoDefault = ...,
1230+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12311231
level: IndexLabel | None = ...,
12321232
as_index: Literal[True] = True,
12331233
sort: _bool = ...,
12341234
group_keys: _bool = ...,
1235-
observed: _bool | NoDefault = ...,
1235+
observed: _bool | _NoDefaultDoNotUse = ...,
12361236
dropna: _bool = ...,
12371237
) -> DataFrameGroupBy[tuple, Literal[True]]: ...
12381238
@overload
12391239
def groupby( # type: ignore[overload-overlap]
12401240
self,
12411241
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1242-
axis: AxisIndex | NoDefault = ...,
1242+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12431243
level: IndexLabel | None = ...,
12441244
as_index: Literal[False] = ...,
12451245
sort: _bool = ...,
12461246
group_keys: _bool = ...,
1247-
observed: _bool | NoDefault = ...,
1247+
observed: _bool | _NoDefaultDoNotUse = ...,
12481248
dropna: _bool = ...,
12491249
) -> DataFrameGroupBy[tuple, Literal[False]]: ...
12501250
@overload
12511251
def groupby( # pyright: ignore reportOverlappingOverload
12521252
self,
12531253
by: Series[SeriesByT],
1254-
axis: AxisIndex | NoDefault = ...,
1254+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12551255
level: IndexLabel | None = ...,
12561256
as_index: Literal[True] = True,
12571257
sort: _bool = ...,
12581258
group_keys: _bool = ...,
1259-
observed: _bool | NoDefault = ...,
1259+
observed: _bool | _NoDefaultDoNotUse = ...,
12601260
dropna: _bool = ...,
12611261
) -> DataFrameGroupBy[SeriesByT, Literal[True]]: ...
12621262
@overload
12631263
def groupby(
12641264
self,
12651265
by: Series[SeriesByT],
1266-
axis: AxisIndex | NoDefault = ...,
1266+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12671267
level: IndexLabel | None = ...,
12681268
as_index: Literal[False] = ...,
12691269
sort: _bool = ...,
12701270
group_keys: _bool = ...,
1271-
observed: _bool | NoDefault = ...,
1271+
observed: _bool | _NoDefaultDoNotUse = ...,
12721272
dropna: _bool = ...,
12731273
) -> DataFrameGroupBy[SeriesByT, Literal[False]]: ...
12741274
@overload
12751275
def groupby(
12761276
self,
12771277
by: CategoricalIndex | Index | Series,
1278-
axis: AxisIndex | NoDefault = ...,
1278+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12791279
level: IndexLabel | None = ...,
12801280
as_index: Literal[True] = True,
12811281
sort: _bool = ...,
12821282
group_keys: _bool = ...,
1283-
observed: _bool | NoDefault = ...,
1283+
observed: _bool | _NoDefaultDoNotUse = ...,
12841284
dropna: _bool = ...,
12851285
) -> DataFrameGroupBy[Any, Literal[True]]: ...
12861286
@overload
12871287
def groupby(
12881288
self,
12891289
by: CategoricalIndex | Index | Series,
1290-
axis: AxisIndex | NoDefault = ...,
1290+
axis: AxisIndex | _NoDefaultDoNotUse = ...,
12911291
level: IndexLabel | None = ...,
12921292
as_index: Literal[False] = ...,
12931293
sort: _bool = ...,
12941294
group_keys: _bool = ...,
1295-
observed: _bool | NoDefault = ...,
1295+
observed: _bool | _NoDefaultDoNotUse = ...,
12961296
dropna: _bool = ...,
12971297
) -> DataFrameGroupBy[Any, Literal[False]]: ...
12981298
def pivot(

pandas-stubs/core/generic.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ from typing_extensions import (
3232
Self,
3333
)
3434

35-
from pandas._libs.lib import NoDefault
35+
from pandas._libs.lib import _NoDefaultDoNotUse
3636
from pandas._typing import (
3737
Axis,
3838
CompressionOptions,
@@ -404,7 +404,7 @@ class NDFrame(indexing.IndexingMixin):
404404
def resample(
405405
self,
406406
rule: Frequency | dt.timedelta,
407-
axis: Axis | NoDefault = ...,
407+
axis: Axis | _NoDefaultDoNotUse = ...,
408408
closed: Literal["right", "left"] | None = ...,
409409
label: Literal["right", "left"] | None = ...,
410410
convention: ToTimestampHow = ...,

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ from typing_extensions import (
4646
TypeAlias,
4747
)
4848

49-
from pandas._libs.lib import NoDefault
49+
from pandas._libs.lib import _NoDefaultDoNotUse
5050
from pandas._libs.tslibs import BaseOffset
5151
from pandas._typing import (
5252
S1,
@@ -283,39 +283,51 @@ class GroupBy(BaseGroupBy[NDFrameT]):
283283
ascending: bool = ...,
284284
na_option: str = ...,
285285
pct: bool = ...,
286-
axis: AxisInt | NoDefault = ...,
286+
axis: AxisInt | _NoDefaultDoNotUse = ...,
287287
) -> NDFrameT: ...
288288
@final
289-
def cumprod(self, axis: Axis | NoDefault = ..., *args, **kwargs) -> NDFrameT: ...
289+
def cumprod(
290+
self, axis: Axis | _NoDefaultDoNotUse = ..., *args, **kwargs
291+
) -> NDFrameT: ...
290292
@final
291-
def cumsum(self, axis: Axis | NoDefault = ..., *args, **kwargs) -> NDFrameT: ...
293+
def cumsum(
294+
self, axis: Axis | _NoDefaultDoNotUse = ..., *args, **kwargs
295+
) -> NDFrameT: ...
292296
@final
293297
def cummin(
294-
self, axis: AxisInt | NoDefault = ..., numeric_only: bool = ..., **kwargs
298+
self,
299+
axis: AxisInt | _NoDefaultDoNotUse = ...,
300+
numeric_only: bool = ...,
301+
**kwargs,
295302
) -> NDFrameT: ...
296303
@final
297304
def cummax(
298-
self, axis: AxisInt | NoDefault = ..., numeric_only: bool = ..., **kwargs
305+
self,
306+
axis: AxisInt | _NoDefaultDoNotUse = ...,
307+
numeric_only: bool = ...,
308+
**kwargs,
299309
) -> NDFrameT: ...
300310
@final
301311
def shift(
302312
self,
303313
periods: int | Sequence[int] = ...,
304314
freq: Frequency | None = ...,
305-
axis: Axis | NoDefault = ...,
315+
axis: Axis | _NoDefaultDoNotUse = ...,
306316
fill_value=...,
307317
suffix: str | None = ...,
308318
) -> NDFrameT: ...
309319
@final
310-
def diff(self, periods: int = ..., axis: AxisInt | NoDefault = ...) -> NDFrameT: ...
320+
def diff(
321+
self, periods: int = ..., axis: AxisInt | _NoDefaultDoNotUse = ...
322+
) -> NDFrameT: ...
311323
@final
312324
def pct_change(
313325
self,
314326
periods: int = ...,
315-
fill_method: Literal["bfill", "ffill"] | None | NoDefault = ...,
316-
limit: int | None | NoDefault = ...,
327+
fill_method: Literal["bfill", "ffill"] | None | _NoDefaultDoNotUse = ...,
328+
limit: int | None | _NoDefaultDoNotUse = ...,
317329
freq=...,
318-
axis: Axis | NoDefault = ...,
330+
axis: Axis | _NoDefaultDoNotUse = ...,
319331
) -> NDFrameT: ...
320332
@final
321333
def head(self, n: int = ...) -> NDFrameT: ...

pandas-stubs/core/groupby/grouper.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ from pandas import (
1616
from pandas.core.resample import TimeGrouper
1717
from typing_extensions import Self
1818

19-
from pandas._libs.lib import NoDefault
19+
from pandas._libs.lib import _NoDefaultDoNotUse
2020
from pandas._typing import (
2121
ArrayLike,
2222
Axis,
@@ -42,7 +42,7 @@ class Grouper:
4242
cls,
4343
key: KeysArgType | None = ...,
4444
level: Level | ListLikeHashable[Level] | None = ...,
45-
axis: Axis | NoDefault = ...,
45+
axis: Axis | _NoDefaultDoNotUse = ...,
4646
sort: bool = ...,
4747
dropna: bool = ...,
4848
) -> Self: ...

0 commit comments

Comments
 (0)