optimize reserved names warning

This commit is contained in:
Brian Coca 2017-08-17 15:50:04 -04:00 committed by Brian Coca
parent b3a57a4014
commit de16ce42ef

View file

@ -70,9 +70,11 @@ def get_reserved_names(include_private=True):
def warn_if_reserved(myvars):
''' this function warns if any variable passed conflicts with internally reserved names '''
reserved = get_reserved_names()
for varname in myvars:
if varname == 'vars':
continue # we add this one internally
if varname in reserved:
display.warning('Found variable using reserved name: %s' % varname)
varnames = set(myvars)
varnames.discard('vars') # we add this one internally, so safe to ignore
for varname in varnames.intersection(_RESERVED_NAMES):
display.warning('Found variable using reserved name: %s' % varname)
_RESERVED_NAMES = frozenset(get_reserved_names())