Skip to content

Commit e102f80

Browse files
TYP: clean for PY3.8 (Literal) (#42385)
1 parent 21de051 commit e102f80

File tree

13 files changed

+14
-20
lines changed

13 files changed

+14
-20
lines changed

pandas/_typing.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Dict,
2222
Hashable,
2323
List,
24+
Literal,
2425
Mapping,
2526
Optional,
2627
Sequence,
@@ -37,7 +38,6 @@
3738
# https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles
3839
if TYPE_CHECKING:
3940
from typing import (
40-
Literal,
4141
TypedDict,
4242
final,
4343
)
@@ -200,10 +200,7 @@
200200
]
201201

202202
# Arguments for fillna()
203-
if TYPE_CHECKING:
204-
FillnaOptions = Literal["backfill", "bfill", "ffill", "pad"]
205-
else:
206-
FillnaOptions = str
203+
FillnaOptions = Literal["backfill", "bfill", "ffill", "pad"]
207204

208205
# internals
209206
Manager = Union[

pandas/core/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from textwrap import dedent
99
from typing import (
1010
TYPE_CHECKING,
11+
Literal,
1112
Union,
1213
cast,
1314
)
@@ -79,7 +80,6 @@
7980
from pandas.core.indexers import validate_indices
8081

8182
if TYPE_CHECKING:
82-
from typing import Literal
8383

8484
from pandas import (
8585
Categorical,

pandas/core/arrays/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Any,
1515
Callable,
1616
Iterator,
17+
Literal,
1718
Sequence,
1819
TypeVar,
1920
cast,
@@ -72,7 +73,6 @@
7273
)
7374

7475
if TYPE_CHECKING:
75-
from typing import Literal
7676

7777
class ExtensionArraySupportsAnyAll("ExtensionArray"):
7878
def any(self, *, skipna: bool = True) -> bool:

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
TYPE_CHECKING,
1010
Any,
1111
Callable,
12+
Literal,
1213
Sequence,
1314
TypeVar,
1415
Union,
@@ -121,7 +122,6 @@
121122
from pandas.tseries import frequencies
122123

123124
if TYPE_CHECKING:
124-
from typing import Literal
125125

126126
from pandas.core.arrays import (
127127
DatetimeArray,

pandas/core/arrays/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
)
99
from typing import (
1010
TYPE_CHECKING,
11+
Literal,
1112
cast,
1213
overload,
1314
)
@@ -81,7 +82,6 @@
8182
)
8283

8384
if TYPE_CHECKING:
84-
from typing import Literal
8585

8686
from pandas import DataFrame
8787
from pandas.core.arrays import (

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Any,
1111
Generic,
1212
Hashable,
13+
Literal,
1314
TypeVar,
1415
cast,
1516
)
@@ -64,7 +65,6 @@
6465
import pandas.core.nanops as nanops
6566

6667
if TYPE_CHECKING:
67-
from typing import Literal
6868

6969
from pandas import Categorical
7070

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from typing import (
1515
TYPE_CHECKING,
1616
Any,
17+
Literal,
1718
Sized,
1819
TypeVar,
1920
cast,
@@ -93,7 +94,6 @@
9394
)
9495

9596
if TYPE_CHECKING:
96-
from typing import Literal
9797

9898
from pandas.core.arrays import (
9999
DatetimeArray,

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
Hashable,
2828
Iterable,
2929
Iterator,
30+
Literal,
3031
Sequence,
3132
cast,
3233
overload,
@@ -207,7 +208,6 @@
207208
import pandas.plotting
208209

209210
if TYPE_CHECKING:
210-
from typing import Literal
211211

212212
from pandas._typing import (
213213
TimedeltaConvertibleTypes,

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
AnyStr,
1515
Callable,
1616
Hashable,
17+
Literal,
1718
Mapping,
1819
Sequence,
1920
cast,
@@ -154,7 +155,6 @@
154155
from pandas.io.formats.printing import pprint_thing
155156

156157
if TYPE_CHECKING:
157-
from typing import Literal
158158

159159
from pandas._libs.tslibs import BaseOffset
160160
from pandas._typing import RandomState

pandas/core/groupby/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class providing the base-class of operations.
2424
Iterable,
2525
Iterator,
2626
List,
27+
Literal,
2728
Mapping,
2829
Sequence,
2930
TypeVar,
@@ -109,7 +110,6 @@ class providing the base-class of operations.
109110
)
110111

111112
if TYPE_CHECKING:
112-
from typing import Literal
113113

114114
from pandas._typing import RandomState
115115

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Any,
1010
Callable,
1111
Hashable,
12+
Literal,
1213
Sequence,
1314
TypeVar,
1415
cast,
@@ -159,7 +160,6 @@
159160
)
160161

161162
if TYPE_CHECKING:
162-
from typing import Literal
163163

164164
from pandas import (
165165
CategoricalIndex,

pandas/core/resample.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from datetime import timedelta
55
from textwrap import dedent
66
from typing import (
7-
TYPE_CHECKING,
87
Callable,
98
Hashable,
9+
Literal,
1010
no_type_check,
1111
)
1212

@@ -88,9 +88,6 @@
8888
Tick,
8989
)
9090

91-
if TYPE_CHECKING:
92-
from typing import Literal
93-
9491
_shared_docs_kwargs: dict[str, str] = {}
9592

9693

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Callable,
1414
Hashable,
1515
Iterable,
16+
Literal,
1617
Sequence,
1718
Union,
1819
cast,
@@ -140,7 +141,6 @@
140141
import pandas.plotting
141142

142143
if TYPE_CHECKING:
143-
from typing import Literal
144144

145145
from pandas._typing import (
146146
TimedeltaConvertibleTypes,

0 commit comments

Comments
 (0)