Skip to content

Commit e462776

Browse files
authored
TYP: fixed io.html._read typing (#50810)
fixed _read typing
1 parent b2e772f commit e462776

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

pandas/io/html.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
)
2020

2121
from pandas._typing import (
22+
BaseBuffer,
2223
FilePath,
2324
ReadBuffer,
2425
)
@@ -130,9 +131,7 @@ def _get_skiprows(skiprows: int | Sequence[int] | slice | None) -> int | Sequenc
130131
raise TypeError(f"{type(skiprows).__name__} is not a valid type for skipping rows")
131132

132133

133-
def _read(
134-
obj: bytes | FilePath | ReadBuffer[str] | ReadBuffer[bytes], encoding: str | None
135-
) -> str | bytes:
134+
def _read(obj: FilePath | BaseBuffer, encoding: str | None) -> str | bytes:
136135
"""
137136
Try to read from a url, file or string.
138137
@@ -150,13 +149,7 @@ def _read(
150149
or hasattr(obj, "read")
151150
or (isinstance(obj, str) and file_exists(obj))
152151
):
153-
# error: Argument 1 to "get_handle" has incompatible type "Union[str, bytes,
154-
# Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]]";
155-
# expected "Union[PathLike[str], Union[str, Union[IO[Any], RawIOBase,
156-
# BufferedIOBase, TextIOBase, TextIOWrapper, mmap]]]"
157-
with get_handle(
158-
obj, "r", encoding=encoding # type: ignore[arg-type]
159-
) as handles:
152+
with get_handle(obj, "r", encoding=encoding) as handles:
160153
text = handles.handle.read()
161154
elif isinstance(obj, (str, bytes)):
162155
text = obj

0 commit comments

Comments
 (0)