Skip to content

Commit 58563c0

Browse files
committed
tooling: Enable ruff preview rules for comment and operator spacing.
1 parent 7c1f087 commit 58563c0

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

lib/lis2mdl/lis2mdl/device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def heading_from_vectors(self, x, y, z, calibrated=True):
558558
x = (x - self.x_off) / (self.x_scale or 1.0)
559559
y = (y - self.y_off) / (self.y_scale or 1.0)
560560
# IMPORTANT: atan2(Y, X)
561-
ang = math.degrees(math.atan2(x, y)) # atan2(Y, X) for compass heading (Y is forward, X is right)
561+
ang = math.degrees(math.atan2(x, y)) # atan2(Y, X) for compass heading (Y is forward, X is right)
562562
ang = self._apply_heading_offsets(ang)
563563
return self._filter_heading(ang)
564564

lib/wsen-pads/examples/altitude.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from machine import I2C
44
from wsen_pads import WSEN_PADS
55

6-
SEA_LEVEL_PRESSURE = 1013.25 # depends on your location, you can adjust it for better altitude estimation
7-
EXPONENT = 0.1903 # standard atmosphere exponent for altitude calculation
6+
SEA_LEVEL_PRESSURE = 1013.25 # depends on your location, you can adjust it for better altitude estimation
7+
EXPONENT = 0.1903 # standard atmosphere exponent for altitude calculation
88

99
i2c = I2C(1)
1010

lib/wsen-pads/examples/pressure_trend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
pressure_history = []
1515
MAX_VALUES = 10
16-
THRESHOLD = 0.5 # sensitivity (hPa)
16+
THRESHOLD = 0.5 # sensitivity (hPa)
1717

1818
def get_trend(values):
1919
if len(values) < 2:

lib/wsen-pads/examples/threshold_alert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from wsen_pads import WSEN_PADS
77
from wsen_pads.const import ODR_10_HZ
88

9-
PRESSURE_ALERT_HPA = 1000 # Alert threshold
10-
READ_INTERVAL_S = 1 # Time between printed readings
9+
PRESSURE_ALERT_HPA = 1000 # Alert threshold
10+
READ_INTERVAL_S = 1 # Time between printed readings
1111

1212
i2c = I2C(1)
1313
sensor = WSEN_PADS(i2c)

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ line-length = 99
3737
target-version = "py37"
3838

3939
[tool.ruff.lint]
40+
preview = true
41+
explicit-preview-rules = true
4042
select = [
4143
"A", # flake8-builtins: prevent shadowing builtins
4244
"ASYNC", # flake8-async
@@ -45,6 +47,10 @@ select = [
4547
"C90", # McCabe cyclomatic complexity
4648
"DTZ", # flake8-datetimez
4749
"E", # pycodestyle
50+
"E225", # (preview) missing whitespace around operator
51+
"E261", # (preview) at least two spaces before inline comment
52+
"E262", # (preview) inline comment must start with '# '
53+
"E265", # (preview) block comment must start with '# '
4854
"EXE", # flake8-executable
4955
"F", # Pyflakes
5056
"G", # flake8-logging-format
@@ -83,6 +89,9 @@ ignore = [
8389
"PLW0603", # global statement
8490
"PLW2901", # overwriting loop variable
8591
"RUF012", # mutable class variable
92+
"RUF001", # ambiguous unicode in string (µ for microtesla is intentional)
93+
"RUF002", # ambiguous unicode in docstring
94+
"RUF003", # ambiguous unicode in comment
8695
"RUF100", # unused noqa
8796
"SIM101", # merge isinstance calls (micropython compat)
8897
"SIM105", # contextlib.suppress not available in micropython

0 commit comments

Comments
 (0)