Skip to content

Commit cb3e342

Browse files
authored
Fix errors found in mypy and add mypy to CI (#1185)
1 parent 872d116 commit cb3e342

File tree

5 files changed

+156
-223
lines changed

5 files changed

+156
-223
lines changed

.github/workflows/choreolib.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ jobs:
241241
with:
242242
name: Python
243243
path: ./choreolib/py/dist
244+
lint-python:
245+
name: "Lint Python"
246+
runs-on: ubuntu-24.04
247+
steps:
248+
- uses: actions/checkout@v4
249+
with:
250+
fetch-depth: 0
251+
persist-credentials: false
252+
token: ${{secrets.GITHUB_TOKEN}}
253+
254+
- uses: actions/setup-python@v5
255+
with:
256+
python-version: 3.12
257+
258+
- run: pip3 install mypy wpilib
259+
260+
- run: mypy --pretty --show-column-numbers choreolib/py
244261

245262
pypi-publish:
246263
name: Upload release to PyPI

choreolib/py/choreo/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
SwerveSample,
99
SwerveTrajectory,
1010
load_event_marker,
11+
marker_is_not_none,
1112
)
1213
from choreo.util.traj_schema_version import (
1314
TRAJ_SCHEMA_VERSION as generated_TRAJ_SCHEMA_VERSION,
@@ -48,18 +49,18 @@ def load_differential_trajectory_string(
4849
float(sample["omega"]),
4950
float(sample["al"]),
5051
float(sample["ar"]),
51-
[float(x) for x in sample["fl"]],
52-
[float(y) for y in sample["fr"]],
52+
float(sample["fl"]),
53+
float(sample["fr"]),
5354
)
5455
for sample in data["trajectory"]["samples"]
5556
]
5657
splits = [int(split) for split in data["trajectory"]["splits"]]
5758
# Add 0 as the first split index
5859
if len(splits) == 0 or splits[0] != 0:
5960
splits.insert(0, 0)
60-
events = list(
61+
events = list[EventMarker](
6162
filter(
62-
lambda marker: marker is not None,
63+
marker_is_not_none,
6364
[load_event_marker(event) for event in data["events"]],
6465
)
6566
)
@@ -122,9 +123,9 @@ def load_swerve_trajectory_string(trajectory_json_string: str) -> SwerveTrajecto
122123
# Add 0 as the first split index
123124
if len(splits) == 0 or splits[0] != 0:
124125
splits.insert(0, 0)
125-
events = list(
126+
events = list[EventMarker](
126127
filter(
127-
lambda marker: marker is not None,
128+
marker_is_not_none,
128129
[load_event_marker(event) for event in data["events"]],
129130
)
130131
)

0 commit comments

Comments
 (0)