Skip to content

Commit bd1263f

Browse files
authored
TYP: annotation of __init__ return type (PEP 484) (pandas/io) (#46284)
1 parent c0d746f commit bd1263f

32 files changed

+92
-86
lines changed

pandas/io/clipboard/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PyperclipException(RuntimeError):
9393

9494

9595
class PyperclipWindowsException(PyperclipException):
96-
def __init__(self, message):
96+
def __init__(self, message) -> None:
9797
message += f" ({ctypes.WinError()})"
9898
super().__init__(message)
9999

@@ -305,7 +305,7 @@ def __bool__(self) -> bool:
305305

306306
# Windows-related clipboard functions:
307307
class CheckedCall:
308-
def __init__(self, f):
308+
def __init__(self, f) -> None:
309309
super().__setattr__("f", f)
310310

311311
def __call__(self, *args):

pandas/io/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ def __init__(
872872
mode: str,
873873
archive_name: str | None = None,
874874
**kwargs,
875-
):
875+
) -> None:
876876
mode = mode.replace("b", "")
877877
self.archive_name = archive_name
878878
self.multiple_write_buffer: StringIO | BytesIO | None = None
@@ -944,7 +944,7 @@ def __init__(
944944
encoding: str = "utf-8",
945945
errors: str = "strict",
946946
decode: bool = True,
947-
):
947+
) -> None:
948948
self.encoding = encoding
949949
self.errors = errors
950950
self.decoder = codecs.getincrementaldecoder(encoding)(errors=errors)
@@ -999,7 +999,7 @@ class _IOWrapper:
999999
# methods, e.g., tempfile.SpooledTemporaryFile.
10001000
# If a buffer does not have the above "-able" methods, we simple assume they are
10011001
# seek/read/writ-able.
1002-
def __init__(self, buffer: BaseBuffer):
1002+
def __init__(self, buffer: BaseBuffer) -> None:
10031003
self.buffer = buffer
10041004

10051005
def __getattr__(self, name: str):
@@ -1026,7 +1026,7 @@ def writable(self) -> bool:
10261026
class _BytesIOWrapper:
10271027
# Wrapper that wraps a StringIO buffer and reads bytes from it
10281028
# Created for compat with pyarrow read_csv
1029-
def __init__(self, buffer: StringIO | TextIOBase, encoding: str = "utf-8"):
1029+
def __init__(self, buffer: StringIO | TextIOBase, encoding: str = "utf-8") -> None:
10301030
self.buffer = buffer
10311031
self.encoding = encoding
10321032
# Because a character can be represented by more than 1 byte,

pandas/io/excel/_base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,9 @@ def read_excel(
497497

498498

499499
class BaseExcelReader(metaclass=abc.ABCMeta):
500-
def __init__(self, filepath_or_buffer, storage_options: StorageOptions = None):
500+
def __init__(
501+
self, filepath_or_buffer, storage_options: StorageOptions = None
502+
) -> None:
501503
# First argument can also be bytes, so create a buffer
502504
if isinstance(filepath_or_buffer, bytes):
503505
filepath_or_buffer = BytesIO(filepath_or_buffer)
@@ -1131,7 +1133,7 @@ def __init__(
11311133
if_sheet_exists: str | None = None,
11321134
engine_kwargs: dict[str, Any] | None = None,
11331135
**kwargs,
1134-
):
1136+
) -> None:
11351137
# validate that this engine can handle the extension
11361138
if isinstance(path, str):
11371139
ext = os.path.splitext(path)[-1]
@@ -1454,7 +1456,7 @@ def __init__(
14541456
path_or_buffer,
14551457
engine: str | None = None,
14561458
storage_options: StorageOptions = None,
1457-
):
1459+
) -> None:
14581460
if engine is not None and engine not in self._engines:
14591461
raise ValueError(f"Unknown engine: {engine}")
14601462

pandas/io/excel/_odfreader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(
4141
self,
4242
filepath_or_buffer: FilePath | ReadBuffer[bytes],
4343
storage_options: StorageOptions = None,
44-
):
44+
) -> None:
4545
import_optional_dependency("odf")
4646
super().__init__(filepath_or_buffer, storage_options=storage_options)
4747

pandas/io/excel/_odswriter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(
3939
if_sheet_exists: str | None = None,
4040
engine_kwargs: dict[str, Any] | None = None,
4141
**kwargs,
42-
):
42+
) -> None:
4343
from odf.opendocument import OpenDocumentSpreadsheet
4444

4545
if mode == "a":

pandas/io/excel/_openpyxl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
if_sheet_exists: str | None = None,
5151
engine_kwargs: dict[str, Any] | None = None,
5252
**kwargs,
53-
):
53+
) -> None:
5454
# Use the openpyxl module as the Excel writer.
5555
from openpyxl.workbook import Workbook
5656

pandas/io/excel/_pyxlsb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(
2121
self,
2222
filepath_or_buffer: FilePath | ReadBuffer[bytes],
2323
storage_options: StorageOptions = None,
24-
):
24+
) -> None:
2525
"""
2626
Reader using pyxlsb engine.
2727

pandas/io/excel/_xlrd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
class XlrdReader(BaseExcelReader):
1515
@doc(storage_options=_shared_docs["storage_options"])
16-
def __init__(self, filepath_or_buffer, storage_options: StorageOptions = None):
16+
def __init__(
17+
self, filepath_or_buffer, storage_options: StorageOptions = None
18+
) -> None:
1719
"""
1820
Reader using xlrd engine.
1921

pandas/io/excel/_xlsxwriter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __init__(
183183
if_sheet_exists: str | None = None,
184184
engine_kwargs: dict[str, Any] | None = None,
185185
**kwargs,
186-
):
186+
) -> None:
187187
# Use the xlsxwriter module as the Excel writer.
188188
from xlsxwriter import Workbook
189189

pandas/io/excel/_xlwt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(
4040
if_sheet_exists: str | None = None,
4141
engine_kwargs: dict[str, Any] | None = None,
4242
**kwargs,
43-
):
43+
) -> None:
4444
# Use the xlwt module as the Excel writer.
4545
import xlwt
4646

0 commit comments

Comments
 (0)