Skip to content

Commit

Permalink
build: Enable PyLint rules W0123 (eval-used) and W0707 (raise-missing…
Browse files Browse the repository at this point in the history
…-from)

Related to #1755

Thank you to Manuel (@feman323) for this contribution.
  • Loading branch information
feman323 authored Jul 14, 2024
1 parent 56cf641 commit b45936a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions common/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,11 @@ def _umount(self):
try:
subprocess.check_call(['fusermount', '-u', self.currentMountpoint])

except subprocess.CalledProcessError:
except subprocess.CalledProcessError as exc:
raise MountException(
_("Can't unmount {mountprocess} from {mountpoint}.")
.format(mountprocess=self.mountproc,
mountpoint=self.currentMountpoint))
mountpoint=self.currentMountpoint)) from exc

def preMountCheck(self, first_run=False):
"""
Expand Down
4 changes: 2 additions & 2 deletions common/test/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ def test_with_pylint(self):
'W4902', # deprecated-method
'W4904', # deprecated-class
'W0614', # unused-wildcard-import
'W0123', # eval-used
'W0707', # raise-missing-from

# Enable asap. This list is a selection of existing (not all!)
# problems currently existing in the BIT code base. Quite easy to fix
# because their count is low.
# 'R0801', # duplicate-code
# 'W0123', # eval-used
# 'W0237', # arguments-renamed
# 'W0221', # arguments-differ
# 'W0603', # global-statement
# 'W0612', # unused-variable
# 'W0707', # raise-missing-from
]

cmd.append('--enable=' + ','.join(err_codes))
Expand Down
3 changes: 2 additions & 1 deletion common/test/test_plugin_usercallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import unittest.mock as mock
import json
from contextlib import redirect_stdout, redirect_stderr
from ast import literal_eval

# This workaround will become obsolet when migrating to src-layout
sys.path.append(str(Path(__file__).parent))
Expand Down Expand Up @@ -182,7 +183,7 @@ def _extract_callback_responses(cls, output):
to_eval = line[line.index("'")+1:line.rindex("'")]

callback_responses.append(
eval(line[line.index("'")+1:line.rindex("'")])
literal_eval(line[line.index("'")+1:line.rindex("'")])
)

# Workaround: Cast profile-id and response-code to integers
Expand Down
14 changes: 7 additions & 7 deletions common/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2315,15 +2315,15 @@ def addRule(self, cmd, uuid):
try:
return self.iface.addRule(cmd, uuid)

except dbus.exceptions.DBusException as e:
if e._dbus_error_name == 'net.launchpad.backintime.InvalidChar':
raise InvalidChar(str(e))
except dbus.exceptions.DBusException as exc:
if exc._dbus_error_name == 'net.launchpad.backintime.InvalidChar':
raise InvalidChar(str(exc)) from exc

elif e._dbus_error_name == 'net.launchpad.backintime.InvalidCmd':
raise InvalidCmd(str(e))
elif exc._dbus_error_name == 'net.launchpad.backintime.InvalidCmd':
raise InvalidCmd(str(exc)) from exc

elif e._dbus_error_name == 'net.launchpad.backintime.LimitExceeded':
raise LimitExceeded(str(e))
elif exc._dbus_error_name == 'net.launchpad.backintime.LimitExceeded':
raise LimitExceeded(str(exc)) from exc

else:
raise
Expand Down

0 comments on commit b45936a

Please sign in to comment.