Add Annotated[Any, "..."] wrapping in type_info_description()

This commit is contained in:
Ralf W. Grosse-Kunstleve 2023-11-14 13:50:20 -08:00
parent 61ee34ee07
commit 11040768ca
2 changed files with 5 additions and 5 deletions

View File

@ -1207,7 +1207,7 @@ PYBIND11_NOINLINE std::string type_info_description(const std::type_info &ti) {
return th.attr("__module__").cast<std::string>() + '.' return th.attr("__module__").cast<std::string>() + '.'
+ th.attr("__qualname__").cast<std::string>(); + th.attr("__qualname__").cast<std::string>();
} }
return clean_type_id(ti.name()); return "Annotated[Any, \"" + clean_type_id(ti.name()) + "\"]";
} }
PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(detail)

View File

@ -21,15 +21,15 @@ from pybind11_tests import stl as test_stl
), ),
( (
m.MapIntUserType.values.__doc__, m.MapIntUserType.values.__doc__,
"values(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ValuesView[test_cases_for_stubgen::user_type]\n", 'values(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ValuesView[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
), ),
( (
m.MapIntUserType.items.__doc__, m.MapIntUserType.items.__doc__,
"items(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ItemsView[int, test_cases_for_stubgen::user_type]\n", 'items(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ItemsView[int, Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
), ),
( (
m.MapUserTypeInt.keys.__doc__, m.MapUserTypeInt.keys.__doc__,
"keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.KeysView[test_cases_for_stubgen::user_type]\n", 'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.KeysView[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
), ),
( (
m.MapUserTypeInt.values.__doc__, m.MapUserTypeInt.values.__doc__,
@ -37,7 +37,7 @@ from pybind11_tests import stl as test_stl
), ),
( (
m.MapUserTypeInt.items.__doc__, m.MapUserTypeInt.items.__doc__,
"items(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ItemsView[test_cases_for_stubgen::user_type, int]\n", 'items(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ItemsView[Annotated[Any, "test_cases_for_stubgen::user_type"], int]\n',
), ),
( (
m.MapFloatUserType.keys.__doc__, m.MapFloatUserType.keys.__doc__,