Skip to content

Commit 7bac17b

Browse files
batch 6 (#41900)
1 parent 52f04db commit 7bac17b

File tree

12 files changed

+41
-41
lines changed

12 files changed

+41
-41
lines changed

pandas/_libs/tslibs/offsets.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import operator
22
import re
33
import time
4-
from typing import Any
54
import warnings
65

76
import cython
@@ -364,7 +363,7 @@ cdef class BaseOffset:
364363
self.normalize = normalize
365364
self._cache = {}
366365

367-
def __eq__(self, other: Any) -> bool:
366+
def __eq__(self, other) -> bool:
368367
if isinstance(other, str):
369368
try:
370369
# GH#23524 if to_offset fails, we are dealing with an

pandas/io/excel/_odfreader.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from __future__ import annotations
22

33
import numpy as np
44

@@ -51,7 +51,7 @@ def empty_value(self) -> str:
5151
return ""
5252

5353
@property
54-
def sheet_names(self) -> List[str]:
54+
def sheet_names(self) -> list[str]:
5555
"""Return a list of sheet names present in the document"""
5656
from odf.table import Table
5757

@@ -78,7 +78,7 @@ def get_sheet_by_name(self, name: str):
7878
self.close()
7979
raise ValueError(f"sheet {name} not found")
8080

81-
def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:
81+
def get_sheet_data(self, sheet, convert_float: bool) -> list[list[Scalar]]:
8282
"""
8383
Parse an ODF Table into a list of lists
8484
"""
@@ -96,12 +96,12 @@ def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:
9696
empty_rows = 0
9797
max_row_len = 0
9898

99-
table: List[List[Scalar]] = []
99+
table: list[list[Scalar]] = []
100100

101101
for sheet_row in sheet_rows:
102102
sheet_cells = [x for x in sheet_row.childNodes if x.qname in cell_names]
103103
empty_cells = 0
104-
table_row: List[Scalar] = []
104+
table_row: list[Scalar] = []
105105

106106
for sheet_cell in sheet_cells:
107107
if sheet_cell.qname == table_cell_name:

pandas/io/excel/_pyxlsb.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from __future__ import annotations
22

33
from pandas._typing import (
44
FilePathOrBuffer,
@@ -47,7 +47,7 @@ def load_workbook(self, filepath_or_buffer: FilePathOrBuffer):
4747
return open_workbook(filepath_or_buffer)
4848

4949
@property
50-
def sheet_names(self) -> List[str]:
50+
def sheet_names(self) -> list[str]:
5151
return self.book.sheets
5252

5353
def get_sheet_by_name(self, name: str):
@@ -74,7 +74,7 @@ def _convert_cell(self, cell, convert_float: bool) -> Scalar:
7474

7575
return cell.v
7676

77-
def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:
77+
def get_sheet_data(self, sheet, convert_float: bool) -> list[list[Scalar]]:
7878
data: list[list[Scalar]] = []
7979
prevous_row_number = -1
8080
# When sparse=True the rows can have different lengths and empty rows are

pandas/io/excel/_util.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from typing import (
2-
List,
3-
MutableMapping,
4-
)
1+
from __future__ import annotations
2+
3+
from typing import MutableMapping
54

65
from pandas.compat._optional import import_optional_dependency
76

@@ -110,7 +109,7 @@ def _excel2num(x: str) -> int:
110109
return index - 1
111110

112111

113-
def _range2cols(areas: str) -> List[int]:
112+
def _range2cols(areas: str) -> list[int]:
114113
"""
115114
Convert comma separated list of column names and ranges to indices.
116115
@@ -131,7 +130,7 @@ def _range2cols(areas: str) -> List[int]:
131130
>>> _range2cols('A,C,Z:AB')
132131
[0, 2, 25, 26, 27]
133132
"""
134-
cols: List[int] = []
133+
cols: list[int] = []
135134

136135
for rng in areas.split(","):
137136
if ":" in rng:

pandas/tests/dtypes/test_common.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from __future__ import annotations
2+
13
from datetime import datetime
2-
from typing import List
34

45
import numpy as np
56
import pytest
@@ -287,7 +288,7 @@ def test_is_string_dtype_nullable(nullable_string_dtype):
287288
assert com.is_string_dtype(pd.array(["a", "b"], dtype=nullable_string_dtype))
288289

289290

290-
integer_dtypes: List = []
291+
integer_dtypes: list = []
291292

292293

293294
@pytest.mark.parametrize(
@@ -319,7 +320,7 @@ def test_is_not_integer_dtype(dtype):
319320
assert not com.is_integer_dtype(dtype)
320321

321322

322-
signed_integer_dtypes: List = []
323+
signed_integer_dtypes: list = []
323324

324325

325326
@pytest.mark.parametrize(
@@ -355,7 +356,7 @@ def test_is_not_signed_integer_dtype(dtype):
355356
assert not com.is_signed_integer_dtype(dtype)
356357

357358

358-
unsigned_integer_dtypes: List = []
359+
unsigned_integer_dtypes: list = []
359360

360361

361362
@pytest.mark.parametrize(

pandas/tests/frame/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from __future__ import annotations
22

33
from pandas import (
44
DataFrame,
@@ -39,7 +39,7 @@ def _check_mixed_int(df, dtype=None):
3939
assert df.dtypes["D"] == dtypes["D"]
4040

4141

42-
def zip_frames(frames: List[DataFrame], axis: int = 1) -> DataFrame:
42+
def zip_frames(frames: list[DataFrame], axis: int = 1) -> DataFrame:
4343
"""
4444
take a list of frames, zip them together under the
4545
assumption that these all have the first frames' index/columns.

pandas/tests/indexes/common.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from __future__ import annotations
2+
13
from datetime import datetime
24
import gc
3-
from typing import Type
45

56
import numpy as np
67
import pytest
@@ -36,7 +37,7 @@ class Base:
3637
Base class for index sub-class tests.
3738
"""
3839

39-
_index_cls: Type[Index]
40+
_index_cls: type[Index]
4041

4142
@pytest.fixture
4243
def simple_index(self):

pandas/tests/indexing/test_coercion.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
from __future__ import annotations
2+
13
from datetime import timedelta
24
import itertools
3-
from typing import (
4-
Dict,
5-
List,
6-
)
75

86
import numpy as np
97
import pytest
@@ -1024,7 +1022,7 @@ class TestReplaceSeriesCoercion(CoercionBase):
10241022
klasses = ["series"]
10251023
method = "replace"
10261024

1027-
rep: Dict[str, List] = {}
1025+
rep: dict[str, list] = {}
10281026
rep["object"] = ["a", "b"]
10291027
rep["int64"] = [4, 5]
10301028
rep["float64"] = [1.1, 2.2]

pandas/tests/io/xml/test_to_xml.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from __future__ import annotations
2+
13
from io import (
24
BytesIO,
35
StringIO,
46
)
57
import os
6-
from typing import Union
78

89
import numpy as np
910
import pytest
@@ -963,7 +964,7 @@ def test_stylesheet_file_like(datapath, mode):
963964
def test_stylesheet_io(datapath, mode):
964965
xsl_path = datapath("io", "data", "xml", "row_field_output.xsl")
965966

966-
xsl_obj: Union[BytesIO, StringIO]
967+
xsl_obj: BytesIO | StringIO
967968

968969
with open(xsl_path, mode) as f:
969970
if mode == "rb":

pandas/tests/io/xml/test_xml.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from __future__ import annotations
2+
13
from io import (
24
BytesIO,
35
StringIO,
46
)
57
import os
6-
from typing import Union
78
from urllib.error import HTTPError
89

910
import numpy as np
@@ -792,7 +793,7 @@ def test_stylesheet_io(datapath, mode):
792793
kml = datapath("io", "data", "xml", "cta_rail_lines.kml")
793794
xsl = datapath("io", "data", "xml", "flatten_doc.xsl")
794795

795-
xsl_obj: Union[BytesIO, StringIO]
796+
xsl_obj: BytesIO | StringIO
796797

797798
with open(xsl, mode) as f:
798799
if mode == "rb":
@@ -942,7 +943,7 @@ def test_stylesheet_file_close(datapath, mode):
942943
kml = datapath("io", "data", "xml", "cta_rail_lines.kml")
943944
xsl = datapath("io", "data", "xml", "flatten_doc.xsl")
944945

945-
xsl_obj: Union[BytesIO, StringIO]
946+
xsl_obj: BytesIO | StringIO
946947

947948
with open(xsl, mode) as f:
948949
if mode == "rb":

pandas/tests/tseries/offsets/test_offsets.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
Tests of pandas.tseries.offsets
33
"""
4+
from __future__ import annotations
5+
46
from datetime import (
57
datetime,
68
timedelta,

scripts/validate_rst_title_capitalization.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
From the command-line:
1212
python scripts/validate_rst_title_capitalization.py <rst file>
1313
"""
14+
from __future__ import annotations
15+
1416
import argparse
1517
import re
1618
import sys
17-
from typing import (
18-
Iterable,
19-
List,
20-
Tuple,
21-
)
19+
from typing import Iterable
2220

2321
CAPITALIZATION_EXCEPTIONS = {
2422
"pandas",
@@ -201,7 +199,7 @@ def correct_title_capitalization(title: str) -> str:
201199
return correct_title
202200

203201

204-
def find_titles(rst_file: str) -> Iterable[Tuple[str, int]]:
202+
def find_titles(rst_file: str) -> Iterable[tuple[str, int]]:
205203
"""
206204
Algorithm to identify particular text that should be considered headings in an
207205
RST file.
@@ -237,7 +235,7 @@ def find_titles(rst_file: str) -> Iterable[Tuple[str, int]]:
237235
previous_line = line
238236

239237

240-
def main(source_paths: List[str]) -> int:
238+
def main(source_paths: list[str]) -> int:
241239
"""
242240
The main method to print all headings with incorrect capitalization.
243241

0 commit comments

Comments
 (0)