From 813660cbd4f1638147ea420d1960206cdda01f9b Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 16 Dec 2023 16:45:59 -0800 Subject: [PATCH] Change `annotated_any()` to `quote_cpp_type_name()` --- include/pybind11/detail/type_caster_base.h | 6 +++--- include/pybind11/pybind11.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 697c94bdd..68c7d9c5a 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -1201,8 +1201,8 @@ protected: static Constructor make_move_constructor(...) { return nullptr; } }; -inline std::string annotated_any(const std::string &cpp_type) { - return "Annotated[Any, pybind11.CppType(\"" + cpp_type + "\")]"; +inline std::string quote_cpp_type_name(const std::string &cpp_type_name) { + return "`" + cpp_type_name + "`"; // See PR #4888 } PYBIND11_NOINLINE std::string type_info_description(const std::type_info &ti) { @@ -1211,7 +1211,7 @@ PYBIND11_NOINLINE std::string type_info_description(const std::type_info &ti) { return th.attr("__module__").cast() + '.' + th.attr("__qualname__").cast(); } - return annotated_any(clean_type_id(ti.name())); + return quote_cpp_type_name(clean_type_id(ti.name())); } PYBIND11_NAMESPACE_END(detail) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 84b415a68..bc2f5924a 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -492,7 +492,7 @@ protected: signature += rec->scope.attr("__module__").cast() + "." + rec->scope.attr("__qualname__").cast(); } else { - signature += detail::annotated_any(detail::clean_type_id(t->name())); + signature += detail::quote_cpp_type_name(detail::clean_type_id(t->name())); } } else { signature += c;