From 0a8d5c098367a58eaff10fd5b3868f099c1e17a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Tue, 9 Feb 2021 10:44:17 -0500 Subject: [PATCH] ansible-test: yamllint, check the assigment 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 --- .../ansible_test_yamllint_avoid_attribute_exception.yaml | 3 +++ test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ansible_test_yamllint_avoid_attribute_exception.yaml 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 00000000000..bd571d6cc6c --- /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 df13b4c38a3..b9fc73e59da 100644 --- a/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py +++ b/test/lib/ansible_test/_data/sanity/yamllint/yamllinter.py @@ -199,7 +199,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: