@@ -1037,12 +1037,14 @@ TEST_SUBMODULE(pytypes, m) {
10371037 m.attr (" defined_PYBIND11_TEST_PYTYPES_HAS_RANGES" ) = false ;
10381038#endif
10391039 m.def (" half_of_number" , [](const RealNumber &x) { return RealNumber{x.value / 2 }; });
1040+ // Tuple<T, T>
10401041 m.def (" half_of_number_tuple" , [](const py::typing::Tuple<RealNumber, RealNumber> &x) {
10411042 py::typing::Tuple<RealNumber, RealNumber> result
10421043 = py::make_tuple (RealNumber{x[0 ].cast <RealNumber>().value / 2 },
10431044 RealNumber{x[1 ].cast <RealNumber>().value / 2 });
10441045 return result;
10451046 });
1047+ // Tuple<T, ...>
10461048 m.def (" half_of_number_tuple_ellipsis" ,
10471049 [](const py::typing::Tuple<RealNumber, py::ellipsis> &x) {
10481050 py::typing::Tuple<RealNumber, py::ellipsis> result (x.size ());
@@ -1051,13 +1053,23 @@ TEST_SUBMODULE(pytypes, m) {
10511053 }
10521054 return result;
10531055 });
1056+ // Dict<K, V>
1057+ m.def (" half_of_number_dict" , [](const py::typing::Dict<std::string, RealNumber> &x) {
1058+ py::typing::Dict<std::string, RealNumber> result;
1059+ for (auto it : x) {
1060+ result[it.first ] = RealNumber{it.second .cast <RealNumber>().value / 2 };
1061+ }
1062+ return result;
1063+ });
1064+ // List<T>
10541065 m.def (" half_of_number_list" , [](const py::typing::List<RealNumber> &x) {
10551066 py::typing::List<RealNumber> result;
10561067 for (auto num : x) {
10571068 result.append (RealNumber{num.cast <RealNumber>().value / 2 });
10581069 }
10591070 return result;
10601071 });
1072+ // List<List<T>>
10611073 m.def (" half_of_number_nested_list" ,
10621074 [](const py::typing::List<py::typing::List<RealNumber>> &x) {
10631075 py::typing::List<py::typing::List<RealNumber>> result_lists;
@@ -1070,11 +1082,25 @@ TEST_SUBMODULE(pytypes, m) {
10701082 }
10711083 return result_lists;
10721084 });
1073- m.def (" half_of_number_dict" , [](const py::typing::Dict<std::string, RealNumber> &x) {
1074- py::typing::Dict<std::string, RealNumber> result;
1075- for (auto it : x) {
1076- result[it.first ] = RealNumber{it.second .cast <RealNumber>().value / 2 };
1077- }
1078- return result;
1079- });
1085+ // Set<T>
1086+ m.def (" identity_set" , [](const py::typing::Set<RealNumber> &x) { return x; });
1087+ // Iterable<T>
1088+ m.def (" identity_iterable" , [](const py::typing::Iterable<RealNumber> &x) { return x; });
1089+ // Iterator<T>
1090+ m.def (" identity_iterator" , [](const py::typing::Iterator<RealNumber> &x) { return x; });
1091+ // Callable<R(A)>
1092+ // m.def("get_identity_callable", []() -> py::typing::Callable<RealNumber(const RealNumber &)>
1093+ // { return [](const RealNumber &x) { return x; };
1094+ // });
1095+ // Callable<R(...)>
1096+ // m.def("get_identity_callable_only_return",
1097+ // []() -> py::typing::Callable<RealNumber(py::ellipsis)> {
1098+ // return [](const RealNumber &x) { return x; };
1099+ // });
1100+ // Union<T1, T2>
1101+ m.def (" identity_union" , [](const py::typing::Union<RealNumber, std::string> &x) { return x; });
1102+ // Optional<T>
1103+ m.def (" identity_optional" , [](const py::typing::Optional<RealNumber> &x) { return x; });
1104+ // TypeGuard<T>
1105+ // TypeIs<T>
10801106}
0 commit comments