Skip to content

Commit caea863

Browse files
committed
remove changes that created aliases with leading underscore
1 parent cce8d9a commit caea863

File tree

10 files changed

+68
-71
lines changed

10 files changed

+68
-71
lines changed

pandas/core/apply.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
from pandas.core.resample import Resampler
7373
from pandas.core.window.rolling import BaseWindow
7474

75-
_ResType: TypeAlias = dict[int, Any]
75+
ResType: TypeAlias = dict[int, Any]
7676

7777

7878
class BaseExecutionEngine(abc.ABC):
@@ -935,7 +935,7 @@ def validate_values_for_numba(self) -> None:
935935

936936
@abc.abstractmethod
937937
def wrap_results_for_axis(
938-
self, results: _ResType, res_index: Index
938+
self, results: ResType, res_index: Index
939939
) -> DataFrame | Series:
940940
pass
941941

@@ -1164,7 +1164,7 @@ def apply_standard(self):
11641164
# wrap results
11651165
return self.wrap_results(results, res_index)
11661166

1167-
def apply_series_generator(self) -> tuple[_ResType, Index]:
1167+
def apply_series_generator(self) -> tuple[ResType, Index]:
11681168
assert callable(self.func)
11691169

11701170
series_gen = self.series_generator
@@ -1194,7 +1194,7 @@ def apply_series_numba(self):
11941194
results = self.apply_with_numba()
11951195
return results, self.result_index
11961196

1197-
def wrap_results(self, results: _ResType, res_index: Index) -> DataFrame | Series:
1197+
def wrap_results(self, results: ResType, res_index: Index) -> DataFrame | Series:
11981198
from pandas import Series
11991199

12001200
# see if we can infer the results
@@ -1290,7 +1290,7 @@ def result_columns(self) -> Index:
12901290
return self.index
12911291

12921292
def wrap_results_for_axis(
1293-
self, results: _ResType, res_index: Index
1293+
self, results: ResType, res_index: Index
12941294
) -> DataFrame | Series:
12951295
"""return the results for the rows"""
12961296

@@ -1434,7 +1434,7 @@ def result_columns(self) -> Index:
14341434
return self.columns
14351435

14361436
def wrap_results_for_axis(
1437-
self, results: _ResType, res_index: Index
1437+
self, results: ResType, res_index: Index
14381438
) -> DataFrame | Series:
14391439
"""return the results for the columns"""
14401440
result: DataFrame | Series
@@ -1454,7 +1454,7 @@ def wrap_results_for_axis(
14541454

14551455
return result
14561456

1457-
def infer_to_same_shape(self, results: _ResType, res_index: Index) -> DataFrame:
1457+
def infer_to_same_shape(self, results: ResType, res_index: Index) -> DataFrame:
14581458
"""infer the results to the same shape as the input object"""
14591459
result = self.obj._constructor(data=results)
14601460
result = result.T

pandas/core/arrays/datetimelike.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@
162162
TimedeltaArray,
163163
)
164164

165-
# underscore at end because of rule PYI043 that private types should not end with 'T'
166-
_DTScalarOrNaT_: TypeAlias = DatetimeLikeScalar | NaTType
165+
DTScalarOrNaT: TypeAlias = DatetimeLikeScalar | NaTType
167166

168167

169168
def _make_unpacked_invalid_op(op_name: str):
@@ -238,7 +237,7 @@ def _scalar_type(self) -> type[DatetimeLikeScalar]:
238237
"""
239238
raise AbstractMethodError(self)
240239

241-
def _scalar_from_string(self, value: str) -> _DTScalarOrNaT_:
240+
def _scalar_from_string(self, value: str) -> DTScalarOrNaT:
242241
"""
243242
Construct a scalar type from a string.
244243
@@ -259,7 +258,7 @@ def _scalar_from_string(self, value: str) -> _DTScalarOrNaT_:
259258
raise AbstractMethodError(self)
260259

261260
def _unbox_scalar(
262-
self, value: _DTScalarOrNaT_
261+
self, value: DTScalarOrNaT
263262
) -> np.int64 | np.datetime64 | np.timedelta64:
264263
"""
265264
Unbox the integer value of a scalar `value`.
@@ -281,7 +280,7 @@ def _unbox_scalar(
281280
"""
282281
raise AbstractMethodError(self)
283282

