From 62ce21b6e4d3ae8b95e4314f36f02eb9bef13b70 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 9 Oct 2024 10:19:55 -0700 Subject: [PATCH] ansible-test - Work around pylint issue on 3.11 (#84094) --- changelogs/fragments/ansible-test-pylint-fix.yml | 4 ++++ .../controller/sanity/pylint/plugins/hide_unraisable.py | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/ansible-test-pylint-fix.yml diff --git a/changelogs/fragments/ansible-test-pylint-fix.yml b/changelogs/fragments/ansible-test-pylint-fix.yml new file mode 100644 index 00000000000..877a5944967 --- /dev/null +++ b/changelogs/fragments/ansible-test-pylint-fix.yml @@ -0,0 +1,4 @@ +bugfixes: + - ansible-test - Enable the ``sys.unraisablehook`` work-around for the ``pylint`` sanity test on Python 3.11. + Previously the work-around was only enabled for Python 3.12 and later. + However, the same issue has been discovered on Python 3.11. diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/hide_unraisable.py b/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/hide_unraisable.py index d3d0f9790e1..b67ea8eccc2 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/hide_unraisable.py +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/hide_unraisable.py @@ -1,4 +1,4 @@ -"""Temporary plugin to prevent stdout noise pollution from finalization of abandoned generators under Python 3.12""" +"""Temporary plugin to prevent stdout noise pollution from finalization of abandoned generators.""" from __future__ import annotations import sys @@ -10,7 +10,7 @@ if t.TYPE_CHECKING: def _mask_finalizer_valueerror(ur: t.Any) -> None: """Mask only ValueErrors from finalizing abandoned generators; delegate everything else""" - # work around Py3.12 finalizer changes that sometimes spews this error message to stdout + # work around Python finalizer issue that sometimes spews this error message to stdout # see https://github.com/pylint-dev/pylint/issues/9138 if ur.exc_type is ValueError and 'generator already executing' in str(ur.exc_value): return @@ -20,5 +20,4 @@ def _mask_finalizer_valueerror(ur: t.Any) -> None: def register(linter: PyLinter) -> None: # pylint: disable=unused-argument """PyLint plugin registration entrypoint""" - if sys.version_info >= (3, 12): - sys.unraisablehook = _mask_finalizer_valueerror + sys.unraisablehook = _mask_finalizer_valueerror