Skip to content

Commit 2375217

Browse files
authored
Merge pull request #5 from twinleaf/fix-type-check
Fix samples(n) regression; add ruff + ty checks
2 parents f0c91ed + 5c48509 commit 2375217

10 files changed

Lines changed: 298 additions & 141 deletions

File tree

.github/workflows/CI.yml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,32 @@ permissions:
1919
contents: read
2020

2121
jobs:
22+
lint:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v5
26+
- uses: astral-sh/setup-uv@v5
27+
with:
28+
enable-cache: false
29+
- name: Ruff lint
30+
run: uvx ruff@0.15.10 check
31+
- name: Ruff format
32+
run: uvx ruff@0.15.10 format --check
33+
- name: Type check (ty)
34+
run: uvx --with ipython ty@0.0.30 check
35+
2236
linux:
2337
runs-on: ${{ matrix.platform.runner }}
2438
strategy:
2539
matrix:
2640
platform:
2741
- runner: ubuntu-latest
2842
target: x86_64
29-
- runner: ubuntu-latest
30-
target: x86
31-
- runner: ubuntu-latest
43+
- runner: ubuntu-24.04-arm
3244
target: aarch64
33-
- runner: ubuntu-latest
34-
target: armv7
35-
- runner: ubuntu-latest
36-
target: s390x
37-
- runner: ubuntu-latest
38-
target: ppc64le
3945
steps:
40-
- uses: actions/checkout@v4
41-
- uses: actions/setup-python@v5
46+
- uses: actions/checkout@v5
47+
- uses: actions/setup-python@v6
4248
with:
4349
python-version: 3.x
4450
- name: Build wheels
@@ -48,6 +54,10 @@ jobs:
4854
args: --release --out dist --find-interpreter
4955
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
5056
manylinux: auto
57+
before-script-linux: |
58+
if command -v yum >/dev/null; then yum install -y systemd-devel; fi
59+
if command -v apt-get >/dev/null; then apt-get update && apt-get install -y libudev-dev; fi
60+
if command -v apk >/dev/null; then apk add --no-cache eudev-dev; fi
5161
- name: Upload wheels
5262
uses: actions/upload-artifact@v4
5363
with:
@@ -61,15 +71,11 @@ jobs:
6171
platform:
6272
- runner: ubuntu-latest
6373
target: x86_64
64-
- runner: ubuntu-latest
65-
target: x86
66-
- runner: ubuntu-latest
74+
- runner: ubuntu-24.04-arm
6775
target: aarch64
68-
- runner: ubuntu-latest
69-
target: armv7
7076
steps:
71-
- uses: actions/checkout@v4
72-
- uses: actions/setup-python@v5
77+
- uses: actions/checkout@v5
78+
- uses: actions/setup-python@v6
7379
with:
7480
python-version: 3.x
7581
- name: Build wheels
@@ -79,6 +85,10 @@ jobs:
7985
args: --release --out dist --find-interpreter
8086
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
8187
manylinux: musllinux_1_2
88+
before-script-linux: |
89+
if command -v yum >/dev/null; then yum install -y systemd-devel; fi
90+
if command -v apt-get >/dev/null; then apt-get update && apt-get install -y libudev-dev; fi
91+
if command -v apk >/dev/null; then apk add --no-cache eudev-dev; fi
8292
- name: Upload wheels
8393
uses: actions/upload-artifact@v4
8494
with:
@@ -95,8 +105,8 @@ jobs:
95105
- runner: windows-latest
96106
target: x86
97107
steps:
98-
- uses: actions/checkout@v4
99-
- uses: actions/setup-python@v5
108+
- uses: actions/checkout@v5
109+
- uses: actions/setup-python@v6
100110
with:
101111
python-version: 3.x
102112
architecture: ${{ matrix.platform.target }}
@@ -122,8 +132,8 @@ jobs:
122132
- runner: macos-latest
123133
target: x86_64
124134
steps:
125-
- uses: actions/checkout@v4
126-
- uses: actions/setup-python@v5
135+
- uses: actions/checkout@v5
136+
- uses: actions/setup-python@v6
127137
with:
128138
python-version: 3.x
129139
- name: Build wheels
@@ -141,7 +151,7 @@ jobs:
141151
sdist:
142152
runs-on: ubuntu-latest
143153
steps:
144-
- uses: actions/checkout@v4
154+
- uses: actions/checkout@v5
145155
- name: Build sdist
146156
uses: PyO3/maturin-action@v1
147157
with:
@@ -157,7 +167,7 @@ jobs:
157167
name: Release
158168
runs-on: ubuntu-latest
159169
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
160-
needs: [linux, musllinux, windows, macos, sdist]
170+
needs: [lint, linux, musllinux, windows, macos, sdist]
161171
permissions:
162172
# Use to sign the release artifacts
163173
id-token: write

examples/tl-meta.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python3
22

3+
import pprint
4+
35
import twinleaf
46

57
dev = twinleaf.Device()
68

79
meta = dev._get_metadata()
8-
import pprint
910
pp = pprint.PrettyPrinter(indent=1)
1011
pp.pprint(meta)

examples/tl-samples.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env python3
22

33
import twinleaf
4-
import pprint
54

65
dev = twinleaf.Device()
76

8-
samples_dict_getter = dev.samples # All samples
9-
samples_list_getter = dev.samples.imu.imu.accel # Wildcard samples
10-
#samples_list_getter = dev.samples.imu.imu.accel.x # Specific column
7+
samples_dict_getter = dev.samples # All samples
8+
samples_list_getter = dev.samples.imu.imu.accel # Wildcard samples
9+
# samples_list_getter = dev.samples.imu.imu.accel.x # Specific column
1110

1211
samples_dict = samples_dict_getter(n=10)
1312
for _id, stream in samples_dict.items():
@@ -19,5 +18,5 @@
1918
samples_list = samples_list_getter(n=10)
2019
for sample in samples_list:
2120
for column in sample:
22-
print(f"{column:<20}", end='')
21+
print(f"{column:<20}", end="")
2322
print()

examples/tl-settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python3
22

3+
import pprint
4+
35
import twinleaf
46

57
dev = twinleaf.Device()
68

79
settings = dev.settings()
8-
import pprint
910
pp = pprint.PrettyPrinter(indent=1)
1011
pp.pprint(settings)

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ build-backend = "maturin"
3636
features = ["pyo3/extension-module"]
3737
module-name = "twinleaf._twinleaf"
3838
python-source = "python"
39+
40+
[tool.ruff]
41+
target-version = "py312"
42+
43+
[tool.ty.environment]
44+
python-version = "3.12"
45+
46+
[tool.ty.src]
47+
exclude = ["examples"]

0 commit comments

Comments
 (0)