mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -07:00
Adding aliases for field attributes and renaming async attribute (#33141)
* Adding aliases for field attributes and renaming async attribute As of Python 3.7, the use of async raises an error, whereas before the use of the reserved word was ignored. This adds an alias field for field attrs so that both async and async_val (interally) work. This allows us to be backwards-compatible with 3rd party plugins that may still reference Task.async, but for the core engine to work on Py3.7+. * Remove files fixed for 'async' usage from the python 3.7 skip list
This commit is contained in:
parent
23f8833e87
commit
d8ae4dfbf2
14 changed files with 43 additions and 36 deletions
|
@ -25,7 +25,7 @@ from copy import deepcopy
|
|||
class Attribute:
|
||||
|
||||
def __init__(self, isa=None, private=False, default=None, required=False, listof=None, priority=0, class_type=None, always_post_validate=False,
|
||||
inherit=True):
|
||||
inherit=True, alias=None):
|
||||
"""
|
||||
:class:`Attribute` specifies constraints for attributes of objects which
|
||||
derive from playbook data. The attributes of the object are basically
|
||||
|
@ -53,6 +53,8 @@ class Attribute:
|
|||
:kwarg inherit: A boolean value, which controls whether the object
|
||||
containing this field should attempt to inherit the value from its
|
||||
parent object if the local value is None.
|
||||
:kwarg alias: An alias to use for the attribute name, for situations where
|
||||
the attribute name may conflict with a Python reserved word.
|
||||
"""
|
||||
|
||||
self.isa = isa
|
||||
|
@ -64,6 +66,7 @@ class Attribute:
|
|||
self.class_type = class_type
|
||||
self.always_post_validate = always_post_validate
|
||||
self.inherit = inherit
|
||||
self.alias = alias
|
||||
|
||||
if default is not None and self.isa in ('list', 'dict', 'set'):
|
||||
self.default = deepcopy(default)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue