Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d887a02

Browse files
projectgusdpgeorge
authored andcommitted
top: Bump the Ruff version to 0.11.6.
With small code fixes to match. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent f8c8875 commit d887a02

File tree

7 files changed

+14
-17
lines changed

7 files changed

+14
-17
lines changed

‎.github/workflows/ruff.yml‎

Lines changed: 2 additions & 1 deletion
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‎

Lines changed: 2 additions & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def download(self, path, dest):
8888

8989
await self._command(_COMMAND_SEND, path.encode())
9090

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

‎micropython/bluetooth/aioble/examples/l2cap_file_server.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def l2cap_task(connection):
8383

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

‎micropython/drivers/codec/wm8960/wm8960.py‎

Lines changed: 4 additions & 8 deletions
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‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,8 @@ def clip_line(c, w, h):
189189
c[3] = h - 1
190190
else:
191191
if c[0] == c[2]:
192-
if c[1] < 0:
193-
c[1] = 0
194-
if c[3] < 0:
195-
c[3] = 0
192+
c[1] = max(c[1], 0)
193+
c[3] = max(c[3], 0)
196194
else:
197195
if c[3] < c[1]:
198196
c[0], c[2] = c[2], c[0]

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ ignore = [
6464
"ISC003", # micropython does not support implicit concatenation of f-strings
6565
"PIE810", # micropython does not support passing tuples to .startswith or .endswith
6666
"PLC1901",
67-
"PLR1701",
67+
"PLR1704", # sometimes desirable to redefine an argument to save code size
6868
"PLR1714",
6969
"PLR5501",
7070
"PLW0602",
7171
"PLW0603",
7272
"PLW2901",
7373
"RUF012",
7474
"RUF100",
75+
"SIM101",
7576
"W191", # tab-indent, redundant when using formatter
7677
]
7778
line-length = 99

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /