Skip to content

Commit 14c15e7

Browse files
committed
tooling: Enable ruff preview rules E203, E302, and E303.
Closes #400. These three pycodestyle rules are in preview in ruff 0.11.6 and were not active because of explicit-preview-rules = true. Add them to the explicit select list and auto-fix the 11 existing violations across the codebase: E203 — whitespace before ':' (catches `else :`, `if x :`, etc.) E302 — expected 2 blank lines before function/class definition E303 — too many blank lines inside a block E203 was spotted in PR #399 (Aline's tamagotchi example) and E302/E303 in PR #376 (Kaan's spirit level) — both were caught manually because ruff did not flag them.
1 parent e619b1e commit 14c15e7

9 files changed

Lines changed: 8 additions & 6 deletions

File tree

lib/apds9960/examples/light_theremin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
# Map the light range to an index in our note array (0 to 14)
6767
note_index = (clamped_light - MIN_LIGHT) * (TOTAL_NOTES - 1) // range_light
6868

69-
7069
# Fetch the perfect harmonic frequency
7170
freq = PENTATONIC_NOTES[note_index]
7271

@@ -77,7 +76,6 @@
7776
print("Light: {} | Note: {} | Freq: {} Hz".format(light_level, note_index, freq), end="\r")
7877
last_freq = freq
7978

80-
8179
sleep_ms(20)
8280

8381
except KeyboardInterrupt:

lib/mcp23009e/examples/i2c_scan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
reset.value(1)
1414

1515

16-
1716
print("=" * 60)
1817
print("Scanner I2C - Recherche des périphériques")
1918
print("=" * 60)

lib/steami_config/steami_config/device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# Reverse map: short key -> sensor name.
1313
_KEY_SENSORS = {v: k for k, v in _SENSOR_KEYS.items()}
1414

15+
1516
class SteamiConfig(object):
1617
"""Persistent configuration stored in the DAPLink F103 config zone.
1718
@@ -239,7 +240,6 @@ def get_accelerometer_calibration(self):
239240
"oz": cal.get("oz", 0.0),
240241
}
241242

242-
243243
def apply_accelerometer_calibration(self, ism330dl_instance):
244244
"""Apply stored accelerometer calibration to an ISM330DL instance."""
245245
if type(ism330dl_instance).__name__.lower() != "ism330dl":

lib/steami_screen/steami_screen/device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
# --- Cardinal position names ---
4242

43+
4344
class Screen:
4445
"""High-level wrapper around a raw display backend."""
4546

@@ -196,7 +197,6 @@ def bar(self, val, max_val=100, y_offset=0, color=LIGHT):
196197
if fill_w > 0:
197198
self._fill_rect(bx, by, fill_w, bar_h, color)
198199

199-
200200
def gauge(self, val, min_val=0, max_val=100, color=LIGHT):
201201
"""Draw a circular arc gauge (270 deg, gap at bottom).
202202

lib/wsen-pads/examples/altitude.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
sensor = WSEN_PADS(i2c)
1212

13+
1314
def pressure_to_altitude(p):
1415
return 44330 * (1 - (p / SEA_LEVEL_PRESSURE) ** EXPONENT)
1516

lib/wsen-pads/examples/pressure_trend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
MAX_VALUES = 10
1616
THRESHOLD = 0.5 # sensitivity (hPa)
1717

18+
1819
def get_trend(values):
1920
if len(values) < 2:
2021
return "N/A"

lib/wsen-pads/examples/temp_pressure_display.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
i2c = I2C(1)
1616
sensor = WSEN_PADS(i2c)
1717

18+
1819
def bar_graph(value, vmin, vmax, width=20):
1920
# Clamp value
2021
if value < vmin:

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ select = [
4848
"C90", # McCabe cyclomatic complexity
4949
"DTZ", # flake8-datetimez
5050
"E", # pycodestyle
51+
"E203", # (preview) whitespace before ':', ';', or ','
5152
"E225", # (preview) missing whitespace around operator
5253
"E261", # (preview) at least two spaces before inline comment
5354
"E262", # (preview) inline comment must start with '# '
5455
"E265", # (preview) block comment must start with '# '
56+
"E302", # (preview) expected 2 blank lines before function/class definition
57+
"E303", # (preview) too many blank lines
5558
"EXE", # flake8-executable
5659
"F", # Pyflakes
5760
"G", # flake8-logging-format

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def pytest_addoption(parser):
2323
)
2424

2525

26-
2726
def pytest_collection_modifyitems(config, items):
2827
port = config.getoption("--port")
2928
driver = config.getoption("--driver")

0 commit comments

Comments
 (0)