refactor: Manually improve f-string formatting

This commit is contained in:
Matthias Hagmann 2024-03-24 11:46:55 +01:00 committed by Peter F. Patel-Schneider
parent 4e6361429e
commit 6f613b17c7
3 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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):