mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00: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:
@@ -131,7 +131,9 @@ class BaseMeta(type):
|
||||
for parent in parents:
|
||||
if hasattr(parent, '__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
|
||||
dct['_attributes'] = dict()
|
||||
|
||||
Reference in New Issue
Block a user