diff --git a/pandas/_typing.py b/pandas/_typing.py index f3fc156cff556..d677564b5455e 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -21,6 +21,7 @@ Dict, Hashable, List, + Literal, Mapping, Optional, Sequence, @@ -37,7 +38,6 @@ # https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles if TYPE_CHECKING: from typing import ( - Literal, TypedDict, final, ) @@ -200,10 +200,7 @@ ] # Arguments for fillna() -if TYPE_CHECKING: - FillnaOptions = Literal["backfill", "bfill", "ffill", "pad"] -else: - FillnaOptions = str +FillnaOptions = Literal["backfill", "bfill", "ffill", "pad"] # internals Manager = Union[ diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 06ad571fb0c00..a467798adf2e4 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -8,6 +8,7 @@ from textwrap import dedent from typing import ( TYPE_CHECKING, + Literal, Union, cast, ) @@ -79,7 +80,6 @@ from pandas.core.indexers import validate_indices if TYPE_CHECKING: - from typing import Literal from pandas import ( Categorical, diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 96bd4280f4da4..86a9eb9c4c32a 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -14,6 +14,7 @@ Any, Callable, Iterator, + Literal, Sequence, TypeVar, cast, @@ -72,7 +73,6 @@ ) if TYPE_CHECKING: - from typing import Literal class ExtensionArraySupportsAnyAll("ExtensionArray"): def any(self, *, skipna: bool = True) -> bool: diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 08cb12a1373bb..8b5bda4629506 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -9,6 +9,7 @@ TYPE_CHECKING, Any, Callable, + Literal, Sequence, TypeVar, Union, @@ -121,7 +122,6 @@ from pandas.tseries import frequencies if TYPE_CHECKING: - from typing import Literal from pandas.core.arrays import ( DatetimeArray, diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 92a906e9fd8b0..0a517b22d1bb3 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -8,6 +8,7 @@ ) from typing import ( TYPE_CHECKING, + Literal, cast, overload, ) @@ -81,7 +82,6 @@ ) if TYPE_CHECKING: - from typing import Literal from pandas import DataFrame from pandas.core.arrays import ( diff --git a/pandas/core/base.py b/pandas/core/base.py index a7a67a1f77ea3..430f1b57f0b87 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -10,6 +10,7 @@ Any, Generic, Hashable, + Literal, TypeVar, cast, ) @@ -64,7 +65,6 @@ import pandas.core.nanops as nanops if TYPE_CHECKING: - from typing import Literal from pandas import Categorical diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 52254ff4cdb9b..9f0fefc9a10d0 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -14,6 +14,7 @@ from typing import ( TYPE_CHECKING, Any, + Literal, Sized, TypeVar, cast, @@ -93,7 +94,6 @@ ) if TYPE_CHECKING: - from typing import Literal from pandas.core.arrays import ( DatetimeArray, diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f63ebd2156fc2..2466154f78294 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -27,6 +27,7 @@ Hashable, Iterable, Iterator, + Literal, Sequence, cast, overload, @@ -207,7 +208,6 @@ import pandas.plotting if TYPE_CHECKING: - from typing import Literal from pandas._typing import ( TimedeltaConvertibleTypes, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 4019ef8537294..f1a5a565fc861 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -14,6 +14,7 @@ AnyStr, Callable, Hashable, + Literal, Mapping, Sequence, cast, @@ -154,7 +155,6 @@ from pandas.io.formats.printing import pprint_thing if TYPE_CHECKING: - from typing import Literal from pandas._libs.tslibs import BaseOffset from pandas._typing import RandomState diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index a3a894560edfd..ba80f7329202d 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -24,6 +24,7 @@ class providing the base-class of operations. Iterable, Iterator, List, + Literal, Mapping, Sequence, TypeVar, @@ -109,7 +110,6 @@ class providing the base-class of operations. ) if TYPE_CHECKING: - from typing import Literal from pandas._typing import RandomState diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 86df4854db01d..2f1d85f1340a4 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -9,6 +9,7 @@ Any, Callable, Hashable, + Literal, Sequence, TypeVar, cast, @@ -159,7 +160,6 @@ ) if TYPE_CHECKING: - from typing import Literal from pandas import ( CategoricalIndex, diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 76e23f1bf77e0..40a208a24699a 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -4,9 +4,9 @@ from datetime import timedelta from textwrap import dedent from typing import ( - TYPE_CHECKING, Callable, Hashable, + Literal, no_type_check, ) @@ -88,9 +88,6 @@ Tick, ) -if TYPE_CHECKING: - from typing import Literal - _shared_docs_kwargs: dict[str, str] = {} diff --git a/pandas/core/series.py b/pandas/core/series.py index a0c974428d875..6e6e8b6d8b178 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -13,6 +13,7 @@ Callable, Hashable, Iterable, + Literal, Sequence, Union, cast, @@ -140,7 +141,6 @@ import pandas.plotting if TYPE_CHECKING: - from typing import Literal from pandas._typing import ( TimedeltaConvertibleTypes,