@@ -347,9 +347,12 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
347347 return PyLong_FromUnsignedLongLong ((unsigned long long ) src);
348348 }
349349
350- PYBIND11_TYPE_CASTER (T,
351- io_name<std::is_integral<T>::value>(
352- " typing.SupportsInt" , " int" , " typing.SupportsFloat" , " float" ));
350+ PYBIND11_TYPE_CASTER (
351+ T,
352+ io_name<std::is_integral<T>::value>(" typing.SupportsInt | typing.SupportsIndex" ,
353+ " int" ,
354+ " typing.SupportsFloat | typing.SupportsIndex" ,
355+ " float" ));
353356};
354357
355358template <typename T>
@@ -1465,21 +1468,24 @@ template <>
14651468struct handle_type_name <weakref> {
14661469 static constexpr auto name = const_name(" weakref.ReferenceType" );
14671470};
1471+ // args/Args/kwargs/KWArgs have name as well as typehint included
14681472template <>
14691473struct handle_type_name <args> {
1470- static constexpr auto name = const_name (" *args" );
1474+ static constexpr auto name = io_name (" *args" , " tuple " );
14711475};
14721476template <typename T>
14731477struct handle_type_name <Args<T>> {
1474- static constexpr auto name = const_name(" *args: " ) + make_caster<T>::name;
1478+ static constexpr auto name
1479+ = io_name(" *args: " , " tuple[" ) + make_caster<T>::name + io_name(" " , " , ...]" );
14751480};
14761481template <>
14771482struct handle_type_name <kwargs> {
1478- static constexpr auto name = const_name (" **kwargs" );
1483+ static constexpr auto name = io_name (" **kwargs" , " dict[str, typing.Any] " );
14791484};
14801485template <typename T>
14811486struct handle_type_name <KWArgs<T>> {
1482- static constexpr auto name = const_name(" **kwargs: " ) + make_caster<T>::name;
1487+ static constexpr auto name
1488+ = io_name(" **kwargs: " , " dict[str, " ) + make_caster<T>::name + io_name(" " , " ]" );
14831489};
14841490template <>
14851491struct handle_type_name <obj_attr_accessor> {
@@ -1905,13 +1911,20 @@ inline cast_error cast_error_unable_to_convert_call_arg(const std::string &name,
19051911}
19061912#endif
19071913
1914+ namespace typing {
1915+ template <typename ... Types>
1916+ class Tuple : public tuple {
1917+ using tuple::tuple;
1918+ };
1919+ } // namespace typing
1920+
19081921template <return_value_policy policy = return_value_policy::automatic_reference>
1909- tuple make_tuple () {
1922+ typing::Tuple<> make_tuple () {
19101923 return tuple (0 );
19111924}
19121925
19131926template <return_value_policy policy = return_value_policy::automatic_reference, typename ... Args>
1914- tuple make_tuple (Args &&...args_) {
1927+ typing::Tuple<Args...> make_tuple (Args &&...args_) {
19151928 constexpr size_t size = sizeof ...(Args);
19161929 std::array<object, size> args{{reinterpret_steal<object>(
19171930 detail::make_caster<Args>::cast (std::forward<Args>(args_), policy, nullptr ))...}};
@@ -1930,7 +1943,12 @@ tuple make_tuple(Args &&...args_) {
19301943 for (auto &arg_value : args) {
19311944 PyTuple_SET_ITEM (result.ptr (), counter++, arg_value.release ().ptr ());
19321945 }
1946+ PYBIND11_WARNING_PUSH
1947+ #ifdef PYBIND11_DETECTED_CLANG_WITH_MISLEADING_CALL_STD_MOVE_EXPLICITLY_WARNING
1948+ PYBIND11_WARNING_DISABLE_CLANG (" -Wreturn-std-move" )
1949+ #endif
19331950 return result;
1951+ PYBIND11_WARNING_POP
19341952}
19351953
19361954// / \ingroup annotations
0 commit comments