19
19
)
20
20
21
21
from pandas ._typing import (
22
+ BaseBuffer ,
22
23
FilePath ,
23
24
ReadBuffer ,
24
25
)
@@ -130,9 +131,7 @@ def _get_skiprows(skiprows: int | Sequence[int] | slice | None) -> int | Sequenc
130
131
raise TypeError (f"{ type (skiprows ).__name__ } is not a valid type for skipping rows" )
131
132
132
133
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 :
136
135
"""
137
136
Try to read from a url, file or string.
138
137
@@ -150,13 +149,7 @@ def _read(
150
149
or hasattr (obj , "read" )
151
150
or (isinstance (obj , str ) and file_exists (obj ))
152
151
):
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 :
160
153
text = handles .handle .read ()
161
154
elif isinstance (obj , (str , bytes )):
162
155
text = obj
0 commit comments