Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions pandas/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)

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


def _read(
obj: bytes | FilePath | ReadBuffer[str] | ReadBuffer[bytes], encoding: str | None
) -> str | bytes:
def _read(obj: FilePath | BaseBuffer, encoding: str | None) -> str | bytes:
"""
Try to read from a url, file or string.

Expand All @@ -150,13 +149,7 @@ def _read(
or hasattr(obj, "read")
or (isinstance(obj, str) and file_exists(obj))
):
# error: Argument 1 to "get_handle" has incompatible type "Union[str, bytes,
# Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]]";
# expected "Union[PathLike[str], Union[str, Union[IO[Any], RawIOBase,
# BufferedIOBase, TextIOBase, TextIOWrapper, mmap]]]"
with get_handle(
obj, "r", encoding=encoding # type: ignore[arg-type]
) as handles:
with get_handle(obj, "r", encoding=encoding) as handles:
text = handles.handle.read()
elif isinstance(obj, (str, bytes)):
text = obj
Expand Down