Skip to content

Commit 16b6f69

Browse files
committed
fix:mypy type errors resolved
1 parent e64ea42 commit 16b6f69

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pandas/_testing/_io.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ def round_trip_pickle(
6161
# Only join tmpdir with _path when _path is a string or Path-like.
6262
# _path may be a ReadPickleBuffer (file-like) in which case it
6363
# should be used directly for pickle operations.
64-
temp_path: pathlib.Path | ReadPickleBuffer
6564
if isinstance(_path, (str, pathlib.Path)):
66-
temp_path = pathlib.Path(tmpdir) / _path
65+
temp_path: FilePath = pathlib.Path(tmpdir) / _path
66+
pd.to_pickle(obj, temp_path)
6767
else:
68-
temp_path = _path
69-
pd.to_pickle(obj, temp_path)
70-
return pd.read_pickle(temp_path)
68+
# _path is a ReadPickleBuffer (file-like object)
69+
pd.to_pickle(obj, _path) # type: ignore[arg-type]
70+
71+
# For read_pickle, handle both cases
72+
if isinstance(_path, (str, pathlib.Path)):
73+
return pd.read_pickle(pathlib.Path(tmpdir) / _path)
74+
else:
75+
return pd.read_pickle(_path)
7176

7277

7378
def round_trip_pathlib(writer, reader, path: str | None = None):

0 commit comments

Comments
 (0)