diff --git a/tests/test_cases_for_stubgen.cpp b/tests/test_cases_for_stubgen.cpp index 9bbbcbd07..43a87e0be 100644 --- a/tests/test_cases_for_stubgen.cpp +++ b/tests/test_cases_for_stubgen.cpp @@ -5,25 +5,25 @@ namespace test_cases_for_stubgen { -struct user_type { - bool operator<(const user_type &) const { return false; } +struct UserType { + bool operator<(const UserType &) const { return false; } }; struct minimal_caster { - static constexpr auto name = py::detail::const_name(); + static constexpr auto name = py::detail::const_name(); static py::handle - cast(user_type const & /*src*/, py::return_value_policy /*policy*/, py::handle /*parent*/) { + cast(UserType const & /*src*/, py::return_value_policy /*policy*/, py::handle /*parent*/) { return py::none().release(); } // Maximizing simplicity. This will go terribly wrong for other arg types. template - using cast_op_type = const user_type &; + using cast_op_type = const UserType &; // NOLINTNEXTLINE(google-explicit-constructor) - operator user_type const &() { - static user_type obj; + operator UserType const &() { + static UserType obj; return obj; } @@ -36,19 +36,19 @@ namespace pybind11 { namespace detail { template <> -struct type_caster : test_cases_for_stubgen::minimal_caster {}; +struct type_caster : test_cases_for_stubgen::minimal_caster {}; } // namespace detail } // namespace pybind11 TEST_SUBMODULE(cases_for_stubgen, m) { - using namespace test_cases_for_stubgen; + using UserType = test_cases_for_stubgen::UserType; - m.def("pass_user_type", [](const user_type &) {}); - m.def("return_user_type", []() { return user_type(); }); + m.def("pass_user_type", [](const UserType &) {}); + m.def("return_user_type", []() { return UserType(); }); - py::bind_map>(m, "MapIntUserType"); - py::bind_map>(m, "MapUserTypeInt"); + py::bind_map>(m, "MapIntUserType"); + py::bind_map>(m, "MapUserTypeInt"); #define MAP_TYPE(MapTypePythonName, ...) \ py::class_<__VA_ARGS__>(m, MapTypePythonName) \ @@ -65,8 +65,8 @@ TEST_SUBMODULE(cases_for_stubgen, m) { [](const __VA_ARGS__ &v) { return py::make_iterator(v.begin(), v.end()); }, \ py::keep_alive<0, 1>()) - MAP_TYPE("MapFloatUserType", std::map); - MAP_TYPE("MapUserTypeFloat", std::map); + MAP_TYPE("MapFloatUserType", std::map); + MAP_TYPE("MapUserTypeFloat", std::map); #undef MAP_TYPE } diff --git a/tests/test_cases_for_stubgen.py b/tests/test_cases_for_stubgen.py index e57e038ce..24508ac21 100644 --- a/tests/test_cases_for_stubgen.py +++ b/tests/test_cases_for_stubgen.py @@ -9,11 +9,11 @@ from pybind11_tests import stl as test_stl [ ( m.pass_user_type.__doc__, - 'pass_user_type(arg0: Annotated[Any, "test_cases_for_stubgen::user_type"]) -> None\n', + 'pass_user_type(arg0: Annotated[Any, "test_cases_for_stubgen::UserType"]) -> None\n', ), ( m.return_user_type.__doc__, - 'return_user_type() -> Annotated[Any, "test_cases_for_stubgen::user_type"]\n', + 'return_user_type() -> Annotated[Any, "test_cases_for_stubgen::UserType"]\n', ), ( m.MapIntUserType.keys.__doc__, @@ -21,15 +21,15 @@ from pybind11_tests import stl as test_stl ), ( m.MapIntUserType.values.__doc__, - 'values(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ValuesView[Annotated[Any, "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::UserType"]]\n', ), ( m.MapIntUserType.items.__doc__, - 'items(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ItemsView[int, Annotated[Any, "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::UserType"]]\n', ), ( m.MapUserTypeInt.keys.__doc__, - 'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.KeysView[Annotated[Any, "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::UserType"]]\n', ), ( m.MapUserTypeInt.values.__doc__, @@ -37,7 +37,7 @@ from pybind11_tests import stl as test_stl ), ( m.MapUserTypeInt.items.__doc__, - 'items(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ItemsView[Annotated[Any, "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::UserType"], int]\n', ), ( m.MapFloatUserType.keys.__doc__, @@ -45,15 +45,15 @@ from pybind11_tests import stl as test_stl ), ( m.MapFloatUserType.values.__doc__, - 'values(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n', + 'values(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[Annotated[Any, "test_cases_for_stubgen::UserType"]]\n', ), ( m.MapFloatUserType.__iter__.__doc__, - '__iter__(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[tuple[float, Annotated[Any, "test_cases_for_stubgen::user_type"]]]\n', + '__iter__(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[tuple[float, Annotated[Any, "test_cases_for_stubgen::UserType"]]]\n', ), ( m.MapUserTypeFloat.keys.__doc__, - 'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n', + 'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[Annotated[Any, "test_cases_for_stubgen::UserType"]]\n', ), ( m.MapUserTypeFloat.values.__doc__, @@ -61,7 +61,7 @@ from pybind11_tests import stl as test_stl ), ( m.MapUserTypeFloat.__iter__.__doc__, - '__iter__(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[tuple[Annotated[Any, "test_cases_for_stubgen::user_type"], float]]\n', + '__iter__(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[tuple[Annotated[Any, "test_cases_for_stubgen::UserType"], float]]\n', ), ( test_stl.cast_array.__doc__,