Applied pre-commit formatting.

This commit is contained in:
Tim Ohliger 2024-09-06 15:24:25 +02:00
parent 7e7f9ce67b
commit e8aa81bd9a
2 changed files with 12 additions and 12 deletions

View File

@ -115,14 +115,12 @@ struct is_descr<const descr<N, Ts...>> : std::true_type {};
/// this is useful for having a different python type hint for args vs return value,
/// e.g., `std::filesystem::path` -> Arg: `Union[os.PathLike, str, bytes]`, return: `Path`.
template <typename T, typename Enable = void>
struct as_return_type
{
struct as_return_type {
static constexpr auto name = T::name;
};
template <typename T>
struct as_return_type<T, typename std::enable_if_t<is_descr<decltype(T::return_name)>::value>>
{
struct as_return_type<T, typename std::enable_if_t<is_descr<decltype(T::return_name)>::value>> {
static constexpr auto name = T::return_name;
};
@ -344,9 +342,8 @@ protected:
/* Generate a readable signature describing the function's arguments and return
value types */
static constexpr auto signature
= const_name("(") + cast_in::arg_names + const_name(") -> ")
+ as_return_type<cast_out>::name;
static constexpr auto signature = const_name("(") + cast_in::arg_names
+ const_name(") -> ") + as_return_type<cast_out>::name;
PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types();
/* Register the function with Python from generic (non-templated) code */

View File

@ -261,7 +261,10 @@ def test_fs_path(doc):
assert m.parent_path(b"foo/bar") == Path("foo")
assert m.parent_path(PseudoStrPath()) == Path("foo")
assert m.parent_path(PseudoBytesPath()) == Path("foo")
assert doc(m.parent_path) == "parent_path(arg0: Union[os.PathLike, str, bytes]) -> Path"
assert (
doc(m.parent_path)
== "parent_path(arg0: Union[os.PathLike, str, bytes]) -> Path"
)
@pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no <variant>")