Skip to content

Commit 32fdfe4

Browse files
authored
Replace aliases to builtins with imports (#1244)
1 parent 30bbb3d commit 32fdfe4

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from builtins import (
2+
bool as _bool,
3+
str as _str,
4+
)
15
from collections.abc import (
26
Callable,
37
Hashable,
@@ -161,9 +165,6 @@ from pandas._typing import (
161165
from pandas.io.formats.style import Styler
162166
from pandas.plotting import PlotAccessor
163167

164-
_str = str
165-
_bool = bool
166-
167168
class _iLocIndexerFrame(_iLocIndexer, Generic[_T]):
168169
@overload
169170
def __getitem__(self, idx: tuple[int, int]) -> Scalar: ...
@@ -2148,7 +2149,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
21482149
def reindex_like(
21492150
self,
21502151
other: DataFrame,
2151-
method: _str | FillnaOptions | Literal["nearest"] | None = ...,
2152+
method: FillnaOptions | Literal["nearest"] | None = ...,
21522153
copy: _bool = ...,
21532154
limit: int | None = ...,
21542155
tolerance: Scalar | AnyArrayLike | Sequence[Scalar] = ...,

pandas-stubs/core/generic.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from builtins import (
2+
bool as _bool,
3+
str as _str,
4+
)
15
from collections.abc import (
26
Callable,
37
Hashable,
@@ -60,9 +64,6 @@ from pandas._typing import (
6064
from pandas.io.pytables import HDFStore
6165
from pandas.io.sql import SQLTable
6266

63-
_bool = bool
64-
_str = str
65-
6667
class NDFrame(indexing.IndexingMixin):
6768
__hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]
6869

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from builtins import str as _str
12
from collections.abc import (
23
Callable,
34
Hashable,
@@ -66,8 +67,6 @@ from pandas._typing import (
6667

6768
class InvalidIndexError(Exception): ...
6869

69-
_str = str
70-
7170
class Index(IndexOpsMixin[S1]):
7271
__hash__: ClassVar[None] # type: ignore[assignment]
7372
# overloads with additional dtypes

pandas-stubs/core/series.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from builtins import (
2+
bool as _bool,
3+
str as _str,
4+
)
15
from collections import dict_keys # type: ignore[attr-defined]
26
from collections.abc import (
37
Callable,
@@ -179,9 +183,6 @@ from pandas.core.dtypes.dtypes import CategoricalDtype
179183

180184
from pandas.plotting import PlotAccessor
181185

182-
_bool: TypeAlias = bool
183-
_str: TypeAlias = str
184-
185186
class _iLocIndexerSeries(_iLocIndexer, Generic[S1]):
186187
# get item
187188
@overload
@@ -1078,7 +1079,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
10781079
def reindex_like(
10791080
self,
10801081
other: Series[S1],
1081-
method: _str | FillnaOptions | Literal["nearest"] | None = ...,
1082+
method: FillnaOptions | Literal["nearest"] | None = ...,
10821083
copy: _bool = ...,
10831084
limit: int | None = ...,
10841085
tolerance: Scalar | AnyArrayLike | Sequence[Scalar] = ...,

pandas-stubs/core/strings.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pyright: strict
2+
from builtins import slice as _slice
23
from collections.abc import (
34
Callable,
45
Sequence,
@@ -8,7 +9,6 @@ from typing import (
89
Any,
910
Generic,
1011
Literal,
11-
TypeAlias,
1212
TypeVar,
1313
overload,
1414
)
@@ -47,8 +47,6 @@ _T_STR = TypeVar("_T_STR", bound=Series[str] | Index[str])
4747
# Used for the result of str.partition
4848
_T_OBJECT = TypeVar("_T_OBJECT", bound=Series[type[object]] | Index[type[object]])
4949

50-
_slice: TypeAlias = slice
51-
5250
class StringMethods(
5351
NoNewAttributesMixin,
5452
Generic[T, _T_EXPANDING, _T_BOOL, _T_LIST_STR, _T_INT, _T_BYTES, _T_STR, _T_OBJECT],

0 commit comments

Comments
 (0)