From b3cdbcb383f81cb6a7364312a06b4d34c0e3e15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Thu, 16 Apr 2026 22:29:59 +0200 Subject: [PATCH] tooling: Enable ruff preview rules E231, E275, E301, E305, and W391. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #402. Second round of explicit preview rules, following #400 (E203/E302/E303): E231 — missing whitespace after comma (prevents dense 0,15 in arrays) E275 — missing whitespace after keyword (catches if(...) without space) E301 — blank line between methods in a class E305 — 2 blank lines after function/class definition (symmetric with E302) W391 — too many newlines at end of file Auto-fixed the 5 existing E305 violations, all in example files. --- lib/wsen-hids/examples/comfort_monitor.py | 1 + lib/wsen-hids/examples/dew_point.py | 1 + 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 | 5 +++++ 6 files changed, 10 insertions(+) diff --git a/lib/wsen-hids/examples/comfort_monitor.py b/lib/wsen-hids/examples/comfort_monitor.py index 84b9db34..b8df1626 100644 --- a/lib/wsen-hids/examples/comfort_monitor.py +++ b/lib/wsen-hids/examples/comfort_monitor.py @@ -18,6 +18,7 @@ def comfort_label(humidity): else: return "Humid" + while True: humidity, temperature = sensor.read_one_shot() comfort = comfort_label(humidity) diff --git a/lib/wsen-hids/examples/dew_point.py b/lib/wsen-hids/examples/dew_point.py index 0cd60b2a..759e8399 100644 --- a/lib/wsen-hids/examples/dew_point.py +++ b/lib/wsen-hids/examples/dew_point.py @@ -20,6 +20,7 @@ def dew_point_celsius(temperature_c, humidity): dp = (b * gamma) / (a - gamma) return dp + humidity, temperature = sensor.read_one_shot() dew_point = dew_point_celsius(temperature, humidity) diff --git a/lib/wsen-pads/examples/altitude.py b/lib/wsen-pads/examples/altitude.py index 83490957..cffc7bc3 100644 --- a/lib/wsen-pads/examples/altitude.py +++ b/lib/wsen-pads/examples/altitude.py @@ -14,6 +14,7 @@ def pressure_to_altitude(p): return 44330 * (1 - (p / SEA_LEVEL_PRESSURE) ** EXPONENT) + for _ in range(10): pressure, temp = sensor.read() diff --git a/lib/wsen-pads/examples/pressure_trend.py b/lib/wsen-pads/examples/pressure_trend.py index 5abbfbd2..9ce28607 100644 --- a/lib/wsen-pads/examples/pressure_trend.py +++ b/lib/wsen-pads/examples/pressure_trend.py @@ -33,6 +33,7 @@ def get_trend(values): else: return "falling" + while True: pressure = sensor.pressure_hpa() diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py index ab827175..def276ca 100644 --- a/lib/wsen-pads/examples/temp_pressure_display.py +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -28,6 +28,7 @@ def bar_graph(value, vmin, vmax, width=20): return "[" + "#" * filled + "-" * (width - filled) + "]" + while True: pressure, temp = sensor.read() temp_bar = bar_graph(temp, TEMP_MIN, TEMP_MAX) diff --git a/pyproject.toml b/pyproject.toml index 647858b9..e7cc1096 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,11 +50,15 @@ select = [ "E", # pycodestyle "E203", # (preview) whitespace before ':', ';', or ',' "E225", # (preview) missing whitespace around operator + "E231", # (preview) missing whitespace after ',' "E261", # (preview) at least two spaces before inline comment "E262", # (preview) inline comment must start with '# ' "E265", # (preview) block comment must start with '# ' + "E275", # (preview) missing whitespace after keyword + "E301", # (preview) blank line between methods "E302", # (preview) expected 2 blank lines before function/class definition "E303", # (preview) too many blank lines + "E305", # (preview) expected 2 blank lines after function/class definition "EXE", # flake8-executable "F", # Pyflakes "G", # flake8-logging-format @@ -78,6 +82,7 @@ select = [ "T20", # flake8-print: no print() in production code "TCH", # flake8-type-checking "W", # pycodestyle + "W391", # (preview) too many newlines at end of file "YTT", # flake8-2020 ] ignore = [