From 9dd3eafa14b47052a0c88d0ffbdab0d98c0a4f92 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 26 May 2023 18:55:56 -0700 Subject: [PATCH] ansible-test - Use pylint unidiomatic-typecheck This replaces the regex based check previously used within the validate-modules sanity test. NOTE: The pylint check overlaps with a similar check for pep8. Both are used, since the pep8 based check is more nuanced than the one in pylint. For example, allowing `is` checks, but not `==` comparisons. If the pylint check is ignored, the pep8 check would still be relevant. --- .../ansible-test-unidiomatic-type-check.yml | 3 +++ .../sanity/pylint/config/collection.cfg | 1 - .../sanity/pylint/config/default.cfg | 1 - .../validate-modules/validate_modules/main.py | 19 ------------------- test/sanity/ignore.txt | 2 ++ 5 files changed, 5 insertions(+), 21 deletions(-) create mode 100644 changelogs/fragments/ansible-test-unidiomatic-type-check.yml diff --git a/changelogs/fragments/ansible-test-unidiomatic-type-check.yml b/changelogs/fragments/ansible-test-unidiomatic-type-check.yml new file mode 100644 index 00000000000..8f39e236b3c --- /dev/null +++ b/changelogs/fragments/ansible-test-unidiomatic-type-check.yml @@ -0,0 +1,3 @@ +minor_changes: + - ansible-test - The ``unidiomatic-typecheck`` rule has been removed from the ``validate-modules`` sanity test. + - ansible-test - The ``unidiomatic-typecheck`` rule has been enabled in the ``pylint`` sanity test. diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg index 762d488d77f..bb6c3e4d6a8 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg @@ -102,7 +102,6 @@ disable= undefined-loop-variable, unexpected-keyword-arg, ungrouped-imports, - unidiomatic-typecheck, unnecessary-pass, unnecessary-dunder-call, unsubscriptable-object, diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg index 825e5df79a5..6264948c285 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg @@ -95,7 +95,6 @@ disable= undefined-loop-variable, unexpected-keyword-arg, ungrouped-imports, - unidiomatic-typecheck, unnecessary-pass, unsubscriptable-object, unsupported-assignment-operation, diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py index 29107910453..d180d464b85 100644 --- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py +++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py @@ -94,7 +94,6 @@ REPLACER_WINDOWS = REPLACER_WINDOWS.decode('utf-8') REJECTLIST_DIRS = frozenset(('.git', 'test', '.github', '.idea')) INDENT_REGEX = re.compile(r'([\t]*)') -TYPE_REGEX = re.compile(r'.*(if|or)(\s+[^"\']*|\s+)(?