style(offscreen): lint fixes for the new code (Codacy)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-09-24 11:02:22 -04:00
co-authored by Claude Opus 5.5
parent 0f68fbcfdc
commit 8163104581
3 changed files with 15 additions and 12 deletions
+11 -8
View File
@@ -138,24 +138,26 @@ class _OffscreenMatrix(_LogicalMatrix):
Reports the surface's size, so plugins that lay out from ``matrix.width`` Reports the surface's size, so plugins that lay out from ``matrix.width``
follow it, and swallows every write that would reach the hardware. Nothing follow it, and swallows every write that would reach the hardware. Nothing
drawn off-screen may touch the panel the render loop is driving. drawn off-screen may touch the panel the render loop is driving. Method
names mirror the rgbmatrix API they stand in for.
""" """
# pylint: disable=invalid-name
__slots__ = () __slots__ = ()
def SetImage(self, *args: Any, **kwargs: Any) -> None: def SetImage(self, *_args: Any, **_kwargs: Any) -> None:
"""Inert: off-screen drawing never reaches the panel.""" """Inert: off-screen drawing never reaches the panel."""
def SetPixel(self, *args: Any, **kwargs: Any) -> None: def SetPixel(self, *_args: Any, **_kwargs: Any) -> None:
"""Inert: off-screen drawing never reaches the panel.""" """Inert: off-screen drawing never reaches the panel."""
def Clear(self) -> None: def Clear(self) -> None:
"""Inert: off-screen drawing never reaches the panel.""" """Inert: off-screen drawing never reaches the panel."""
def Fill(self, *args: Any, **kwargs: Any) -> None: def Fill(self, *_args: Any, **_kwargs: Any) -> None:
"""Inert: off-screen drawing never reaches the panel.""" """Inert: off-screen drawing never reaches the panel."""
def SwapOnVSync(self, canvas: Any, *args: Any, **kwargs: Any) -> Any: def SwapOnVSync(self, canvas: Any, *_args: Any, **_kwargs: Any) -> Any:
"""Inert: hands the canvas straight back without waiting on the panel.""" """Inert: hands the canvas straight back without waiting on the panel."""
return canvas return canvas
@@ -174,7 +176,8 @@ class _OffscreenSurface:
def __init__(self, width: int, height: int, real_matrix: Any) -> None: def __init__(self, width: int, height: int, real_matrix: Any) -> None:
self.image = Image.new('RGB', (width, height)) self.image = Image.new('RGB', (width, height))
self.draw = ImageDraw.Draw(self.image) self.draw = ImageDraw.Draw(self.image)
self.draw.fontmode = "1" # 1-bit text: the panel has no partial brightness, so AA only smears glyphs. # 1-bit text: the panel has no partial brightness, so AA only smears glyphs.
self.draw.fontmode = "1"
self.matrix = (_OffscreenMatrix(real_matrix, width, height) self.matrix = (_OffscreenMatrix(real_matrix, width, height)
if real_matrix is not None else None) if real_matrix is not None else None)
@@ -190,7 +193,7 @@ def _per_thread_canvas_attr(name: str) -> property:
shared = "_shared_" + name shared = "_shared_" + name
def fget(self: "DisplayManager") -> Any: def fget(self: "DisplayManager") -> Any:
surface = self._current_surface() surface = self._current_surface() # pylint: disable=protected-access
if surface is not None: if surface is not None:
return getattr(surface, name) return getattr(surface, name)
try: try:
@@ -199,7 +202,7 @@ def _per_thread_canvas_attr(name: str) -> property:
raise AttributeError(name) from None raise AttributeError(name) from None
def fset(self: "DisplayManager", value: Any) -> None: def fset(self: "DisplayManager", value: Any) -> None:
surface = self._current_surface() surface = self._current_surface() # pylint: disable=protected-access
if surface is not None: if surface is not None:
setattr(surface, name, value) setattr(surface, name, value)
else: else:
@@ -263,7 +263,8 @@ class VisualTestDisplayManager:
self.matrix = _MatrixProxy(target_w, target_h) self.matrix = _MatrixProxy(target_w, target_h)
self.image = Image.new('RGB', (target_w, target_h), (0, 0, 0)) self.image = Image.new('RGB', (target_w, target_h), (0, 0, 0))
self.draw = ImageDraw.Draw(self.image) self.draw = ImageDraw.Draw(self.image)
self.draw.fontmode = "1" # Match production: 1-bit text, so goldens show what the panel shows. # Match production: 1-bit text, so goldens show what the panel shows.
self.draw.fontmode = "1"
self._capture_mode_active = True self._capture_mode_active = True
yield self yield self
finally: finally:
+2 -3
View File
@@ -160,11 +160,10 @@ class PluginAdapter:
there is no plugin manager to ask -- the behaviour before the lock was there is no plugin manager to ask -- the behaviour before the lock was
taken here at all. taken here at all.
""" """
get_lock = getattr(self.plugin_manager, 'get_plugin_lock', None) if not hasattr(self.plugin_manager, 'get_plugin_lock'):
if get_lock is None:
yield True yield True
return return
lock = get_lock(plugin_id) lock = self.plugin_manager.get_plugin_lock(plugin_id)
acquired = lock.acquire(timeout=self.PLUGIN_LOCK_TIMEOUT) acquired = lock.acquire(timeout=self.PLUGIN_LOCK_TIMEOUT)
try: try:
yield acquired yield acquired