-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(types) Support for inline generics #5268
base: master
Are you sure you want to change the base?
Conversation
Currently the following classes are seg faulting due to some error in their construction. Any ideas on how to properly create such classes? I tried some stuff with inheriting the constructor from class ParamSpec : public object {
PYBIND11_OBJECT_DEFAULT(ParamSpec, object, PyObject_Type)
using object::object;
ParamSpec(const char *name) {
attr("__name__") = name;
attr("__bound__") = pybind11::none();
}
};
class TypeVarTuple : public object {
PYBIND11_OBJECT_DEFAULT(TypeVarTuple, object, PyObject_Type)
using object::object;
TypeVarTuple(const char *name) { attr("__name__") = name; }
}; Error attached
|
Description
#5167
Expands upon the initial TypeVars to generate inline generics by putting typevars, paramspecs, or typevartuples, in the atrribute
__type_params__
where using the python3.12 inline generic syntax stores them. This should work for functions and classes. For more info on__type_params__
can be found here.Normal Python3.12 syntax.
Mocked by doing the following in pybind.
Suggested changelog entry: