From 2dfb46a4a66496f93f7fe1d365495d4618b0ceb9 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:14:51 +1300 Subject: [PATCH] remove ignore lines for Python 2 (#11122) * remove ignore lines for Python 2 * use yield from * add changelog frag * Update changelogs/fragments/11122-yield-from-ignore.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/11122-yield-from-ignore.yml | 2 ++ plugins/module_utils/univention_umc.py | 3 +-- tests/sanity/ignore-2.17.txt | 2 -- tests/sanity/ignore-2.18.txt | 2 -- tests/sanity/ignore-2.19.txt | 2 -- tests/sanity/ignore-2.20.txt | 2 -- tests/sanity/ignore-2.21.txt | 2 -- tests/unit/plugins/modules/uthelper.py | 3 +-- 8 files changed, 4 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/11122-yield-from-ignore.yml diff --git a/changelogs/fragments/11122-yield-from-ignore.yml b/changelogs/fragments/11122-yield-from-ignore.yml new file mode 100644 index 0000000000..f820de1d55 --- /dev/null +++ b/changelogs/fragments/11122-yield-from-ignore.yml @@ -0,0 +1,2 @@ +minor_changes: + - univention_umc module utils - update code to Python 3 (https://github.com/ansible-collections/community.general/pull/11122). diff --git a/plugins/module_utils/univention_umc.py b/plugins/module_utils/univention_umc.py index 7f8f58d8ec..54f1654827 100644 --- a/plugins/module_utils/univention_umc.py +++ b/plugins/module_utils/univention_umc.py @@ -161,8 +161,7 @@ def ldap_search(filter, base=None, attr=None): break else: if result_type is ldap_module().RES_SEARCH_ENTRY: - for res in result_data: - yield res + yield from result_data uldap().lo.lo.abandon(msgid) diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 97751e5a92..f6b058ec69 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -9,6 +9,4 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2 -tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2 tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt index 97751e5a92..f6b058ec69 100644 --- a/tests/sanity/ignore-2.18.txt +++ b/tests/sanity/ignore-2.18.txt @@ -9,6 +9,4 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2 -tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2 tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes diff --git a/tests/sanity/ignore-2.19.txt b/tests/sanity/ignore-2.19.txt index 97751e5a92..f6b058ec69 100644 --- a/tests/sanity/ignore-2.19.txt +++ b/tests/sanity/ignore-2.19.txt @@ -9,6 +9,4 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2 -tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2 tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes diff --git a/tests/sanity/ignore-2.20.txt b/tests/sanity/ignore-2.20.txt index ab7e6e3c7c..f6b058ec69 100644 --- a/tests/sanity/ignore-2.20.txt +++ b/tests/sanity/ignore-2.20.txt @@ -1,4 +1,3 @@ -plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2 plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/homectl.py import-3.12 # Uses deprecated stdlib library 'crypt' @@ -10,5 +9,4 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2 tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes diff --git a/tests/sanity/ignore-2.21.txt b/tests/sanity/ignore-2.21.txt index b29d87a77e..1ecb499e8b 100644 --- a/tests/sanity/ignore-2.21.txt +++ b/tests/sanity/ignore-2.21.txt @@ -1,4 +1,3 @@ -plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2 plugins/modules/ansible_galaxy_install.py validate-modules:bad-return-value-key # TODO: rename offending return values if possible, or adjust this comment in case the name is OK plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice plugins/modules/gandi_livedns.py validate-modules:bad-return-value-key # TODO: rename offending return values if possible, or adjust this comment in case the name is OK @@ -17,5 +16,4 @@ plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt' plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt' plugins/modules/xfconf.py validate-modules:return-syntax-error -tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2 tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes diff --git a/tests/unit/plugins/modules/uthelper.py b/tests/unit/plugins/modules/uthelper.py index 7058055c6c..e76bc010d5 100644 --- a/tests/unit/plugins/modules/uthelper.py +++ b/tests/unit/plugins/modules/uthelper.py @@ -231,8 +231,7 @@ class RunCommandMock(TestCaseMock): def setup(self, mocker): def _results(): - for result in [(x["rc"], x["out"], x["err"]) for x in self.mock_specs]: - yield result + yield from [(x["rc"], x["out"], x["err"]) for x in self.mock_specs] raise Exception("testcase has not enough run_command calls") results = _results()