summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <mclay@redhat.com>2021-02-10 15:52:41 -0800
committerGitHub <noreply@github.com>2021-02-10 15:52:41 -0800
commit8a175f59c939ca29ad56f3fa9edbc37a8656879a (patch)
treea5a2373d686638abb92a4afd6e2e23a006f1f726
parent7cd577cc167ed017946e593fd17d70bf22f64b0d (diff)
downloadansible-8a175f59c939ca29ad56f3fa9edbc37a8656879a.tar.gz
Upgrade pylint used by ansible-test. (#70155)
* Upgrade pylint and deps in ansible-test. * Enable pylint on Python 3.9. * Update pylint config. * Add ignore for vendored six. * Add ignores for support plugins. * Fix issue reported by pylint.
-rw-r--r--changelogs/fragments/ansible-test-pylint-upgrade.yml5
-rw-r--r--test/integration/targets/ansible-test/ansible_collections/ns/col/plugins/filter/check_pylint.py2
-rw-r--r--test/integration/targets/ansible-test/ansible_collections/ns/col/tests/sanity/ignore.txt1
-rw-r--r--test/lib/ansible_test/_data/requirements/constraints.txt12
-rw-r--r--test/lib/ansible_test/_data/sanity/pylint/config/ansible-test.cfg3
-rw-r--r--test/lib/ansible_test/_data/sanity/pylint/config/collection.cfg5
-rw-r--r--test/lib/ansible_test/_data/sanity/pylint/config/default.cfg5
-rw-r--r--test/lib/ansible_test/_data/sanity/pylint/config/sanity.cfg3
-rw-r--r--test/lib/ansible_test/_internal/sanity/pylint.py8
-rwxr-xr-xtest/sanity/code-smell/rstcheck.py1
-rw-r--r--test/sanity/ignore.txt6
11 files changed, 36 insertions, 15 deletions
diff --git a/changelogs/fragments/ansible-test-pylint-upgrade.yml b/changelogs/fragments/ansible-test-pylint-upgrade.yml
new file mode 100644
index 0000000000..0026ad39f2
--- /dev/null
+++ b/changelogs/fragments/ansible-test-pylint-upgrade.yml
@@ -0,0 +1,5 @@
+minor_changes:
+ - ansible-test - Update ``pylint`` and its dependencies to the latest available versions to support Python 3.9.
+known_issues:
+ - ansible-test - The ``pylint`` sanity test no longer correctly detects "bad" variable names for non-constants.
+ See https://github.com/PyCQA/pylint/issues/3701 for additional details.
diff --git a/test/integration/targets/ansible-test/ansible_collections/ns/col/plugins/filter/check_pylint.py b/test/integration/targets/ansible-test/ansible_collections/ns/col/plugins/filter/check_pylint.py
index 359fbf071c..f1be4f3432 100644
--- a/test/integration/targets/ansible-test/ansible_collections/ns/col/plugins/filter/check_pylint.py
+++ b/test/integration/targets/ansible-test/ansible_collections/ns/col/plugins/filter/check_pylint.py
@@ -18,4 +18,6 @@ result = {None: None}[{}.get('something')]
# pylint 2.3.1 and 2.4.4 report the following error but 2.5.0 and 2.6.0 do not
# blacklisted-name: Black listed name "foo"
# see: https://github.com/PyCQA/pylint/issues/3701
+# regression: documented as a known issue and removed from ignore.txt so pylint can be upgraded to 2.6.0
+# if future versions of pylint fix this issue then the ignore should be restored
foo = {}.keys()
diff --git a/test/integration/targets/ansible-test/ansible_collections/ns/col/tests/sanity/ignore.txt b/test/integration/targets/ansible-test/ansible_collections/ns/col/tests/sanity/ignore.txt
index 079d01612a..6d7877ba1e 100644
--- a/test/integration/targets/ansible-test/ansible_collections/ns/col/tests/sanity/ignore.txt
+++ b/test/integration/targets/ansible-test/ansible_collections/ns/col/tests/sanity/ignore.txt
@@ -1,4 +1,3 @@
-plugins/filter/check_pylint.py pylint:blacklisted-name
plugins/modules/bad.py import
plugins/modules/bad.py pylint:ansible-bad-module-import
tests/integration/targets/hello/files/bad.py pylint:ansible-bad-function
diff --git a/test/lib/ansible_test/_data/requirements/constraints.txt b/test/lib/ansible_test/_data/requirements/constraints.txt
index 39a37af851..dc3cad2bfd 100644
--- a/test/lib/ansible_test/_data/requirements/constraints.txt
+++ b/test/lib/ansible_test/_data/requirements/constraints.txt
@@ -55,13 +55,15 @@ antsibull-changelog == 0.9.0
antsibull >= 0.21.0
# freeze pylint and its requirements for consistent test results
-astroid == 2.3.3
-isort == 4.3.15
+# NOTE: six is not frozen since it is a requirement for more than just pylint
+astroid == 2.4.2
+isort == 5.7.0
lazy-object-proxy == 1.4.3
mccabe == 0.6.1
-pylint == 2.3.1
-typed-ast == 1.4.1
-wrapt == 1.11.1
+pylint == 2.6.0
+toml == 0.10.2
+typed-ast == 1.4.2
+wrapt == 1.12.1
# freeze pycodestyle for consistent test results
pycodestyle == 2.6.0
diff --git a/test/lib/ansible_test/_data/sanity/pylint/config/ansible-test.cfg b/test/lib/ansible_test/_data/sanity/pylint/config/ansible-test.cfg
index 4b97ad46f7..5e9b593ca2 100644
--- a/test/lib/ansible_test/_data/sanity/pylint/config/ansible-test.cfg
+++ b/test/lib/ansible_test/_data/sanity/pylint/config/ansible-test.cfg
@@ -6,8 +6,11 @@ disable=
cyclic-import, # consistent results require running with --jobs 1 and testing all files
duplicate-code, # consistent results require running with --jobs 1 and testing all files
import-error, # inconsistent results which depend on the availability of imports
+ import-outside-toplevel, # common pattern in ansible related code
no-name-in-module, # inconsistent results which depend on the availability of imports
no-self-use,
+ raise-missing-from, # Python 2.x does not support raise from
+ super-with-arguments, # Python 2.x does not support super without arguments
too-few-public-methods,
too-many-ancestors, # inconsistent results between python 3.6 and 3.7+
too-many-arguments,
diff --git a/test/lib/ansible_test/_data/sanity/pylint/config/collection.cfg b/test/lib/ansible_test/_data/sanity/pylint/config/collection.cfg
index 2561730a51..03deb9685b 100644
--- a/test/lib/ansible_test/_data/sanity/pylint/config/collection.cfg
+++ b/test/lib/ansible_test/_data/sanity/pylint/config/collection.cfg
@@ -36,6 +36,7 @@ disable=
global-statement,
global-variable-undefined,
import-error, # inconsistent results which depend on the availability of imports
+ import-outside-toplevel, # common pattern in ansible related code
import-self,
inconsistent-return-statements,
invalid-envvar-default,
@@ -49,6 +50,8 @@ disable=
method-hidden,
misplaced-comparison-constant,
missing-docstring,
+ no-else-break,
+ no-else-continue,
no-else-raise,
no-else-return,
no-init,
@@ -65,6 +68,7 @@ disable=
pointless-string-statement,
possibly-unused-variable,
protected-access,
+ raise-missing-from, # Python 2.x does not support raise from
redefined-argument-from-local,
redefined-builtin,
redefined-outer-name,
@@ -76,6 +80,7 @@ disable=
simplifiable-if-statement,
subprocess-popen-preexec-fn,
super-init-not-called,
+ super-with-arguments, # Python 2.x does not support super without arguments
superfluous-parens,
too-few-public-methods,
too-many-ancestors, # inconsistent results between python 3.6 and 3.7+
diff --git a/test/lib/ansible_test/_data/sanity/pylint/config/default.cfg b/test/lib/ansible_test/_data/sanity/pylint/config/default.cfg
index b4062d4379..47951646ce 100644
--- a/test/lib/ansible_test/_data/sanity/pylint/config/default.cfg
+++ b/test/lib/ansible_test/_data/sanity/pylint/config/default.cfg
@@ -1,6 +1,7 @@
[MESSAGES CONTROL]
disable=
+ import-outside-toplevel, # common pattern in ansible related code
abstract-method,
access-member-before-definition,
arguments-differ,
@@ -49,6 +50,8 @@ disable=
method-hidden,
misplaced-comparison-constant,
missing-docstring,
+ no-else-break,
+ no-else-continue,
no-else-raise,
no-else-return,
no-init,
@@ -65,6 +68,7 @@ disable=
pointless-string-statement,
possibly-unused-variable,
protected-access,
+ raise-missing-from, # Python 2.x does not support raise from
redefined-argument-from-local,
redefined-builtin,
redefined-outer-name,
@@ -76,6 +80,7 @@ disable=
simplifiable-if-statement,
subprocess-popen-preexec-fn,
super-init-not-called,
+ super-with-arguments, # Python 2.x does not support super without arguments
superfluous-parens,
too-few-public-methods,
too-many-ancestors, # inconsistent results between python 3.6 and 3.7+
diff --git a/test/lib/ansible_test/_data/sanity/pylint/config/sanity.cfg b/test/lib/ansible_test/_data/sanity/pylint/config/sanity.cfg
index 1d7a4e696e..77f69b3e22 100644
--- a/test/lib/ansible_test/_data/sanity/pylint/config/sanity.cfg
+++ b/test/lib/ansible_test/_data/sanity/pylint/config/sanity.cfg
@@ -6,8 +6,11 @@ disable=
cyclic-import, # consistent results require running with --jobs 1 and testing all files
duplicate-code, # consistent results require running with --jobs 1 and testing all files
import-error, # inconsistent results which depend on the availability of imports
+ import-outside-toplevel, # common pattern in ansible related code
missing-docstring,
no-name-in-module, # inconsistent results which depend on the availability of imports
+ raise-missing-from, # Python 2.x does not support raise from
+ super-with-arguments, # Python 2.x does not support super without arguments
too-few-public-methods,
too-many-ancestors, # inconsistent results between python 3.6 and 3.7+
too-many-arguments,
diff --git a/test/lib/ansible_test/_internal/sanity/pylint.py b/test/lib/ansible_test/_internal/sanity/pylint.py
index 324e587346..769a171728 100644
--- a/test/lib/ansible_test/_internal/sanity/pylint.py
+++ b/test/lib/ansible_test/_internal/sanity/pylint.py
@@ -64,14 +64,6 @@ class PylintTest(SanitySingleVersion):
"""Error code for ansible-test matching the format used by the underlying test program, or None if the program does not use error codes."""
return 'ansible-test'
- @property
- def supported_python_versions(self): # type: () -> t.Optional[t.Tuple[str, ...]]
- """A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
- # Python 3.9 is not supported on pylint < 2.5.0.
- # Unfortunately pylint 2.5.0 and later include an unfixed regression.
- # See: https://github.com/PyCQA/pylint/issues/3701
- return tuple(python_version for python_version in super(PylintTest, self).supported_python_versions if python_version not in ('3.9',))
-
def filter_targets(self, targets): # type: (t.List[TestTarget]) -> t.List[TestTarget]
"""Return the given list of test targets, filtered to include only those relevant for the test."""
return [target for target in targets if os.path.splitext(target.path)[1] == '.py' or is_subdir(target.path, 'bin')]
diff --git a/test/sanity/code-smell/rstcheck.py b/test/sanity/code-smell/rstcheck.py
index 7866afa891..885659c3e4 100755
--- a/test/sanity/code-smell/rstcheck.py
+++ b/test/sanity/code-smell/rstcheck.py
@@ -28,6 +28,7 @@ def main():
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
+ check=False,
)
if process.stdout:
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 149f34e579..6a0510e234 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -72,6 +72,7 @@ lib/ansible/module_utils/six/__init__.py no-basestring
lib/ansible/module_utils/six/__init__.py no-dict-iteritems
lib/ansible/module_utils/six/__init__.py no-dict-iterkeys
lib/ansible/module_utils/six/__init__.py no-dict-itervalues
+lib/ansible/module_utils/six/__init__.py pylint:self-assigning-variable
lib/ansible/module_utils/six/__init__.py replace-urlopen
lib/ansible/module_utils/urls.py pylint:blacklisted-name
lib/ansible/module_utils/urls.py replace-urlopen
@@ -143,7 +144,6 @@ lib/ansible/plugins/lookup/sequence.py pylint:blacklisted-name
lib/ansible/plugins/strategy/__init__.py pylint:blacklisted-name
lib/ansible/plugins/strategy/linear.py pylint:blacklisted-name
lib/ansible/vars/hostvars.py pylint:blacklisted-name
-test/integration/targets/ansible-test/ansible_collections/ns/col/plugins/filter/check_pylint.py pylint:blacklisted-name
test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py pylint:relative-beyond-top-level
test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py pylint:relative-beyond-top-level
test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py pylint:relative-beyond-top-level
@@ -202,8 +202,10 @@ test/lib/ansible_test/_data/requirements/sanity.ps1 pslint:PSCustomUseLiteralPat
test/lib/ansible_test/_data/sanity/pylint/plugins/string_format.py use-compat-six
test/lib/ansible_test/_data/setup/ConfigureRemotingForAnsible.ps1 pslint:PSCustomUseLiteralPath
test/lib/ansible_test/_data/setup/windows-httptester.ps1 pslint:PSCustomUseLiteralPath
+test/support/integration/plugins/module_utils/aws/core.py pylint:property-with-parameters
test/support/integration/plugins/module_utils/cloud.py future-import-boilerplate
test/support/integration/plugins/module_utils/cloud.py metaclass-boilerplate
+test/support/integration/plugins/module_utils/cloud.py pylint:isinstance-second-argument-not-valid-type
test/support/integration/plugins/module_utils/compat/ipaddress.py future-import-boilerplate
test/support/integration/plugins/module_utils/compat/ipaddress.py metaclass-boilerplate
test/support/integration/plugins/module_utils/compat/ipaddress.py no-unicode-literals
@@ -212,6 +214,8 @@ test/support/integration/plugins/module_utils/database.py metaclass-boilerplate
test/support/integration/plugins/module_utils/mysql.py future-import-boilerplate
test/support/integration/plugins/module_utils/mysql.py metaclass-boilerplate
test/support/integration/plugins/module_utils/network/common/utils.py future-import-boilerplate
+test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py pylint:unnecessary-comprehension
+test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/netconf/default.py pylint:unnecessary-comprehension
test/support/integration/plugins/module_utils/network/common/utils.py metaclass-boilerplate
test/support/integration/plugins/module_utils/postgres.py future-import-boilerplate
test/support/integration/plugins/module_utils/postgres.py metaclass-boilerplate