mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
optimize reserved names warning
This commit is contained in:
parent
b3a57a4014
commit
de16ce42ef
1 changed files with 8 additions and 6 deletions
|
@ -70,9 +70,11 @@ def get_reserved_names(include_private=True):
|
||||||
|
|
||||||
def warn_if_reserved(myvars):
|
def warn_if_reserved(myvars):
|
||||||
''' this function warns if any variable passed conflicts with internally reserved names '''
|
''' this function warns if any variable passed conflicts with internally reserved names '''
|
||||||
reserved = get_reserved_names()
|
|
||||||
for varname in myvars:
|
varnames = set(myvars)
|
||||||
if varname == 'vars':
|
varnames.discard('vars') # we add this one internally, so safe to ignore
|
||||||
continue # we add this one internally
|
for varname in varnames.intersection(_RESERVED_NAMES):
|
||||||
if varname in reserved:
|
display.warning('Found variable using reserved name: %s' % varname)
|
||||||
display.warning('Found variable using reserved name: %s' % varname)
|
|
||||||
|
|
||||||
|
_RESERVED_NAMES = frozenset(get_reserved_names())
|
||||||
|
|
Loading…
Reference in a new issue