Skip to content

Commit 95ea2d8

Browse files
committed
[cr] fix pylint errors
1 parent cda1fac commit 95ea2d8

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

pyproject.toml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ build-backend = "hatchling.build"
5353
[tool.hatch.build.targets.wheel]
5454
packages = ["src/openlaunch"]
5555

56-
[tool.uv]
57-
dev-dependencies = [
56+
[dependency-groups]
57+
dev = [
58+
"pylint>=3.3.9",
5859
"pytest>=7.0.0",
5960
"ruff>=0.1.0",
6061
]
@@ -67,6 +68,23 @@ target-version = "py39"
6768
select = ["E", "F", "W", "I"]
6869
ignore = ["E501"] # Line length handled separately
6970

71+
[tool.pylint.main]
72+
py-version = "3.9"
73+
74+
[tool.pylint.messages_control]
75+
disable = [
76+
"too-many-instance-attributes", # Radar and monitor classes need many attributes
77+
"too-many-public-methods", # Radar API has many commands
78+
"too-many-locals", # Distance estimation lookup table
79+
"too-many-statements", # CLI main function
80+
"import-outside-toplevel", # argparse in main() is fine
81+
"broad-exception-caught", # Generic catch in streaming loop is intentional
82+
"invalid-name", # Allow DRIVER_TABLE, CLUB_FACTORS constants
83+
]
84+
85+
[tool.pylint.format]
86+
max-line-length = 100
87+
7088
[tool.pytest.ini_options]
7189
testpaths = ["tests"]
7290
python_files = ["test_*.py"]

src/openlaunch/launch_monitor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from datetime import datetime
1313
from enum import Enum
1414

15-
from .ops243 import OPS243Radar, SpeedReading, Direction
15+
from .ops243 import OPS243Radar, SpeedReading
1616

1717

1818
class ClubType(Enum):
@@ -315,7 +315,7 @@ def _on_reading(self, reading: SpeedReading):
315315
min_speed = self.MIN_BALL_SPEED_MPH
316316

317317
# Filter by realistic speeds
318-
if not (min_speed <= reading.speed <= self.MAX_BALL_SPEED_MPH):
318+
if not min_speed <= reading.speed <= self.MAX_BALL_SPEED_MPH:
319319
return
320320

321321
# Check if this is part of current shot or new shot
@@ -369,9 +369,11 @@ def _process_shot(self):
369369
club_speed_tolerance = 20 # mph tolerance
370370

371371
# Find readings that could be club (within expected range)
372+
club_speed_min = expected_club_speed - club_speed_tolerance
373+
club_speed_max = expected_club_speed + club_speed_tolerance
372374
potential_club_speeds = [
373375
s for s in speeds
374-
if (expected_club_speed - club_speed_tolerance) <= s <= (expected_club_speed + club_speed_tolerance)
376+
if club_speed_min <= s <= club_speed_max
375377
and s < peak_speed * 0.85 # Must be significantly less than ball speed
376378
]
377379

@@ -380,7 +382,7 @@ def _process_shot(self):
380382
club_speed = max(potential_club_speeds)
381383

382384
# Validate: club speed should be realistic
383-
if not (self.MIN_CLUB_SPEED_MPH <= club_speed <= self.MAX_CLUB_SPEED_MPH):
385+
if not self.MIN_CLUB_SPEED_MPH <= club_speed <= self.MAX_CLUB_SPEED_MPH:
384386
club_speed = None
385387

386388
# Ball speed is the peak
@@ -508,7 +510,7 @@ def main():
508510
print("Radar Configuration:")
509511
for key, value in info.items():
510512
print(f" {key}: {value}")
511-
return
513+
return 0
512514

513515
print("Ready! Swing when ready...")
514516
print("Press Ctrl+C to stop")
@@ -565,4 +567,5 @@ def on_live(reading):
565567

566568

567569
if __name__ == "__main__":
568-
exit(main())
570+
import sys
571+
sys.exit(main())

src/openlaunch/ops243.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
- 100kHz (SC): max 695 mph - overkill but works
1818
"""
1919

20-
import serial
21-
import serial.tools.list_ports
2220
import json
23-
import time
2421
import threading
22+
import time
2523
from dataclasses import dataclass
26-
from typing import Optional, Callable, List
2724
from enum import Enum
25+
from typing import Callable, List, Optional
26+
27+
import serial
28+
import serial.tools.list_ports
2829

2930

3031
class SpeedUnit(Enum):
@@ -156,7 +157,7 @@ def connect(self, timeout: float = DEFAULT_TIMEOUT) -> bool:
156157
self.serial.reset_input_buffer()
157158
return True
158159
except serial.SerialException as e:
159-
raise ConnectionError(f"Failed to connect to {self.port}: {e}")
160+
raise ConnectionError(f"Failed to connect to {self.port}: {e}") from e
160161

161162
def disconnect(self):
162163
"""Disconnect from the radar sensor."""
@@ -568,18 +569,17 @@ def _parse_reading(self, line: str) -> Optional[SpeedReading]:
568569
timestamp=time.time(),
569570
unit=self._unit
570571
)
571-
else:
572-
# Plain number format
573-
# Negative = inbound, positive = outbound
574-
speed = float(line)
575-
direction = Direction.OUTBOUND if speed > 0 else Direction.INBOUND
576-
577-
return SpeedReading(
578-
speed=abs(speed),
579-
direction=direction,
580-
timestamp=time.time(),
581-
unit=self._unit
582-
)
572+
# Plain number format
573+
# Negative = inbound, positive = outbound
574+
speed = float(line)
575+
direction = Direction.OUTBOUND if speed > 0 else Direction.INBOUND
576+
577+
return SpeedReading(
578+
speed=abs(speed),
579+
direction=direction,
580+
timestamp=time.time(),
581+
unit=self._unit
582+
)
583583
except (ValueError, json.JSONDecodeError):
584584
return None
585585

0 commit comments

Comments
 (0)