From 14c15e77b417a67ca8b80f71bd3c04df67bf95f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Thu, 16 Apr 2026 21:23:26 +0200 Subject: [PATCH 1/4] tooling: Enable ruff preview rules E203, E302, and E303. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/apds9960/examples/light_theremin.py | 2 -- lib/mcp23009e/examples/i2c_scan.py | 1 - lib/steami_config/steami_config/device.py | 2 +- lib/steami_screen/steami_screen/device.py | 2 +- lib/wsen-pads/examples/altitude.py | 1 + lib/wsen-pads/examples/pressure_trend.py | 1 + lib/wsen-pads/examples/temp_pressure_display.py | 1 + pyproject.toml | 3 +++ tests/conftest.py | 1 - 9 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/apds9960/examples/light_theremin.py b/lib/apds9960/examples/light_theremin.py index 7190982f..e6a2204b 100644 --- a/lib/apds9960/examples/light_theremin.py +++ b/lib/apds9960/examples/light_theremin.py @@ -66,7 +66,6 @@ # Map the light range to an index in our note array (0 to 14) note_index = (clamped_light - MIN_LIGHT) * (TOTAL_NOTES - 1) // range_light - # Fetch the perfect harmonic frequency freq = PENTATONIC_NOTES[note_index] @@ -77,7 +76,6 @@ print("Light: {} | Note: {} | Freq: {} Hz".format(light_level, note_index, freq), end="\r") last_freq = freq - sleep_ms(20) except KeyboardInterrupt: diff --git a/lib/mcp23009e/examples/i2c_scan.py b/lib/mcp23009e/examples/i2c_scan.py index 2adc3a43..5e9f2457 100644 --- a/lib/mcp23009e/examples/i2c_scan.py +++ b/lib/mcp23009e/examples/i2c_scan.py @@ -13,7 +13,6 @@ reset.value(1) - print("=" * 60) print("Scanner I2C - Recherche des périphériques") print("=" * 60) diff --git a/lib/steami_config/steami_config/device.py b/lib/steami_config/steami_config/device.py index 47eb36f6..05a55cc5 100644 --- a/lib/steami_config/steami_config/device.py +++ b/lib/steami_config/steami_config/device.py @@ -12,6 +12,7 @@ # Reverse map: short key -> sensor name. _KEY_SENSORS = {v: k for k, v in _SENSOR_KEYS.items()} + class SteamiConfig(object): """Persistent configuration stored in the DAPLink F103 config zone. @@ -239,7 +240,6 @@ def get_accelerometer_calibration(self): "oz": cal.get("oz", 0.0), } - def apply_accelerometer_calibration(self, ism330dl_instance): """Apply stored accelerometer calibration to an ISM330DL instance.""" if type(ism330dl_instance).__name__.lower() != "ism330dl": diff --git a/lib/steami_screen/steami_screen/device.py b/lib/steami_screen/steami_screen/device.py index 302e4f5d..16f17a7e 100644 --- a/lib/steami_screen/steami_screen/device.py +++ b/lib/steami_screen/steami_screen/device.py @@ -40,6 +40,7 @@ # --- Cardinal position names --- + class Screen: """High-level wrapper around a raw display backend.""" @@ -196,7 +197,6 @@ def bar(self, val, max_val=100, y_offset=0, color=LIGHT): if fill_w > 0: self._fill_rect(bx, by, fill_w, bar_h, color) - def gauge(self, val, min_val=0, max_val=100, color=LIGHT): """Draw a circular arc gauge (270 deg, gap at bottom). diff --git a/lib/wsen-pads/examples/altitude.py b/lib/wsen-pads/examples/altitude.py index 84f0d589..83490957 100644 --- a/lib/wsen-pads/examples/altitude.py +++ b/lib/wsen-pads/examples/altitude.py @@ -10,6 +10,7 @@ sensor = WSEN_PADS(i2c) + def pressure_to_altitude(p): return 44330 * (1 - (p / SEA_LEVEL_PRESSURE) ** EXPONENT) diff --git a/lib/wsen-pads/examples/pressure_trend.py b/lib/wsen-pads/examples/pressure_trend.py index 6424306c..5abbfbd2 100644 --- a/lib/wsen-pads/examples/pressure_trend.py +++ b/lib/wsen-pads/examples/pressure_trend.py @@ -15,6 +15,7 @@ MAX_VALUES = 10 THRESHOLD = 0.5 # sensitivity (hPa) + def get_trend(values): if len(values) < 2: return "N/A" diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py index bb558bea..ab827175 100644 --- a/lib/wsen-pads/examples/temp_pressure_display.py +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -15,6 +15,7 @@ i2c = I2C(1) sensor = WSEN_PADS(i2c) + def bar_graph(value, vmin, vmax, width=20): # Clamp value if value < vmin: diff --git a/pyproject.toml b/pyproject.toml index c8ecd7e0..2217d6d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,10 +48,13 @@ select = [ "C90", # McCabe cyclomatic complexity "DTZ", # flake8-datetimez "E", # pycodestyle + "E203", # (preview) whitespace before ':', ';', or ',' "E225", # (preview) missing whitespace around operator "E261", # (preview) at least two spaces before inline comment "E262", # (preview) inline comment must start with '# ' "E265", # (preview) block comment must start with '# ' + "E302", # (preview) expected 2 blank lines before function/class definition + "E303", # (preview) too many blank lines "EXE", # flake8-executable "F", # Pyflakes "G", # flake8-logging-format diff --git a/tests/conftest.py b/tests/conftest.py index a2da1f13..2863b7e6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,6 @@ def pytest_addoption(parser): ) - def pytest_collection_modifyitems(config, items): port = config.getoption("--port") driver = config.getoption("--driver") From b1c45095031021e6f97e549aa34f0fcd2c510627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Thu, 16 Apr 2026 21:24:35 +0200 Subject: [PATCH 2/4] tooling: Add steami_screen to Pylance extraPaths. --- .vscode/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 70758b93..5faa1b79 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,6 +16,7 @@ "lib/mcp23009e", "lib/ssd1327", "lib/steami_config", + "lib/steami_screen", "lib/vl53l1x", "lib/wsen-hids", "lib/wsen-pads" From 47ee02a3fc557b00cdf723b0f23bec4ca409f091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Thu, 16 Apr 2026 21:26:34 +0200 Subject: [PATCH 3/4] tooling: Remove deprecated and unknown settings from VSCode config. --- .vscode/settings.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5faa1b79..2834112c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,9 +24,6 @@ "python.analysis.stubPath": "typings", "python.analysis.diagnosticSeverityOverrides": { "reportMissingModuleSource": "none", - "reportWildcardImportFromLibrary": "none", - "reportGeneralTypeIssues": "warning" - }, - "pylint.enabled": false, - "mypy-type-checker.enabled": false + "reportWildcardImportFromLibrary": "none" + } } From 0bcc42d85ddb922039ae06ccdb0e69b51f0cc57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Thu, 16 Apr 2026 21:29:25 +0200 Subject: [PATCH 4/4] tooling: Migrate Pylance settings from VSCode to pyproject.toml. Pylance ignores python.analysis.* in settings.json when a pyproject.toml exists and warns "cannot be set when a pyproject.toml is being used". Move typeCheckingMode, extraPaths, stubPath, and diagnosticSeverityOverrides into [tool.pyright] in pyproject.toml where Pylance reads them. This also makes the configuration IDE-agnostic (works for any pyright-based tool, not just VSCode). --- .vscode/settings.json | 27 +-------------------------- pyproject.toml | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2834112c..9d5cbde6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,29 +1,4 @@ { "python.languageServer": "Pylance", - "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", - "python.analysis.typeCheckingMode": "basic", - "python.analysis.extraPaths": [ - "lib/apds9960", - "lib/bme280", - "lib/bq27441", - "lib/daplink_bridge", - "lib/daplink_flash", - "lib/gc9a01", - "lib/hts221", - "lib/im34dt05", - "lib/ism330dl", - "lib/lis2mdl", - "lib/mcp23009e", - "lib/ssd1327", - "lib/steami_config", - "lib/steami_screen", - "lib/vl53l1x", - "lib/wsen-hids", - "lib/wsen-pads" - ], - "python.analysis.stubPath": "typings", - "python.analysis.diagnosticSeverityOverrides": { - "reportMissingModuleSource": "none", - "reportWildcardImportFromLibrary": "none" - } + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" } diff --git a/pyproject.toml b/pyproject.toml index 2217d6d0..74e80d79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,3 +128,28 @@ quote-style = "double" indent-style = "space" skip-magic-trailing-comma = false line-ending = "auto" + +[tool.pyright] +typeCheckingMode = "basic" +stubPath = "typings" +extraPaths = [ + "lib/apds9960", + "lib/bme280", + "lib/bq27441", + "lib/daplink_bridge", + "lib/daplink_flash", + "lib/gc9a01", + "lib/hts221", + "lib/im34dt05", + "lib/ism330dl", + "lib/lis2mdl", + "lib/mcp23009e", + "lib/ssd1327", + "lib/steami_config", + "lib/steami_screen", + "lib/vl53l1x", + "lib/wsen-hids", + "lib/wsen-pads", +] +reportMissingModuleSource = "none" +reportWildcardImportFromLibrary = "none"