diff options
author | Matt Clay <matt@mystile.com> | 2024-10-03 18:59:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-03 18:59:56 +0200 |
commit | 9406ed31090120afedce866a6b2c16277efae832 (patch) | |
tree | 9e3e858a2eb0929d5db974aeb2983a6f049b2dac /test/lib | |
parent | Reduce number of implicit meta tasks (#84007) (diff) | |
download | ansible-9406ed31090120afedce866a6b2c16277efae832.tar.xz ansible-9406ed31090120afedce866a6b2c16277efae832.zip |
ansible-test - Update sanity tests and default Python (#83998)
* ansible-test - Update sanity test requirements
* ansible-test - Default to Python 3.13 in base/default containers
* ansible-test - Fix incorrect AnyStr type hints
Diffstat (limited to 'test/lib')
9 files changed, 20 insertions, 15 deletions
diff --git a/test/lib/ansible_test/_data/completion/docker.txt b/test/lib/ansible_test/_data/completion/docker.txt index d997693532..2d59ffd1d7 100644 --- a/test/lib/ansible_test/_data/completion/docker.txt +++ b/test/lib/ansible_test/_data/completion/docker.txt @@ -1,6 +1,6 @@ -base image=quay.io/ansible/base-test-container:7.5.0 python=3.12,3.8,3.9,3.10,3.11,3.13 -default image=quay.io/ansible/default-test-container:10.5.0 python=3.12,3.8,3.9,3.10,3.11,3.13 context=collection -default image=quay.io/ansible/ansible-core-test-container:10.5.0 python=3.12,3.8,3.9,3.10,3.11,3.13 context=ansible-core +base image=quay.io/ansible/base-test-container:7.5.0 python=3.13,3.8,3.9,3.10,3.11,3.12 +default image=quay.io/ansible/default-test-container:10.5.0 python=3.13,3.8,3.9,3.10,3.11,3.12 context=collection +default image=quay.io/ansible/ansible-core-test-container:10.5.0 python=3.13,3.8,3.9,3.10,3.11,3.12 context=ansible-core alpine320 image=quay.io/ansible/alpine320-test-container:8.1.0 python=3.12 cgroup=none audit=none fedora40 image=quay.io/ansible/fedora40-test-container:8.1.0 python=3.12 ubuntu2204 image=quay.io/ansible/ubuntu2204-test-container:8.1.0 python=3.10 diff --git a/test/lib/ansible_test/_data/requirements/sanity.pylint.txt b/test/lib/ansible_test/_data/requirements/sanity.pylint.txt index 60490bc7da..a34c949550 100644 --- a/test/lib/ansible_test/_data/requirements/sanity.pylint.txt +++ b/test/lib/ansible_test/_data/requirements/sanity.pylint.txt @@ -1,9 +1,9 @@ # edit "sanity.pylint.in" and generate with: hacking/update-sanity-requirements.py --test pylint -astroid==3.2.4 -dill==0.3.8 +astroid==3.3.4 +dill==0.3.9 isort==5.13.2 mccabe==0.7.0 -platformdirs==4.3.2 -pylint==3.2.7 +platformdirs==4.3.6 +pylint==3.3.1 PyYAML==6.0.2 tomlkit==0.13.2 diff --git a/test/lib/ansible_test/_internal/encoding.py b/test/lib/ansible_test/_internal/encoding.py index 11f0d75c26..476c59025e 100644 --- a/test/lib/ansible_test/_internal/encoding.py +++ b/test/lib/ansible_test/_internal/encoding.py @@ -6,17 +6,17 @@ import typing as t ENCODING = 'utf-8' -def to_optional_bytes(value: t.Optional[t.AnyStr], errors: str = 'strict') -> t.Optional[bytes]: +def to_optional_bytes(value: t.Optional[str | bytes], errors: str = 'strict') -> t.Optional[bytes]: """Return the given value as bytes encoded using UTF-8 if not already bytes, or None if the value is None.""" return None if value is None else to_bytes(value, errors) -def to_optional_text(value: t.Optional[t.AnyStr], errors: str = 'strict') -> t.Optional[str]: +def to_optional_text(value: t.Optional[str | bytes], errors: str = 'strict') -> t.Optional[str]: """Return the given value as text decoded using UTF-8 if not already text, or None if the value is None.""" return None if value is None else to_text(value, errors) -def to_bytes(value: t.AnyStr, errors: str = 'strict') -> bytes: +def to_bytes(value: str | bytes, errors: str = 'strict') -> bytes: """Return the given value as bytes encoded using UTF-8 if not already bytes.""" if isinstance(value, bytes): return value @@ -27,7 +27,7 @@ def to_bytes(value: t.AnyStr, errors: str = 'strict') -> bytes: raise Exception('value is not bytes or text: %s' % type(value)) -def to_text(value: t.AnyStr, errors: str = 'strict') -> str: +def to_text(value: str | bytes, errors: str = 'strict') -> str: """Return the given value as text decoded using UTF-8 if not already text.""" if isinstance(value, bytes): return value.decode(ENCODING, errors) diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg index 51d0bb01d3..0f42d75961 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg @@ -20,6 +20,7 @@ disable= too-many-nested-blocks, too-many-return-statements, too-many-statements, + too-many-positional-arguments, use-dict-literal, # ignoring as a common style issue useless-return, # complains about returning None when the return type is optional diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg index 801adbe145..6067069dc5 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg @@ -18,6 +18,7 @@ disable= too-many-nested-blocks, too-many-return-statements, too-many-statements, + too-many-positional-arguments, use-dict-literal, # ignoring as a common style issue unspecified-encoding, # always run with UTF-8 encoding enforced useless-return, # complains about returning None when the return type is optional diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg index adc0b95e94..39ed050eef 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg @@ -17,6 +17,7 @@ disable= too-many-nested-blocks, too-many-return-statements, too-many-statements, + too-many-positional-arguments, use-dict-literal, # ignoring as a common style issue unspecified-encoding, # always run with UTF-8 encoding enforced useless-return, # complains about returning None when the return type is optional 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 778bf77fd8..60048abb88 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 @@ -98,6 +98,7 @@ disable= too-many-public-methods, too-many-return-statements, too-many-statements, + too-many-positional-arguments, try-except-raise, unbalanced-tuple-unpacking, undefined-loop-variable, 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 d41185214e..c4b9a8f4de 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 @@ -91,6 +91,7 @@ disable= too-many-public-methods, too-many-return-statements, too-many-statements, + too-many-positional-arguments, try-except-raise, unbalanced-tuple-unpacking, undefined-loop-variable, diff --git a/test/lib/ansible_test/_util/target/setup/requirements.py b/test/lib/ansible_test/_util/target/setup/requirements.py index da2555f430..7cbc0a2f19 100644 --- a/test/lib/ansible_test/_util/target/setup/requirements.py +++ b/test/lib/ansible_test/_util/target/setup/requirements.py @@ -363,17 +363,17 @@ def open_binary_file(path, mode='rb'): # type: (str, str) -> t.IO[bytes] return io.open(to_bytes(path), mode) # pylint: disable=consider-using-with,unspecified-encoding -def to_optional_bytes(value, errors='strict'): # type: (t.Optional[t.AnyStr], str) -> t.Optional[bytes] +def to_optional_bytes(value, errors='strict'): # type: (t.Optional[str | bytes], str) -> t.Optional[bytes] """Return the given value as bytes encoded using UTF-8 if not already bytes, or None if the value is None.""" return None if value is None else to_bytes(value, errors) -def to_optional_text(value, errors='strict'): # type: (t.Optional[t.AnyStr], str) -> t.Optional[t.Text] +def to_optional_text(value, errors='strict'): # type: (t.Optional[str | bytes], str) -> t.Optional[t.Text] """Return the given value as text decoded using UTF-8 if not already text, or None if the value is None.""" return None if value is None else to_text(value, errors) -def to_bytes(value, errors='strict'): # type: (t.AnyStr, str) -> bytes +def to_bytes(value, errors='strict'): # type: (str | bytes, str) -> bytes """Return the given value as bytes encoded using UTF-8 if not already bytes.""" if isinstance(value, bytes): return value @@ -384,7 +384,7 @@ def to_bytes(value, errors='strict'): # type: (t.AnyStr, str) -> bytes raise Exception('value is not bytes or text: %s' % type(value)) -def to_text(value, errors='strict'): # type: (t.AnyStr, str) -> t.Text +def to_text(value, errors='strict'): # type: (str | bytes, str) -> t.Text """Return the given value as text decoded using UTF-8 if not already text.""" if isinstance(value, bytes): return value.decode(ENCODING, errors) |