diff options
author | Gonéri Le Bouder <goneri@lebouder.net> | 2021-03-07 23:38:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-07 22:38:05 -0600 |
commit | 462edf003ef6954a9b5dc58cbb793e3d7bab2116 (patch) | |
tree | 01c095c5c5ea7697abacd16be2a0d3fdb278a0d2 | |
parent | 8493662b8951e8c11ebd9aeff6e2f896184d0781 (diff) | |
download | ansible-462edf003ef6954a9b5dc58cbb793e3d7bab2116.tar.gz |
ansible-test: yamllint, check the assigment (#73584)
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 0a8d5c098367a58eaff10fd5b3868f099c1e17a7)
-rw-r--r-- | changelogs/fragments/ansible_test_yamllint_avoid_attribute_exception.yaml | 3 | ||||
-rwxr-xr-x | test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/changelogs/fragments/ansible_test_yamllint_avoid_attribute_exception.yaml b/changelogs/fragments/ansible_test_yamllint_avoid_attribute_exception.yaml new file mode 100644 index 0000000000..bd571d6cc6 --- /dev/null +++ b/changelogs/fragments/ansible_test_yamllint_avoid_attribute_exception.yaml @@ -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. diff --git a/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py b/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py index efde78a6d0..01e59011c4 100755 --- a/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py +++ b/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py @@ -128,7 +128,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: |