Guard against assignments that are not ast.Name in docs parsing (#35513)
This commit is contained in:
parent
ef34eb1a7d
commit
f659cc5963
2 changed files with 4 additions and 1 deletions
|
@ -191,7 +191,7 @@ def extract_metadata(module_ast=None, module_data=None, offsets=False):
|
|||
for root_idx, child in reversed(list(enumerate(module_ast.body))):
|
||||
if isinstance(child, ast.Assign):
|
||||
for target in child.targets:
|
||||
if target.id == 'ANSIBLE_METADATA':
|
||||
if isinstance(target, ast.Name) and target.id == 'ANSIBLE_METADATA':
|
||||
metadata = ast.literal_eval(child.value)
|
||||
if not offsets:
|
||||
continue
|
||||
|
|
|
@ -753,6 +753,9 @@ class ModuleValidator(Validator):
|
|||
for child in self.ast.body:
|
||||
if isinstance(child, ast.Assign):
|
||||
for grandchild in child.targets:
|
||||
if not isinstance(grandchild, ast.Name):
|
||||
continue
|
||||
|
||||
if grandchild.id == 'DOCUMENTATION':
|
||||
docs['DOCUMENTATION']['value'] = child.value.s
|
||||
docs['DOCUMENTATION']['lineno'] = child.lineno
|
||||
|
|
Loading…
Reference in a new issue