Skip to content

Commit de81cb9

Browse files
committed
Fix mypy and Windows path error
1 parent 6ffbe40 commit de81cb9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pandas/io/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def get_handle(
714714
assert not isinstance(handle, str)
715715
handles.append(handle)
716716

717-
elif is_path:
717+
elif isinstance(handle, str):
718718
# Check whether the filename is to be opened in binary mode.
719719
# Binary mode does not support 'encoding' and 'newline'.
720720
if ioargs.encoding and "b" not in ioargs.mode:

pandas/tests/io/xml/test_to_xml.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
StringIO,
66
)
77
import os
8+
from pathlib import Path
89

910
import numpy as np
1011
import pytest
@@ -202,14 +203,14 @@ def test_str_output(datapath, parser):
202203

203204

204205
def test_wrong_file_path(parser):
205-
fpath = "/my/fake/path/output.xml"
206-
dirname = os.path.dirname(fpath)
206+
path = "/my/fake/path/output.xml"
207+
parent = Path(path).parent
207208

208209
with pytest.raises(
209210
OSError,
210-
match=(fr"Cannot save file into a non-existent directory: '{dirname}'"),
211+
match=(fr"Cannot save file into a non-existent directory: '{parent}'"),
211212
):
212-
geom_df.to_xml(fpath, parser=parser)
213+
geom_df.to_xml(path, parser=parser)
213214

214215

215216
# INDEX

0 commit comments

Comments
 (0)