@@ -55,6 +55,10 @@ def _is_derived(cls, name, bases):
5555 # This is not derived at all from Resource (eg. is base).
5656 return False
5757
58+ @classmethod
59+ def _get_attributes_dict (cls , obj ):
60+ return {n : getattr (obj , n ) for n in dir (obj )}
61+
5862 def __new__ (cls , name , bases , attrs ):
5963 # Only continue if we are dervied from declarative.
6064 if not cls ._is_derived (name , bases ):
@@ -64,20 +68,19 @@ def __new__(cls, name, bases, attrs):
6468 # Gather the attributes of all options classes.
6569 # Start with the base configuration.
6670 metadata = {}
67- values = lambda x : {n : getattr (x , n ) for n in dir (x )}
6871
6972 # Expand the options class with the gathered metadata.
7073 base_meta = []
7174 cls ._gather_metadata (base_meta , bases )
7275
7376 # Apply the configuration from each class in the chain.
7477 for meta in base_meta :
75- metadata .update (** values (meta ))
78+ metadata .update (** cls . _get_attributes_dict (meta ))
7679
7780 # Apply the configuration from the current class.
7881 cur_meta = {}
7982 if attrs .get ('Meta' ):
80- cur_meta = values (attrs ['Meta' ])
83+ cur_meta = cls . _get_attributes_dict (attrs ['Meta' ])
8184 metadata .update (** cur_meta )
8285
8386 # Gather and construct the options object.
@@ -93,8 +96,8 @@ def __new__(cls, name, bases, attrs):
9396 attrs ['_items' ].update (values )
9497
9598 # Collect attributes from current class.
96- test = lambda x : issubclass (type (x [1 ]), Component )
97- attrs_l = list ( filter ( test , attrs .items ()))
99+ attrs_l = list ( filter ( lambda x : issubclass (type (x [1 ]), Component ),
100+ attrs .items ()))
98101 attrs_l .sort (key = lambda x : x [1 ].creation_counter )
99102 for key , attr in attrs_l :
100103 # If name reference is null; default to camel-cased name.
0 commit comments