From 8392945afe892f840993e215fa5bbf8d77397ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Sl=C3=A1vik?= Date: Thu, 19 Oct 2023 14:35:26 +0200 Subject: [PATCH 01/10] infra: Get outputs from containerized pylint Invoking the standalone containerized pylint make target now also: - propagates error code - provides logs --- Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d9680e4b961..2596a4a5416 100644 --- a/Makefile.am +++ b/Makefile.am @@ -473,7 +473,11 @@ tests-pylint: # For a weird reason when pylint is not in TESTS included for automake (during configure) # it won't allow us to use makefile check to start the tests. # Unfortunately, we removed pylint from the TESTS because we don't want it to run as default - $(srcdir)/tests/pylint/runpylint | tee $(srcdir)/tests/pylint/runpylint.log + set -o pipefail ; \ + $(srcdir)/tests/pylint/runpylint | tee $(srcdir)/tests/pylint/runpylint.log ; \ + rc=$$? ; \ + $(MAKE) grab-logs ; \ + exit $$rc tests-unit-only: @mkdir -p $(USER_SITE_PACKAGES) From 5f7e9e0558d2184cc3ddc650b4f1353208e2a06a Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Wed, 28 Feb 2024 16:30:24 +0100 Subject: [PATCH 02/10] tests: pylint: fix concat string --- tests/unit_tests/pyanaconda_tests/ui/test_webui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/pyanaconda_tests/ui/test_webui.py b/tests/unit_tests/pyanaconda_tests/ui/test_webui.py index ee493aedf48..f2a9a04c0d6 100644 --- a/tests/unit_tests/pyanaconda_tests/ui/test_webui.py +++ b/tests/unit_tests/pyanaconda_tests/ui/test_webui.py @@ -74,7 +74,7 @@ def test_error_propagation(self, mocked_print_message): mocked_print_message.reset_mock() self.intf.showDetailedError("My detailed error", "Such a detail!") - mocked_print_message.assert_called_once_with("My detailed error\n\nSuch a detail!""") + mocked_print_message.assert_called_once_with("""My detailed error\n\nSuch a detail!""") @patch("pyanaconda.ui.webui.flags") def test_setup_automated_installation(self, mocked_flags): From 9f76ce0b279e08a42bcf776aaa4cee8050e415e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Sl=C3=A1vik?= Date: Thu, 19 Oct 2023 18:21:21 +0200 Subject: [PATCH 03/10] pylint: Disable new warnings found by 3.x --- anaconda.py | 6 ++++-- pyanaconda/display.py | 2 ++ scripts/makebumpver | 5 +++++ .../pyanaconda_tests/modules/boss/test_install_category.py | 1 + tests/unit_tests/pyanaconda_tests/test_display.py | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/anaconda.py b/anaconda.py index 0ef9112d638..7a289864bcc 100755 --- a/anaconda.py +++ b/anaconda.py @@ -36,9 +36,11 @@ def exitHandler(rebootData): from pyanaconda.core.process_watchers import WatchProcesses WatchProcesses.unwatch_all_processes() + # pylint: disable=used-before-assignment if flags.usevnc: vnc.shutdownServer() + # pylint: disable=used-before-assignment if "nokill" in kernel_arguments: util.vtActivate(1) print("anaconda halting due to nokill flag.") @@ -67,7 +69,7 @@ def exitHandler(rebootData): # Tear down the storage module. storage_proxy = STORAGE.get_proxy() - from pyanaconda.modules.common.task import sync_run_task + from pyanaconda.modules.common.task import sync_run_task # pylint: disable=redefined-outer-name for task_path in storage_proxy.TeardownWithTasks(): task_proxy = STORAGE.get_proxy(task_path) @@ -148,7 +150,7 @@ def setup_environment(): if "DISPLAY" in os.environ: flags.preexisting_x11 = True else: - os.environ["DISPLAY"] = ":%s" % constants.X_DISPLAY_NUMBER + os.environ["DISPLAY"] = ":%s" % constants.X_DISPLAY_NUMBER # pylint: disable=used-before-assignment # We mostly don't run from bash, so it won't load the file for us, and libreport will then # show vi instead of nano. Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1889674 diff --git a/pyanaconda/display.py b/pyanaconda/display.py index 61daca7334e..7713a6ce5ea 100644 --- a/pyanaconda/display.py +++ b/pyanaconda/display.py @@ -81,6 +81,7 @@ def start_user_systemd(): # start a new one), but dbus-launch doesn't check the XDG_RUNTIME_DIR/bus path. xdg_runtime_dir = os.environ.get("XDG_RUNTIME_DIR", "/tmp") session_bus_address = "unix:path=" + join_paths(xdg_runtime_dir, "/bus") + # pylint: disable=environment-modify os.environ["DBUS_SESSION_BUS_ADDRESS"] = session_bus_address log.info("The session bus address is set to %s.", session_bus_address) @@ -206,6 +207,7 @@ def do_startup_x11_actions(): xdg_config_dirs = datadir if 'XDG_CONFIG_DIRS' in os.environ: xdg_config_dirs = datadir + ':' + os.environ['XDG_CONFIG_DIRS'] + # pylint: disable=environment-modify os.environ['XDG_CONFIG_DIRS'] = xdg_config_dirs def x11_preexec(): diff --git a/scripts/makebumpver b/scripts/makebumpver index d7b40cf0d09..6cd52f48c07 100755 --- a/scripts/makebumpver +++ b/scripts/makebumpver @@ -76,6 +76,8 @@ class JIRAValidator: # Importing JIRA now will remove unnecessary requirements for Fedora use try: + # https://github.com/pylint-dev/pylint/issues/1727 + # pylint: disable=unused-import from jira import JIRA, JIRAError # pylint: disable=import-error except ModuleNotFoundError: print("Can't find jira python library. Please install it ideally by:\n", file=sys.stderr) @@ -101,10 +103,13 @@ class JIRAValidator: return None + # pylint: disable=method-cache-max-size-none @cache def _query_RHEL_issue(self, bug): try: issue = self.jira.issue(bug) + # https://github.com/pylint-dev/pylint/issues/1727 + # pylint: disable=undefined-variable except JIRAError as ex: raise ValueError(f"Error during JIRA query for bug {bug}: {ex.text}") from ex diff --git a/tests/unit_tests/pyanaconda_tests/modules/boss/test_install_category.py b/tests/unit_tests/pyanaconda_tests/modules/boss/test_install_category.py index a6660c4dcc8..2046b65bfd5 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/boss/test_install_category.py +++ b/tests/unit_tests/pyanaconda_tests/modules/boss/test_install_category.py @@ -68,6 +68,7 @@ def test_task_category_reporting(self): interface = task.for_publication() callback = Mock() + # pylint: disable=no-member interface.CategoryChanged.connect(callback) task.run() diff --git a/tests/unit_tests/pyanaconda_tests/test_display.py b/tests/unit_tests/pyanaconda_tests/test_display.py index adf5b37ca59..ec0fff26d41 100644 --- a/tests/unit_tests/pyanaconda_tests/test_display.py +++ b/tests/unit_tests/pyanaconda_tests/test_display.py @@ -39,6 +39,7 @@ def test_start_user_systemd(self, util_mock, conf_mock, watch_mock): util_mock.reset_mock() # Start systemd --user on a boot.iso. + # pylint: disable=environment-modify os.environ["XDG_RUNTIME_DIR"] = "/my/xdg/path" conf_mock.system.can_start_user_systemd = True util_mock.startProgram.return_value = 100 From edce3a6653194bafbf11413de77a458a54bc8016 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 26 Feb 2024 10:30:42 +0100 Subject: [PATCH 04/10] maint: fix: W0707(raise-missing-from):pyanaconda/ui/webui/__init__.py:168,12 --- pyanaconda/ui/webui/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyanaconda/ui/webui/__init__.py b/pyanaconda/ui/webui/__init__.py index e862c752116..c3b3cdcfe93 100644 --- a/pyanaconda/ui/webui/__init__.py +++ b/pyanaconda/ui/webui/__init__.py @@ -164,8 +164,8 @@ def _watch_webui_on_live(self): try: with open(self._viewer_pid_file, "tr") as f: pid = int(f.readline().strip()) - except ValueError: - raise ValueError("Anaconda can't obtain pid of the web UI viewer application") + except ValueError as e: + raise ValueError("Anaconda can't obtain pid of the web UI viewer application") from e if pid < 0: raise ValueError("Anaconda web UI viewer pid file seems to be broken") From cd4909871aef46c0be6ded39b6576206b2eae718 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 26 Feb 2024 11:20:03 +0100 Subject: [PATCH 05/10] pyanaconda: task: remove unused variable --- pyanaconda/modules/common/task/progress.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyanaconda/modules/common/task/progress.py b/pyanaconda/modules/common/task/progress.py index 76453d9c4e2..353b560b667 100644 --- a/pyanaconda/modules/common/task/progress.py +++ b/pyanaconda/modules/common/task/progress.py @@ -34,7 +34,6 @@ def __init__(self): self.__progress_lock = Lock() self.__progress_step = 0 - self.__progress_category = None self.__progress_msg = "" @property From d446ef0e75df69ff180e3623648f17cfec06e481 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 26 Feb 2024 17:44:19 +0100 Subject: [PATCH 06/10] tests: pylint: remove unused false positive --- tests/pylint/runpylint.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py index 39c52dc1096..3a66d4c59d4 100755 --- a/tests/pylint/runpylint.py +++ b/tests/pylint/runpylint.py @@ -24,7 +24,6 @@ def __init__(self): self.false_positives = [ FalsePositive(r"^E1101.*: Instance of 'KickstartSpecificationHandler' has no '.*' member$"), - FalsePositive(r"^E1101.*: Method 'PropertiesChanged' has no 'connect' member"), # TODO: BlockDev introspection needs to be added to pylint to handle these FalsePositive(r"E1101.*: Instance of 'int' has no 'dasd_is_fba' member"), From 6c1f3c0e8ec93bb760ed9ca53c3ac93b598bffb6 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 26 Feb 2024 18:07:08 +0100 Subject: [PATCH 07/10] pylint: add new false positive The 'new' method exists on class Bytes, https://hackage.haskell.org/package/gi-glib-2.0.29/docs/GI-GLib-Structs-Bytes.html#g:method:new --- tests/pylint/runpylint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py index 3a66d4c59d4..64568bbf6da 100755 --- a/tests/pylint/runpylint.py +++ b/tests/pylint/runpylint.py @@ -24,6 +24,7 @@ def __init__(self): self.false_positives = [ FalsePositive(r"^E1101.*: Instance of 'KickstartSpecificationHandler' has no '.*' member$"), + FalsePositive(r"^E1101.*: Class 'Bytes' has no 'new' member$"), # TODO: BlockDev introspection needs to be added to pylint to handle these FalsePositive(r"E1101.*: Instance of 'int' has no 'dasd_is_fba' member"), From a09cc333fba313c8736cea0c1ae053b14a70321e Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Wed, 28 Feb 2024 09:41:07 +0100 Subject: [PATCH 08/10] tests: pylint: ignore problematic file for astroid Needed because of https://github.com/pylint-dev/astroid/issues/2391 --- pyanaconda/modules/subscription/subscription.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyanaconda/modules/subscription/subscription.py b/pyanaconda/modules/subscription/subscription.py index 632958cd781..a2e12f57df7 100644 --- a/pyanaconda/modules/subscription/subscription.py +++ b/pyanaconda/modules/subscription/subscription.py @@ -17,6 +17,11 @@ # License and may only be used or replicated with the express permission of # Red Hat, Inc. # + +# pylint: skip-file +# FIXME: https://github.com/pylint-dev/astroid/issues/2391 +# There is a known issue with astroid, remove this when it's fixed upstream. + import copy import warnings From 94702d59cad53b0b5e7a2cc6a2f823dd72c57c48 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 26 Feb 2024 14:14:35 +0100 Subject: [PATCH 09/10] infra: bump pylint and astroid version --- dockerfile/anaconda-ci/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfile/anaconda-ci/requirements.txt b/dockerfile/anaconda-ci/requirements.txt index 62cf1dd4f89..6e5f5c8f568 100644 --- a/dockerfile/anaconda-ci/requirements.txt +++ b/dockerfile/anaconda-ci/requirements.txt @@ -15,8 +15,8 @@ pyyaml jinja2 # pylint and its supporting libs -pylint == 3.0.3 -astroid == 3.0.2 +pylint == 3.1.0 +astroid == 3.1.0 # ruff for fast linting ruff == 0.1.14 From bdff5fc945644b408511d955a14c8ae2657f84d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Sl=C3=A1vik?= Date: Mon, 23 Oct 2023 15:14:32 +0200 Subject: [PATCH 10/10] tests: Run pylint again --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6a537ccee5a..d15d39fd4bd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,6 +70,7 @@ TESTS = \ glade_tests/glade_tests.sh \ shellcheck/run_shellcheck.sh \ ruff/run_ruff.sh \ + pylint/runpylint.py \ unit_tests/unit_tests.sh clean-local: