Don't terminate the super() chain in SubclassWithMeta.__init_subclass__

This commit is contained in:
Eero Ruohola 2020-07-21 23:35:01 +03:00
parent 485b1ed325
commit af595b1fe7
No known key found for this signature in database
GPG Key ID: DC40A970DAB939A5

View File

@ -19,7 +19,12 @@ class SubclassWithMeta(metaclass=SubclassWithMeta_Meta):
"""This class improves __init_subclass__ to receive automatically the options from meta"""
def __init_subclass__(cls, **meta_options):
"""This method just terminates the super() chain"""
"""Consume all the passed kwargs and cls's possible `Meta`.
The consumed kwargs and all of the attributes from `Meta`
will be passed for further processing to the next
`__init_subclass_with_meta__` in the method resolution order.
"""
_Meta = getattr(cls, "Meta", None)
_meta_props = {}
if _Meta:
@ -44,6 +49,7 @@ class SubclassWithMeta(metaclass=SubclassWithMeta_Meta):
super_class = super(cls, cls)
if hasattr(super_class, "__init_subclass_with_meta__"):
super_class.__init_subclass_with_meta__(**options)
super().__init_subclass__()
@classmethod
def __init_subclass_with_meta__(cls, **meta_options):