diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 6ddf721..af26dce 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -7,7 +7,14 @@ on: jobs: ruff: runs-on: ubuntu-latest + name: Ruff + steps: + - uses: actions/checkout@v4.1.1 + - uses: ITProKyle/action-setup-python@v0.7.0 + with: + python-version: 3.11 + - uses: chartboost/ruff-action@v1 name: Ruff Lint diff --git a/drumpy/app/camera_display.py b/drumpy/app/camera_display.py index 9889d07..7b23006 100644 --- a/drumpy/app/camera_display.py +++ b/drumpy/app/camera_display.py @@ -1,3 +1,5 @@ +from typing import Self + import pygame.time from pygame import Surface @@ -12,7 +14,7 @@ class VideoDisplay: """ def __init__( - self, + self: Self, video_source: VideoSource, media_pipe_pose: MediaPipePose, window: Surface, @@ -26,7 +28,7 @@ def __init__( self.video_source = video_source self.prev_surface = None - def update(self) -> None: + def update(self: Self) -> None: frame = self.video_source.get_frame() assert frame is None or frame.shape[0] == frame.shape[1], "Frame is not square" diff --git a/drumpy/app/fps_display.py b/drumpy/app/fps_display.py index 0eb0b30..a5652c6 100644 --- a/drumpy/app/fps_display.py +++ b/drumpy/app/fps_display.py @@ -1,9 +1,13 @@ +from typing import Self + from pygame import Rect from pygame_gui import UIManager from pygame_gui.elements import UILabel from drumpy.mediapipe_pose import MediaPipePose +MEMORY = 30 + class FPSDisplay(UILabel): """ @@ -11,7 +15,7 @@ class FPSDisplay(UILabel): """ def __init__( - self, + self: Self, ui_manager: UIManager, media_pipe_pose: MediaPipePose, ) -> None: @@ -30,15 +34,15 @@ def __init__( self.media_pipe_pose = media_pipe_pose self.ui_manager = ui_manager - def update(self, time_delta: float) -> None: + def update(self: Self, time_delta: float) -> None: super().update(time_delta) self.ui_time_deltas.append(time_delta) - if len(self.ui_time_deltas) > 30: + if len(self.ui_time_deltas) > MEMORY: self.ui_time_deltas.pop(0) self.mediapipe_time_deltas.append(self.media_pipe_pose.latency) - if len(self.mediapipe_time_deltas) > 30: + if len(self.mediapipe_time_deltas) > MEMORY: self.mediapipe_time_deltas.pop(0) if len(self.ui_time_deltas) == 0 or len(self.mediapipe_time_deltas) == 0: diff --git a/drumpy/app/main.py b/drumpy/app/main.py index 66e5a00..2f495d7 100644 --- a/drumpy/app/main.py +++ b/drumpy/app/main.py @@ -76,10 +76,7 @@ def __init__( self.fps = self.video_source.get_fps() - if self.plot: - rect = pygame.Rect((400, 50), (900, 900)) - else: - rect = pygame.Rect((0, 50), (900, 900)) + rect = pygame.Rect((400, 50), (900, 900)) if self.plot else pygame.Rect((0, 50), (900, 900)) self.video_display = VideoDisplay( video_source=self.video_source, diff --git a/drumpy/drum/drum.py b/drumpy/drum/drum.py index cb23db9..de845f7 100644 --- a/drumpy/drum/drum.py +++ b/drumpy/drum/drum.py @@ -146,11 +146,13 @@ def find_and_play_sound( if closest_sound is not None: closest_sound.hit(position) print( - f"{marker_label}: {closest_sound.name} with distance {closest_distance:.3f} ] at {print_float_array(position)}" + f"{marker_label}: {closest_sound.name} with distance {closest_distance:.3f} " + f"at {print_float_array(position)}" ) else: print( - f"{marker_label}: No sound found for position {print_float_array(position)} with distance {closest_distance:.3f}" + f"{marker_label}: No sound found for position {print_float_array(position)} " + f"with distance {closest_distance:.3f}" ) def auto_calibrate(self, sounds: list[int] | None = None) -> None: diff --git a/pyproject.toml b/pyproject.toml index cb5c894..453a5c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,3 +26,7 @@ ruff-lsp = "^0.0.53" [tool.ruff.lint] select = [ "E", "F", "N", "ANN", "FBT", "B", "A", "C4", "PIE", "Q", "RET", "SLF", "SIM", "ARG", "PL", "PERF", "RUF"] fixable = ["ALL"] +pylint.max-args = 10 + +[tool.ruff.lint.pycodestyle] +max-line-length = 120