This commit is contained in:
gentlegiantJGC 2024-09-20 11:18:09 +01:00 committed by GitHub
commit 7775595943
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View File

@ -1010,11 +1010,19 @@ struct handle_type_name<weakref> {
}; };
template <> template <>
struct handle_type_name<args> { struct handle_type_name<args> {
static constexpr auto name = const_name("*args"); static constexpr auto name = const_name("*args: typing.Any");
};
template <typename T>
struct handle_type_name<Args<T>> {
static constexpr auto name = const_name("*args: ") + make_caster<T>::name;
}; };
template <> template <>
struct handle_type_name<kwargs> { struct handle_type_name<kwargs> {
static constexpr auto name = const_name("**kwargs"); static constexpr auto name = const_name("**kwargs: typing.Any");
};
template <typename T>
struct handle_type_name<KWArgs<T>> {
static constexpr auto name = const_name("**kwargs: ") + make_caster<T>::name;
}; };
template <> template <>
struct handle_type_name<obj_attr_accessor> { struct handle_type_name<obj_attr_accessor> {
@ -1570,9 +1578,9 @@ class argument_loader {
using indices = make_index_sequence<sizeof...(Args)>; using indices = make_index_sequence<sizeof...(Args)>;
template <typename Arg> template <typename Arg>
using argument_is_args = std::is_same<intrinsic_t<Arg>, args>; using argument_is_args = std::is_base_of<args, intrinsic_t<Arg>>;
template <typename Arg> template <typename Arg>
using argument_is_kwargs = std::is_same<intrinsic_t<Arg>, kwargs>; using argument_is_kwargs = std::is_base_of<kwargs, intrinsic_t<Arg>>;
// Get kwargs argument position, or -1 if not present: // Get kwargs argument position, or -1 if not present:
static constexpr auto kwargs_pos = constexpr_last<argument_is_kwargs, Args...>(); static constexpr auto kwargs_pos = constexpr_last<argument_is_kwargs, Args...>();

View File

@ -2216,6 +2216,16 @@ class kwargs : public dict {
PYBIND11_OBJECT_DEFAULT(kwargs, dict, PyDict_Check) PYBIND11_OBJECT_DEFAULT(kwargs, dict, PyDict_Check)
}; };
template <typename T>
class Args : public args {
using args::args;
};
template <typename T>
class KWArgs : public kwargs {
using kwargs::kwargs;
};
class anyset : public object { class anyset : public object {
public: public:
PYBIND11_OBJECT(anyset, object, PyAnySet_Check) PYBIND11_OBJECT(anyset, object, PyAnySet_Check)