From 87084a8de84efb31b75374f48cad5c8f1b41071b Mon Sep 17 00:00:00 2001 From: Tim Ohliger Date: Mon, 2 Sep 2024 14:48:10 +0200 Subject: [PATCH] Changed `fs::path` to be bound to `os.PathLike|str`. Strings are implicitly convertible to `fs::path`, but pybind11 just uses `os.PathLike` and not `os.PathLike | str` as type annotation. Python does not support implicit conversions for annotations, so this corrects the annotations to be explicit. --- cpp/pybind/pybind_filesystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/pybind/pybind_filesystem.h b/cpp/pybind/pybind_filesystem.h index 3617d6cad454..0bb468ae4155 100644 --- a/cpp/pybind/pybind_filesystem.h +++ b/cpp/pybind/pybind_filesystem.h @@ -99,7 +99,7 @@ struct path_caster { return true; } - PYBIND11_TYPE_CASTER(T, const_name("os.PathLike")); + PYBIND11_TYPE_CASTER(T, _("Union[os.PathLike, str]")); }; template <>