File tree 1 file changed +11
-9
lines changed 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -306,25 +306,27 @@ def initialize(self) -> None:
306
306
pass
307
307
308
308
async def get_attrdefs (self ) -> AttributeDefinitions :
309
- attrdefs_dicts = []
310
-
311
309
if self ._standard_attrdefs_cache is None :
312
310
self ._standard_attrdefs_cache = dict (await self .get_standard_attrdefs ())
313
- attrdefs_dicts .append (self ._standard_attrdefs_cache )
311
+ for name , attrdef in list (self ._standard_attrdefs_cache .items ()):
312
+ enabled = attrdef .get ('enabled' , True )
313
+ if callable (enabled ):
314
+ enabled = enabled (self )
315
+ if inspect .isawaitable (enabled ):
316
+ enabled = await enabled
317
+ if not enabled :
318
+ self ._standard_attrdefs_cache .pop (name )
319
+
314
320
if self ._additional_attrdefs_cache is None :
315
321
self ._additional_attrdefs_cache = dict (await self .get_additional_attrdefs ())
316
- attrdefs_dicts .append (self ._additional_attrdefs_cache )
317
-
318
- for attrdefs_dict in attrdefs_dicts :
319
- for name , attrdef in list (attrdefs_dict .items ()):
322
+ for name , attrdef in list (self ._additional_attrdefs_cache .items ()):
320
323
enabled = attrdef .get ('enabled' , True )
321
324
if callable (enabled ):
322
325
enabled = enabled (self )
323
326
if inspect .isawaitable (enabled ):
324
327
enabled = await enabled
325
-
326
328
if not enabled :
327
- attrdefs_dict .pop (name )
329
+ self . _additional_attrdefs_cache .pop (name )
328
330
329
331
return self ._standard_attrdefs_cache | self ._additional_attrdefs_cache
330
332
You can’t perform that action at this time.
0 commit comments