ansible-test: yamllint, check the assigment (#73583)

Ensure `yamllint`'s `check_assignment()` correctly ignore the
attribute assignment. Those don't have any `.id` attribute and will
trigger an `AttributeError` exception.

See: https://github.com/ansible/ansible/pull/73322
(cherry picked from commit 0a8d5c0983)
This commit is contained in:
Gonéri Le Bouder 2021-03-08 05:16:09 -05:00 committed by GitHub
parent ab8bbe269d
commit b1d278a595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- yamllint - do not raise an ``AttributeError`` if a value is assigned to a module attribute at the top of the module.

View file

@ -180,7 +180,7 @@ class YamlChecker:
def check_assignment(statement, doc_types=None):
"""Check the given statement for a documentation assignment."""
for target in statement.targets:
if isinstance(target, ast.Tuple):
if not isinstance(target, ast.Name):
continue
if doc_types and target.id not in doc_types: