1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge class dict with parent dict when creating meta attributes

In some situations, where the Base class defines an Attribute, the
BaseMeta class doesn't properly see the _get_parent_attribute or
_get_attr_<whatever> methods because of multiple layers of subclasses
(ie. Handler, which subclasses Task). This addresses that by merging
the __dict__ of the parent with the current classes __dict__ meaning
all future iterations see available special methods.

Fixes #18378
This commit is contained in:
James Cammarata 2016-11-07 20:47:46 -06:00
parent 912d6ed8cc
commit 4794b5da45

View file

@ -131,7 +131,9 @@ class BaseMeta(type):
for parent in parents: for parent in parents:
if hasattr(parent, '__dict__'): if hasattr(parent, '__dict__'):
_create_attrs(parent.__dict__, dst_dict) _create_attrs(parent.__dict__, dst_dict)
_process_parents(parent.__bases__, dst_dict) new_dst_dict = parent.__dict__.copy()
new_dst_dict.update(dst_dict)
_process_parents(parent.__bases__, new_dst_dict)
# create some additional class attributes # create some additional class attributes
dct['_attributes'] = dict() dct['_attributes'] = dict()