284-
def _check_compatible_with(self, other: _DTScalarOrNaT_) -> None:
283+
def _check_compatible_with(self, other: DTScalarOrNaT) -> None:
285284
"""
286285
Verify that `self` and `other` are compatible.
287286
@@ -372,23 +371,23 @@ def __array__(
372371
return self._ndarray
373372

374373
@overload
375-
def __getitem__(self, key: ScalarIndexer) -> _DTScalarOrNaT_: ...
374+
def __getitem__(self, key: ScalarIndexer) -> DTScalarOrNaT: ...
376375

377376
@overload
378377
def __getitem__(
379378
self,
380379
key: SequenceIndexer | PositionalIndexerTuple,
381380
) -> Self: ...
382381

383-
def __getitem__(self, key: PositionalIndexer2D) -> Self | _DTScalarOrNaT_:
382+
def __getitem__(self, key: PositionalIndexer2D) -> Self | DTScalarOrNaT:
384383
"""
385384
This getitem defers to the underlying array, which by-definition can
386385
only handle list-likes, slices, and integer scalars
387386
"""
388387
# Use cast as we know we will get back a DatetimeLikeArray or DTScalar,
389388
# but skip evaluating the Union at runtime for performance
390389
# (see https://github.com/pandas-dev/pandas/pull/44624)
391-
result = cast(Union[Self, _DTScalarOrNaT_], super().__getitem__(key))
390+
result = cast(Union[Self, DTScalarOrNaT], super().__getitem__(key))
392391
if lib.is_scalar(result):
393392
return result
394393
else:

pandas/core/arrays/interval.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
)
110110

111111

112-
_IntervalSide: TypeAlias = TimeArrayLike | np.ndarray
113-
_IntervalOrNA: TypeAlias = Interval | float
112+
IntervalSide: TypeAlias = TimeArrayLike | np.ndarray
113+
IntervalOrNA: TypeAlias = Interval | float
114114

115115
_interval_shared_docs: dict[str, str] = {}
116116

@@ -216,8 +216,8 @@ def ndim(self) -> Literal[1]:
216216
return 1
217217

218218
# To make mypy recognize the fields
219-
_left: _IntervalSide
220-
_right: _IntervalSide
219+
_left: IntervalSide
220+
_right: IntervalSide
221221
_dtype: IntervalDtype
222222

223223
# ---------------------------------------------------------------------
@@ -234,8 +234,8 @@ def __new__(
234234
data = extract_array(data, extract_numpy=True)
235235

236236
if isinstance(data, cls):
237-
left: _IntervalSide = data._left
238-
right: _IntervalSide = data._right
237+
left: IntervalSide = data._left
238+
right: IntervalSide = data._right
239239
closed = closed or data.closed
240240
dtype = IntervalDtype(left.dtype, closed=closed)
241241
else:
@@ -277,8 +277,8 @@ def __new__(
277277
@classmethod
278278
def _simple_new(
279279
cls,
280-
left: _IntervalSide,
281-
right: _IntervalSide,
280+
left: IntervalSide,
281+
right: IntervalSide,
282282
dtype: IntervalDtype,
283283
) -> Self:
284284
result = IntervalMixin.__new__(cls)
@@ -296,7 +296,7 @@ def _ensure_simple_new_inputs(
296296
closed: IntervalClosedType | None = None,
297297
copy: bool = False,
298298
dtype: Dtype | None = None,
299-
) -> tuple[_IntervalSide, _IntervalSide, IntervalDtype]:
299+
) -> tuple[IntervalSide, IntervalSide, IntervalDtype]:
300300
"""Ensure correctness of input parameters for cls._simple_new."""
301301
from pandas.core.indexes.base import ensure_index
302302

@@ -704,12 +704,12 @@ def __len__(self) -> int:
704704
return len(self._left)
705705

706706
@overload
707-
def __getitem__(self, key: ScalarIndexer) -> _IntervalOrNA: ...
707+
def __getitem__(self, key: ScalarIndexer) -> IntervalOrNA: ...
708708

709709
@overload
710710
def __getitem__(self, key: SequenceIndexer) -> Self: ...
711711

712-
def __getitem__(self, key: PositionalIndexer) -> Self | _IntervalOrNA:
712+
def __getitem__(self, key: PositionalIndexer) -> Self | IntervalOrNA:
713713
key = check_array_indexer(self, key)
714714
left = self._left[key]
715715
right = self._right[key]
@@ -858,7 +858,7 @@ def argsort(
858858
ascending=ascending, kind=kind, na_position=na_position, **kwargs
859859
)
860860

861-
def min(self, *, axis: AxisInt | None = None, skipna: bool = True) -> _IntervalOrNA:
861+
def min(self, *, axis: AxisInt | None = None, skipna: bool = True) -> IntervalOrNA:
862862
nv.validate_minmax_axis(axis, self.ndim)
863863

864864
if not len(self):
@@ -875,7 +875,7 @@ def min(self, *, axis: AxisInt | None = None, skipna: bool = True) -> _IntervalO
875875
indexer = obj.argsort()[0]
876876
return obj[indexer]
877877

878-
def max(self, *, axis: AxisInt | None = None, skipna: bool = True) -> _IntervalOrNA:
878+
def max(self, *, axis: AxisInt | None = None, skipna: bool = True) -> IntervalOrNA:
879879
nv.validate_minmax_axis(axis, self.ndim)
880880

881881
if not len(self):
@@ -1016,10 +1016,8 @@ def _concat_same_type(cls, to_concat: Sequence[IntervalArray]) -> Self:
10161016
raise ValueError("Intervals must all be closed on the same side.")
10171017
closed = closed_set.pop()
10181018

1019-
left: _IntervalSide = np.concatenate([interval.left for interval in to_concat])
1020-
right: _IntervalSide = np.concatenate(
1021-
[interval.right for interval in to_concat]
1022-
)
1019+
left: IntervalSide = np.concatenate([interval.left for interval in to_concat])
1020+
right: IntervalSide = np.concatenate([interval.right for interval in to_concat])
10231021

10241022
left, right, dtype = cls._ensure_simple_new_inputs(left, right, closed=closed)
10251023

@@ -1954,7 +1952,7 @@ def isin(self, values: ArrayLike) -> npt.NDArray[np.bool_]:
19541952
return isin(self.astype(object), values.astype(object))
19551953

19561954
@property
1957-
def _combined(self) -> _IntervalSide:
1955+
def _combined(self) -> IntervalSide:
19581956
# error: Item "ExtensionArray" of "ExtensionArray | ndarray[Any, Any]"
19591957
# has no attribute "reshape" [union-attr]
19601958
left = self.left._values.reshape(-1, 1) # type: ignore[union-attr]

pandas/core/groupby/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
from pandas.core.generic import NDFrame
103103

104104
# TODO(typing) the return value on this callable should be any *scalar*.
105-
_AggScalar: TypeAlias = str | Callable[..., Any]
105+
AggScalar: TypeAlias = str | Callable[..., Any]
106106
# TODO: validate types on ScalarResult and move to _typing
107107
# Blocked from using by https://github.com/python/mypy/issues/1484
108108
# See note at _mangle_lambda_list
@@ -141,7 +141,7 @@ class NamedAgg(NamedTuple):
141141
"""
142142

