|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | import codecs
|
2 | 4 | from functools import wraps
|
3 | 5 | import re
|
4 | 6 | from typing import (
|
5 | 7 | TYPE_CHECKING,
|
6 |
| - Dict, |
7 | 8 | Hashable,
|
8 |
| - List, |
9 |
| - Optional, |
10 | 9 | Pattern,
|
11 |
| - Union, |
12 | 10 | )
|
13 | 11 | import warnings
|
14 | 12 |
|
|
43 | 41 | if TYPE_CHECKING:
|
44 | 42 | from pandas import Index
|
45 | 43 |
|
46 |
| -_shared_docs: Dict[str, str] = {} |
| 44 | +_shared_docs: dict[str, str] = {} |
47 | 45 | _cpython_optimized_encoders = (
|
48 | 46 | "utf-8",
|
49 | 47 | "utf8",
|
@@ -325,7 +323,7 @@ def cons_row(x):
|
325 | 323 | else:
|
326 | 324 | index = self._orig.index
|
327 | 325 | # This is a mess.
|
328 |
| - dtype: Optional[str] |
| 326 | + dtype: str | None |
329 | 327 | if self._is_string and returns_string:
|
330 | 328 | dtype = self._orig.dtype
|
331 | 329 | else:
|
@@ -391,7 +389,7 @@ def _get_series_list(self, others):
|
391 | 389 | or (isinstance(x, np.ndarray) and x.ndim == 1)
|
392 | 390 | for x in others
|
393 | 391 | ):
|
394 |
| - los: List[Series] = [] |
| 392 | + los: list[Series] = [] |
395 | 393 | while others: # iterate through list and append each element
|
396 | 394 | los = los + self._get_series_list(others.pop(0))
|
397 | 395 | return los
|
@@ -2292,7 +2290,7 @@ def findall(self, pat, flags=0):
|
2292 | 2290 | @forbid_nonstring_types(["bytes"])
|
2293 | 2291 | def extract(
|
2294 | 2292 | self, pat: str, flags: int = 0, expand: bool = True
|
2295 |
| - ) -> Union[FrameOrSeriesUnion, "Index"]: |
| 2293 | + ) -> FrameOrSeriesUnion | Index: |
2296 | 2294 | r"""
|
2297 | 2295 | Extract capture groups in the regex `pat` as columns in a DataFrame.
|
2298 | 2296 |
|
@@ -2733,7 +2731,7 @@ def len(self):
|
2733 | 2731 | # boolean:
|
2734 | 2732 | # isalpha, isnumeric isalnum isdigit isdecimal isspace islower isupper istitle
|
2735 | 2733 | # _doc_args holds dict of strings to use in substituting casemethod docs
|
2736 |
| - _doc_args: Dict[str, Dict[str, str]] = {} |
| 2734 | + _doc_args: dict[str, dict[str, str]] = {} |
2737 | 2735 | _doc_args["lower"] = {"type": "lowercase", "method": "lower", "version": ""}
|
2738 | 2736 | _doc_args["upper"] = {"type": "uppercase", "method": "upper", "version": ""}
|
2739 | 2737 | _doc_args["title"] = {"type": "titlecase", "method": "title", "version": ""}
|
@@ -2971,7 +2969,7 @@ def casefold(self):
|
2971 | 2969 | )
|
2972 | 2970 |
|
2973 | 2971 |
|
2974 |
| -def cat_safe(list_of_columns: List, sep: str): |
| 2972 | +def cat_safe(list_of_columns: list, sep: str): |
2975 | 2973 | """
|
2976 | 2974 | Auxiliary function for :meth:`str.cat`.
|
2977 | 2975 |
|
@@ -3007,7 +3005,7 @@ def cat_safe(list_of_columns: List, sep: str):
|
3007 | 3005 | return result
|
3008 | 3006 |
|
3009 | 3007 |
|
3010 |
| -def cat_core(list_of_columns: List, sep: str): |
| 3008 | +def cat_core(list_of_columns: list, sep: str): |
3011 | 3009 | """
|
3012 | 3010 | Auxiliary function for :meth:`str.cat`
|
3013 | 3011 |
|
@@ -3053,7 +3051,7 @@ def _get_single_group_name(regex: Pattern) -> Hashable:
|
3053 | 3051 | return None
|
3054 | 3052 |
|
3055 | 3053 |
|
3056 |
| -def _get_group_names(regex: Pattern) -> List[Hashable]: |
| 3054 | +def _get_group_names(regex: Pattern) -> list[Hashable]: |
3057 | 3055 | """
|
3058 | 3056 | Get named groups from compiled regex.
|
3059 | 3057 |
|
@@ -3119,7 +3117,7 @@ def str_extract(accessor: StringMethods, pat: str, flags: int = 0, expand: bool
|
3119 | 3117 | else:
|
3120 | 3118 | result_list = _str_extract(obj.array, pat, flags=flags, expand=returns_df)
|
3121 | 3119 |
|
3122 |
| - result_index: Optional["Index"] |
| 3120 | + result_index: Index | None |
3123 | 3121 | if isinstance(obj, ABCSeries):
|
3124 | 3122 | result_index = obj.index
|
3125 | 3123 | else:
|
|
0 commit comments