summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonéri Le Bouder <goneri@lebouder.net>2021-03-08 05:16:09 -0500
committerGitHub <noreply@github.com>2021-03-08 04:16:09 -0600
commitb1d278a5958a81dbcd12184f3e5d638f1d948481 (patch)
treeb1ff95596e86cea96dcf326d85887f02f9d2c563
parentab8bbe269de93d2e7ce511b4f8d0bd635f917223 (diff)
downloadansible-b1d278a5958a81dbcd12184f3e5d638f1d948481.tar.gz
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 0a8d5c098367a58eaff10fd5b3868f099c1e17a7)
-rw-r--r--changelogs/fragments/ansible_test_yamllint_avoid_attribute_exception.yaml3
-rw-r--r--test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py2
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 933debe707..c9cdc19ce1 100644
--- a/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py
+++ b/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py
@@ -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: