Added type hinted args and kwargs classes

This commit is contained in:
gentlegiantJGC 2024-09-06 13:40:10 +01:00
parent 2bf09e21db
commit 862b807adf
2 changed files with 16 additions and 0 deletions

View File

@ -1012,11 +1012,17 @@ template <>
struct handle_type_name<args> { struct handle_type_name<args> {
static constexpr auto name = const_name("*args: ") + make_caster<object>::name; static constexpr auto name = const_name("*args: ") + make_caster<object>::name;
}; };
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: ") + make_caster<object>::name; static constexpr auto name = const_name("**kwargs: ") + make_caster<object>::name;
}; };
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> {

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)