Skip to content

Commit

Permalink
Merge pull request #5486 from adamkankovsky/pylint-enable
Browse files Browse the repository at this point in the history
  • Loading branch information
KKoukiou authored Feb 28, 2024
2 parents 7035746 + bdff5fc commit c01a74e
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 10 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dockerfile/anaconda-ci/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions pyanaconda/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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():
Expand Down
1 change: 0 additions & 1 deletion pyanaconda/modules/common/task/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def __init__(self):

self.__progress_lock = Lock()
self.__progress_step = 0
self.__progress_category = None
self.__progress_msg = ""

@property
Expand Down
5 changes: 5 additions & 0 deletions pyanaconda/modules/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions pyanaconda/ui/webui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions scripts/makebumpver
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/pylint/runpylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self):

self.false_positives = [
FalsePositive(r"^E1101.*: Instance of 'KickstartSpecificationHandler' has no '.*' member$"),
FalsePositive(r"^E1101.*: Method 'PropertiesChanged' has no 'connect' 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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/pyanaconda_tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/pyanaconda_tests/ui/test_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c01a74e

Please sign in to comment.