[stable-2.14] Cache field attributes list on the playbook classes (#79091) (#81089)

* [stable-2.14] Cache field attributes list on the playbook classes (#79091)

* Cache field attributes list on the playbook classes
(cherry picked from commit 5863770)

Co-authored-by: Martin Krizek <martin.krizek@gmail.com>

* Replace deprecated stacked `@classmethod` and `@property` (#79952)

(cherry picked from commit 243d1b5e3d)

---------

Co-authored-by: Martin Krizek <martin.krizek@gmail.com>
pull/81187/head
Matt Martz 1 year ago committed by GitHub
parent 178acc3805
commit c8fe9a74a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- Cache field attributes list on the playbook classes

@ -0,0 +1,2 @@
minor_changes:
- Playbook objects - Replace deprecated stacked ``@classmethod`` and ``@property``

@ -10,6 +10,7 @@ import operator
import os
from copy import copy as shallowcopy
from functools import cache
from jinja2.exceptions import UndefinedError
@ -69,12 +70,21 @@ def _validate_action_group_metadata(action, found_group_metadata, fq_group_name)
display.warning(" ".join(metadata_warnings))
class _ClassProperty:
def __set_name__(self, owner, name):
self.name = name
def __get__(self, obj, objtype=None):
return getattr(objtype, f'_{self.name}')()
class FieldAttributeBase:
fattributes = _ClassProperty()
@classmethod
@property
def fattributes(cls):
# FIXME is this worth caching?
@cache
def _fattributes(cls):
fattributes = {}
for class_obj in reversed(cls.__mro__):
for name, attr in list(class_obj.__dict__.items()):

Loading…
Cancel
Save