diff --git a/.vscode/settings.json b/.vscode/settings.json index 70758b93..9d5cbde6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,31 +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/vl53l1x", - "lib/wsen-hids", - "lib/wsen-pads" - ], - "python.analysis.stubPath": "typings", - "python.analysis.diagnosticSeverityOverrides": { - "reportMissingModuleSource": "none", - "reportWildcardImportFromLibrary": "none", - "reportGeneralTypeIssues": "warning" - }, - "pylint.enabled": false, - "mypy-type-checker.enabled": false + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" } 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..74e80d79 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 @@ -125,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" 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")