143143
column: Hashable
144-
aggfunc: _AggScalar
144+
aggfunc: AggScalar
145145

146146

147147
@set_module("pandas.api.typing")

pandas/core/tools/datetimes.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,33 @@
9494
# ---------------------------------------------------------------------
9595
# types used in annotations
9696

97-
_ArrayConvertible: TypeAlias = list | tuple | AnyArrayLike
98-
_Scalar: TypeAlias = float | str
99-
_DatetimeScalar: TypeAlias = _Scalar | date | np.datetime64
97+
ArrayConvertible: TypeAlias = list | tuple | AnyArrayLike
98+
Scalar: TypeAlias = float | str
99+
DatetimeScalar: TypeAlias = Scalar | date | np.datetime64
100100

101-
_DatetimeScalarOrArrayConvertible: TypeAlias = _DatetimeScalar | _ArrayConvertible
102-
_DatetimeDictArg: TypeAlias = list[_Scalar] | tuple[_Scalar, ...] | AnyArrayLike
101+
DatetimeScalarOrArrayConvertible: TypeAlias = DatetimeScalar | ArrayConvertible
102+
DatetimeDictArg: TypeAlias = list[Scalar] | tuple[Scalar, ...] | AnyArrayLike
103103

104104

105-
class _YearMonthDayDict(TypedDict, total=True):
106-
year: _DatetimeDictArg
107-
month: _DatetimeDictArg
108-
day: _DatetimeDictArg
105+
class YearMonthDayDict(TypedDict, total=True):
106+
year: DatetimeDictArg
107+
month: DatetimeDictArg
108+
day: DatetimeDictArg
109109

110110

