Skip to content

Commit 7a04efe

Browse files
committed
pre_commit, ci: Bump the Ruff version to 0.11.6.
With small code fixes to match. Signed-off-by: Angus Gratton <[email protected]>
1 parent 583bc0d commit 7a04efe

File tree

7 files changed

+14
-17
lines changed

7 files changed

+14
-17
lines changed

.github/workflows/ruff.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v4
9-
- run: pip install --user ruff==0.1.2
9+
# Version should be kept in sync with .pre-commit_config.yaml & also micropython
10+
- run: pip install --user ruff==0.11.6
1011
- run: ruff check --output-format=github .
1112
- run: ruff format --diff .

.pre-commit-config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ repos:
88
verbose: true
99
stages: [commit-msg]
1010
- repo: https://github.com/charliermarsh/ruff-pre-commit
11-
rev: v0.1.2
11+
# Version should be kept in sync with .github/workflows/ruff.yml & also micropython
12+
rev: v0.11.6
1213
hooks:
1314
- id: ruff
1415
id: ruff-format

micropython/bluetooth/aioble/examples/l2cap_file_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async def download(self, path, dest):
8787

8888
send_seq = await self._command(_COMMAND_SEND, path.encode())
8989

90-
with open(dest, "wb") as f: # noqa: ASYNC101
90+
with open(dest, "wb") as f: # noqa: ASYNC230
9191
total = 0
9292
buf = bytearray(self._channel.our_mtu)
9393
mv = memoryview(buf)

micropython/bluetooth/aioble/examples/l2cap_file_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def l2cap_task(connection):
8282

8383
if send_file:
8484
print("Sending:", send_file)
85-
with open(send_file, "rb") as f: # noqa: ASYNC101
85+
with open(send_file, "rb") as f: # noqa: ASYNC230
8686
buf = bytearray(channel.peer_mtu)
8787
mv = memoryview(buf)
8888
while n := f.readinto(buf):

micropython/drivers/codec/wm8960/wm8960.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ def __init__(
331331
sysclk = 11289600
332332
else:
333333
sysclk = 12288000
334-
if sysclk < sample_rate * 256:
335-
sysclk = sample_rate * 256
334+
sysclk = max(sysclk, sample_rate * 256)
336335
if mclk_freq is None:
337336
mclk_freq = sysclk
338337
else: # sysclk_source == SYSCLK_MCLK
@@ -691,10 +690,8 @@ def alc_mode(self, channel, mode=ALC_MODE):
691690
def alc_gain(self, target=-12, max_gain=30, min_gain=-17.25, noise_gate=-78):
692691
def limit(value, minval, maxval):
693692
value = int(value)
694-
if value < minval:
695-
value = minval
696-
if value > maxval:
697-
value = maxval
693+
value = max(value, minval)
694+
value = min(value, maxval)
698695
return value
699696

700697
target = limit((16 + (target * 2) // 3), 0, 15)
@@ -718,8 +715,7 @@ def logb(value, limit):
718715
while value > 1:
719716
value >>= 1
720717
lb += 1
721-
if lb > limit:
722-
lb = limit
718+
lb = min(lb, limit)
723719
return lb
724720

725721
attack = logb(attack / 6, 7)

micropython/drivers/display/lcd160cr/lcd160cr.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ def clip_line(c, w, h):
188188
c[3] = h - 1
189189
else:
190190
if c[0] == c[2]:
191-
if c[1] < 0:
192-
c[1] = 0
193-
if c[3] < 0:
194-
c[3] = 0
191+
c[1] = max(c[1], 0)
192+
c[3] = max(c[3], 0)
195193
else:
196194
if c[3] < c[1]:
197195
c[0], c[2] = c[2], c[0]

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ ignore = [
6868
"ISC003", # micropython does not support implicit concatenation of f-strings
6969
"PIE810", # micropython does not support passing tuples to .startswith or .endswith
7070
"PLC1901",
71-
"PLR1701",
71+
"PLR1704", # sometimes desirable to redefine an argument to save code size
7272
"PLR1714",
7373
"PLR5501",
7474
"PLW0602",
7575
"PLW0603",
7676
"PLW2901",
7777
"RUF012",
7878
"RUF100",
79+
"SIM101",
7980
"W191",
8081
]
8182
line-length = 99

0 commit comments

Comments
 (0)