refactor: dedupe flipped-orientation check via is_flipped_orientation
What changed, and why it matters
This commit is a straightforward internal cleanup: it moves a repeated screen-rotation check into a single shared helper and makes that helper use its existing object instead of creating new temporary settings objects. There is no user-facing behavior change and no security relevance.
No security action needed; this is a benign refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors three copies of a flipped-orientation check into one Settings.is_flipped_orientation() method. The method now reads self.hardware instead of instantiating Settings() twice, and display.to_landscape/to_portrait call that helper. The logic and behavior are unchanged; only redundant Settings() constructions are removed.
Changed components
src/krux/display.pysrc/krux/krux_settings.pyInspect captured patch +4 / −10
diff --git a/src/krux/display.py b/src/krux/display.py
index 4f458f2..9ffe97f 100644
--- a/src/krux/display.py
+++ b/src/krux/display.py
@@ -244,20 +244,14 @@ class Display:
def to_landscape(self):
"""Changes the rotation of the display to landscape"""
if self.portrait:
- hardware = Settings().hardware
- flipped = hasattr(hardware, "display") and getattr(
- hardware.display, "flipped_orientation", False
- )
+ flipped = Settings().is_flipped_orientation()
lcd.rotation((LANDSCAPE + 2) % 4 if flipped else LANDSCAPE)
self.portrait = False
def to_portrait(self):
"""Changes the rotation of the display to portrait"""
if not self.portrait:
- hardware = Settings().hardware
- flipped = hasattr(hardware, "display") and getattr(
- hardware.display, "flipped_orientation", False
- )
+ flipped = Settings().is_flipped_orientation()
lcd.rotation((PORTRAIT + 2) % 4 if flipped else PORTRAIT)
self.portrait = True
diff --git a/src/krux/krux_settings.py b/src/krux/krux_settings.py
index c781505..765f180 100644
--- a/src/krux/krux_settings.py
+++ b/src/krux/krux_settings.py
@@ -502,8 +502,8 @@ class Settings(SettingsNamespace):
def is_flipped_orientation(self):
"""Returns flipped orientation setting"""
- return hasattr(Settings().hardware, "display") and getattr(
- Settings().hardware.display, "flipped_orientation", False
+ return hasattr(self.hardware, "display") and getattr(
+ self.hardware.display, "flipped_orientation", False
)
def label(self, attr):
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.