111-
class _FulldatetimeDict(_YearMonthDayDict, total=False):
112-
hour: _DatetimeDictArg
113-
hours: _DatetimeDictArg
114-
minute: _DatetimeDictArg
115-
minutes: _DatetimeDictArg
116-
second: _DatetimeDictArg
117-
seconds: _DatetimeDictArg
118-
ms: _DatetimeDictArg
119-
us: _DatetimeDictArg
120-
ns: _DatetimeDictArg
111+
class FulldatetimeDict(YearMonthDayDict, total=False):
112+
hour: DatetimeDictArg
113+
hours: DatetimeDictArg
114+
minute: DatetimeDictArg
115+
minutes: DatetimeDictArg
116+
second: DatetimeDictArg
117+
seconds: DatetimeDictArg
118+
ms: DatetimeDictArg
119+
us: DatetimeDictArg
120+
ns: DatetimeDictArg
121121

122122

123-
_DictConvertible = Union[_FulldatetimeDict, "DataFrame"]
123+
DictConvertible = Union[FulldatetimeDict, "DataFrame"]
124124
start_caching_at = 50
125125

126126

@@ -151,7 +151,7 @@ def _guess_datetime_format_for_array(arr, dayfirst: bool | None = False) -> str
151151

152152

153153
def should_cache(
154-
arg: _ArrayConvertible, unique_share: float = 0.7, check_count: int | None = None
154+
arg: ArrayConvertible, unique_share: float = 0.7, check_count: int | None = None
155155
) -> bool:
156156
"""
157157
Decides whether to do caching.
@@ -211,7 +211,7 @@ def should_cache(
211211

212212

213213
def _maybe_cache(
214-
arg: _ArrayConvertible,
214+
arg: ArrayConvertible,
215215
format: str | None,
216216
cache: bool,
217217
convert_listlike: Callable,
@@ -290,7 +290,7 @@ def _box_as_indexlike(
290290

291291

292292
def _convert_and_box_cache(
293-
arg: _DatetimeScalarOrArrayConvertible,
293+
arg: DatetimeScalarOrArrayConvertible,
294294
cache_array: Series,
295295
name: Hashable | None = None,
296296
) -> Index:
@@ -622,7 +622,7 @@ def _adjust_to_origin(arg, origin, unit):
622622

623623
@overload
624624
def to_datetime(
625-
arg: _DatetimeScalar,
625+
arg: DatetimeScalar,
626626
errors: DateTimeErrorChoices = ...,
627627
dayfirst: bool = ...,
628628
yearfirst: bool = ...,
@@ -637,7 +637,7 @@ def to_datetime(
637637

638638
@overload
639639
def to_datetime(
640-
arg: Series | _DictConvertible,
640+
arg: Series | DictConvertible,
641641
errors: DateTimeErrorChoices = ...,
642642
dayfirst: bool = ...,
643643
yearfirst: bool = ...,
@@ -666,7 +666,7 @@ def to_datetime(
666666

667667

668668
def to_datetime(
669-
arg: _DatetimeScalarOrArrayConvertible | _DictConvertible,
669+
arg: DatetimeScalarOrArrayConvertible | DictConvertible,
670670
errors: DateTimeErrorChoices = "raise",
671671
dayfirst: bool = False,
672672
yearfirst: bool = False,
@@ -676,7 +676,7 @@ def to_datetime(
676676
unit: str | None = None,
677677
origin: str = "unix",
678678
cache: bool = True,
679-
) -> DatetimeIndex | Series | _DatetimeScalar | NaTType | None:
679+
) -> DatetimeIndex | Series | DatetimeScalar | NaTType | None:
680680
"""
681681
Convert argument to datetime.
682682

pandas/io/formats/printing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
if TYPE_CHECKING:
2929
from pandas._typing import ListLike
30-
_EscapeChars: TypeAlias = Mapping[str, str] | Iterable[str]
30+
EscapeChars: TypeAlias = Mapping[str, str] | Iterable[str]
3131
_KT = TypeVar("_KT")
3232
_VT = TypeVar("_VT")
3333

@@ -174,7 +174,7 @@ def _pprint_dict(
174174
def pprint_thing(
175175
thing: object,
176176
_nest_lvl: int = 0,
177-
escape_chars: _EscapeChars | None = None,
177+
escape_chars: EscapeChars | None = None,
178178
default_escapes: bool = False,
179179
quote_strings: bool = False,
180180
max_seq_items: int | None = None,
@@ -203,7 +203,7 @@ def pprint_thing(
203203
"""
204204

205205
def as_escaped_string(
206-
thing: Any, escape_chars: _EscapeChars | None = escape_chars
206+
thing: Any, escape_chars: EscapeChars | None = escape_chars
207207
) -> str:
208208
translate = {"\t": r"\t", "\n": r"\n", "\r": r"\r", "'": r"\'"}
209209
if isinstance(escape_chars, Mapping):

0 commit comments

Comments
 (0)