Skip to content

Commit 9d0766c

Browse files
committed
Changed Path to pathlib.Path for compatibility with pybind11-stubgen
1 parent 2a7dda2 commit 9d0766c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

include/pybind11/stl/filesystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct path_caster {
106106
return true;
107107
}
108108

109-
PYBIND11_TYPE_CASTER(T, io_name("Union[os.PathLike, str, bytes]", "Path"));
109+
PYBIND11_TYPE_CASTER(T, io_name("Union[os.PathLike, str, bytes]", "pathlib.Path"));
110110
};
111111

112112
#endif // PYBIND11_HAS_FILESYSTEM || defined(PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM)

tests/test_stl.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,19 @@ def __fspath__(self):
265265
assert m.parent_path(PseudoBytesPath()) == Path("foo")
266266
assert (
267267
doc(m.parent_path)
268-
== "parent_path(arg0: Union[os.PathLike, str, bytes]) -> Path"
268+
== "parent_path(arg0: Union[os.PathLike, str, bytes]) -> pathlib.Path"
269269
)
270270
# std::vector
271271
assert m.parent_paths(["foo/bar", "foo/baz"]) == [Path("foo"), Path("foo")]
272272
assert (
273273
doc(m.parent_paths)
274-
== "parent_paths(arg0: list[Union[os.PathLike, str, bytes]]) -> list[Path]"
274+
== "parent_paths(arg0: list[Union[os.PathLike, str, bytes]]) -> list[pathlib.Path]"
275275
)
276276
# py::typing::List
277277
assert m.parent_paths_list(["foo/bar", "foo/baz"]) == [Path("foo"), Path("foo")]
278278
assert (
279279
doc(m.parent_paths_list)
280-
== "parent_paths_list(arg0: list[Union[os.PathLike, str, bytes]]) -> list[Path]"
280+
== "parent_paths_list(arg0: list[Union[os.PathLike, str, bytes]]) -> list[pathlib.Path]"
281281
)
282282
# Nested py::typing::List
283283
assert m.parent_paths_nested_list([["foo/bar"], ["foo/baz", "foo/buzz"]]) == [
@@ -286,13 +286,13 @@ def __fspath__(self):
286286
]
287287
assert (
288288
doc(m.parent_paths_nested_list)
289-
== "parent_paths_nested_list(arg0: list[list[Union[os.PathLike, str, bytes]]]) -> list[list[Path]]"
289+
== "parent_paths_nested_list(arg0: list[list[Union[os.PathLike, str, bytes]]]) -> list[list[pathlib.Path]]"
290290
)
291291
# py::typing::Tuple
292292
assert m.parent_paths_tuple(("foo/bar", "foo/baz")) == (Path("foo"), Path("foo"))
293293
assert (
294294
doc(m.parent_paths_tuple)
295-
== "parent_paths_tuple(arg0: tuple[Union[os.PathLike, str, bytes], Union[os.PathLike, str, bytes]]) -> tuple[Path, Path]"
295+
== "parent_paths_tuple(arg0: tuple[Union[os.PathLike, str, bytes], Union[os.PathLike, str, bytes]]) -> tuple[pathlib.Path, pathlib.Path]"
296296
)
297297
# py::typing::Dict
298298
assert m.parent_paths_dict(
@@ -308,7 +308,7 @@ def __fspath__(self):
308308
}
309309
assert (
310310
doc(m.parent_paths_dict)
311-
== "parent_paths_dict(arg0: dict[str, Union[os.PathLike, str, bytes]]) -> dict[str, Path]"
311+
== "parent_paths_dict(arg0: dict[str, Union[os.PathLike, str, bytes]]) -> dict[str, pathlib.Path]"
312312
)
313313

314314

0 commit comments

Comments
 (0)