diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index b6f26b966..6eb5ef277 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -703,7 +703,7 @@ struct smart_holder_type_caster : smart_holder_type_caster_load, template struct smart_holder_type_caster> : smart_holder_type_caster_load, smart_holder_type_caster_class_hooks { - static constexpr auto name = const_name>(); + static constexpr auto name = const_name(); static handle cast(const std::shared_ptr &src, return_value_policy policy, handle parent) { switch (policy) { @@ -760,7 +760,7 @@ struct smart_holder_type_caster> : smart_holder_type_caster_l template struct smart_holder_type_caster> : smart_holder_type_caster_load, smart_holder_type_caster_class_hooks { - static constexpr auto name = const_name>(); + static constexpr auto name = const_name(); static handle cast(const std::shared_ptr &src, return_value_policy policy, handle parent) { @@ -780,7 +780,7 @@ struct smart_holder_type_caster> : smart_holder_type_ca template struct smart_holder_type_caster> : smart_holder_type_caster_load, smart_holder_type_caster_class_hooks { - static constexpr auto name = const_name>(); + static constexpr auto name = const_name(); static handle cast(std::unique_ptr &&src, return_value_policy policy, handle parent) { if (policy != return_value_policy::automatic @@ -857,7 +857,7 @@ struct smart_holder_type_caster> : smart_holder_type_caste template struct smart_holder_type_caster> : smart_holder_type_caster_load, smart_holder_type_caster_class_hooks { - static constexpr auto name = const_name>(); + static constexpr auto name = const_name(); static handle cast(std::unique_ptr &&src, return_value_policy policy, handle parent) { diff --git a/tests/test_class_sh_basic.cpp b/tests/test_class_sh_basic.cpp index 21e307a2d..74dad47ad 100644 --- a/tests/test_class_sh_basic.cpp +++ b/tests/test_class_sh_basic.cpp @@ -154,6 +154,12 @@ TEST_SUBMODULE(class_sh_basic, m) { m.def("py_type_handle_of_atyp", []() { return py::type::handle_of(); // Exercises static_cast in this function. }); + + // Checks for type names used as arguments + m.def("args_shared_ptr", [](std::shared_ptr p) { return p; }); + m.def("args_shared_ptr_const", [](std::shared_ptr p) { return p; }); + m.def("args_unique_ptr", [](std::unique_ptr p) { return p; }); + m.def("args_unique_ptr_const", [](std::unique_ptr p) { return p; }); } } // namespace class_sh_basic diff --git a/tests/test_class_sh_basic.py b/tests/test_class_sh_basic.py index 3727dcdb5..ba407a46a 100644 --- a/tests/test_class_sh_basic.py +++ b/tests/test_class_sh_basic.py @@ -163,3 +163,22 @@ def test_unique_ptr_consumer_roundtrip(pass_f, rtrn_f, moved_out, moved_in): def test_py_type_handle_of_atyp(): obj = m.py_type_handle_of_atyp() assert obj.__class__.__name__ == "pybind11_type" + + +def test_function_signatures(doc): + assert ( + doc(m.args_shared_ptr) + == "args_shared_ptr(arg0: m.class_sh_basic.atyp) -> m.class_sh_basic.atyp" + ) + assert ( + doc(m.args_shared_ptr_const) + == "args_shared_ptr_const(arg0: m.class_sh_basic.atyp) -> m.class_sh_basic.atyp" + ) + assert ( + doc(m.args_unique_ptr) + == "args_unique_ptr(arg0: m.class_sh_basic.atyp) -> m.class_sh_basic.atyp" + ) + assert ( + doc(m.args_unique_ptr_const) + == "args_unique_ptr_const(arg0: m.class_sh_basic.atyp) -> m.class_sh_basic.atyp" + )