I have a class that accepts keyword arguments, something that was introduced together with __init_subclass__ in Python 3.6:
class Parent:
def __init_subclass__(cls, key=None, **kwargs):
super().__init_subclass__(**kwargs)
assert key is not None
class Child(Parent, key=5):
pass
Child2 = type("Child2", (Parent,), {})
But it gives an AssertionError since no key was passed. If I try to give an additional dictionary of arguments I get the following error:
>>> type("Child2", (Parent,), {}, {"key": 5})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: type() takes 1 or 3 arguments
And also the documentation on the type function do not allow for them to be specified. How can I pass these kwargs to __init_subclass__?