Provide filename and line number of variable which triggered the deprecation warning (#83322)

* Warning now shows line number and file in which the error occured
 Signed-off-by: Naya1217 <tbalthaz@redhat.com>
pull/83720/head
Naya1217 4 months ago committed by GitHub
parent d33bb8ebfd
commit 6a558de6e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,3 @@
bugfixes:
- Warning now includes filename and line number of variable
when specifying a list of dictionaries for vars (https://github.com/ansible/ansible/issues/82528).

@ -589,10 +589,11 @@ class FieldAttributeBase:
_validate_variable_keys(ds)
return combine_vars(self.vars, ds)
elif isinstance(ds, list):
line_file = getattr(ds, 'ansible_pos', ("unknown", 0))
display.deprecated(
(
'Specifying a list of dictionaries for vars is deprecated in favor of '
'specifying a dictionary.'
'specifying a dictionary. Error occurred in the file: %s, line: %d' % (line_file[0], line_file[1])
),
version='2.18'
)

Loading…
Cancel
Save