Change annotated_any() to quote_cpp_type_name()

This commit is contained in:
Ralf W. Grosse-Kunstleve 2023-12-16 16:45:59 -08:00
parent 6b771d548a
commit 813660cbd4
2 changed files with 4 additions and 4 deletions

View File

@ -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<std::string>() + '.'
+ th.attr("__qualname__").cast<std::string>();
}
return annotated_any(clean_type_id(ti.name()));
return quote_cpp_type_name(clean_type_id(ti.name()));
}
PYBIND11_NAMESPACE_END(detail)

View File

@ -492,7 +492,7 @@ protected:
signature += rec->scope.attr("__module__").cast<std::string>() + "."
+ rec->scope.attr("__qualname__").cast<std::string>();
} 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;