1
0
forked from drath/libratbag

lint: enable flake8-return

This commit is contained in:
Yaroslav Chvanov
2023-03-02 05:17:34 +03:00
parent 40fb7430db
commit e7a738086c
5 changed files with 17 additions and 15 deletions

View File

@@ -17,6 +17,8 @@ select = [
"B",
# flake8-pie
"PIE",
# flake8-return
"RET",
# pep8-naming
# `Error` suffix on exception names.
"N818",

View File

@@ -168,14 +168,16 @@ class Ratbagd:
v = libratbag.ratbag_log_get_priority(self._ratbag)
if v == libratbag.RATBAG_LOG_PRIORITY_RAW:
return 3
elif v == libratbag.RATBAG_LOG_PRIORITY_DEBUG: # noqa: SIM114
if v == libratbag.RATBAG_LOG_PRIORITY_DEBUG:
# to match with setter action, we return 1 instead of 2
return 1
elif v == libratbag.RATBAG_LOG_PRIORITY_INFO:
if v == libratbag.RATBAG_LOG_PRIORITY_INFO:
return 1
elif v == libratbag.RATBAG_LOG_PRIORITY_ERROR:
if v == libratbag.RATBAG_LOG_PRIORITY_ERROR:
return 0
return 0
@verbose.setter
def verbose(self, verbosity):
if verbosity > 2:

View File

@@ -525,7 +525,7 @@ def func_report_rate_set(ratbagd: Ratbagd, args: argparse.Namespace) -> None:
def func_angle_snapping_get(ratbagd: Ratbagd, args: argparse.Namespace) -> None:
profile, _device = find_profile(ratbagd, args)
if profile.angle_snapping == -1:
return None
return
print(bool(profile.angle_snapping))
@@ -538,7 +538,7 @@ def func_angle_snapping_set(ratbagd: Ratbagd, args: argparse.Namespace) -> None:
def func_debounce_get(ratbagd: Ratbagd, args: argparse.Namespace) -> None:
profile, _device = find_profile(ratbagd, args)
if profile.debounce == -1:
return None
return
print(profile.debounce)
@@ -1471,7 +1471,7 @@ class RatbagParser:
self, input_string: List[str], ns: argparse.Namespace
) -> argparse.ArgumentParser:
r = self._sub_parse(input_string, ns)
return r
return r # noqa: RET504
def print_help(self, group: Optional[str], prefix: str = "") -> None:
if self.group is not None:

View File

@@ -238,11 +238,10 @@ class _RatbagdDBus(GObject.GObject):
except GLib.Error as e:
if e.code == Gio.IOErrorEnum.TIMED_OUT:
raise RatbagdDBusTimeoutError(e.message) from e
else:
# Unrecognized error code; print the message to stderr and raise
# the GLib.Error.
print(e.message, file=sys.stderr)
raise
# Unrecognized error code.
print(e.message, file=sys.stderr)
raise
def __eq__(self, other):
return other and self._object_path == other._object_path
@@ -660,7 +659,8 @@ class RatbagdResolution(_RatbagdDBus):
res = self._get_dbus_property("Resolution")
if isinstance(res, int):
res = tuple([res])
return res
# False-positive RET504:
return res # noqa: RET504
@resolution.setter
def resolution(self, resolution):

View File

@@ -46,12 +46,10 @@ def import_non_standard_path(name, path):
# there's a problem we can't handle -- let the caller handle it.
with open(path, "rb") as fp:
module = imp.load_module(
return imp.load_module(
name, fp, os.path.basename(path), (".py", "rb", imp.PY_SOURCE)
)
return module
def start_ratbagd(verbosity=0):
from gi.repository import Gio