From 6f613b17c7d004a9e4c09f004360bd1e96bf0bd0 Mon Sep 17 00:00:00 2001 From: Matthias Hagmann <16444067+MattHag@users.noreply.github.com> Date: Sun, 24 Mar 2024 11:46:55 +0100 Subject: [PATCH] refactor: Manually improve f-string formatting --- lib/logitech_receiver/common.py | 4 ++-- lib/logitech_receiver/settings_templates.py | 5 ++++- lib/solaar/cli/show.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/logitech_receiver/common.py b/lib/logitech_receiver/common.py index 36a79cee..31a451c0 100644 --- a/lib/logitech_receiver/common.py +++ b/lib/logitech_receiver/common.py @@ -475,9 +475,9 @@ class NamedInts: raise TypeError("name must be a string") if str(value) in self.__dict__: - raise ValueError(f"{value} ({int(int(value))}) already known") + raise ValueError(f"{value} ({int(value)}) already known") if int(value) in self._indexed: - raise ValueError(f"{int(int(value))} ({value}) already known") + raise ValueError(f"{int(value)} ({value}) already known") self._values.append(value) self._is_sorted = False diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 2a038f51..d296a69d 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -773,7 +773,10 @@ class DpiSlidingXY(_RawXYProcessing): def displayNewDpi(self, newDpiIdx): if _notify.available: - reason = f"DPI {int(self.dpiChoices[newDpiIdx])} [min {int(self.dpiChoices[0])}, max {int(self.dpiChoices[-1])}]" + selected_dpi = self.dpiChoices[newDpiIdx] + min_dpi = self.dpiChoices[0] + max_dpi = self.dpiChoices[-1] + reason = f"DPI {selected_dpi} [min {min_dpi}, max {max_dpi}]" _notify.show(self.device, reason) def press_action(self, key): # start tracking diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index 9f16b9f4..1bca4c34 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -64,7 +64,7 @@ def _print_receiver(receiver): print(" Device activity counters:", activity_text or "(empty)") -def _battery_text(level): +def _battery_text(level) -> str: if level is None: return "N/A" elif isinstance(level, _NamedInt):