top: Bump the Ruff version to 0.11.6.

With small code fixes to match.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
pull/1001/head
Angus Gratton 2025-04-24 10:41:10 +10:00 zatwierdzone przez Damien George
rodzic f8c8875e25
commit d887a021e8
7 zmienionych plików z 14 dodań i 17 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install --user ruff==0.1.2
# Version should be kept in sync with .pre-commit_config.yaml & also micropython
- run: pip install --user ruff==0.11.6
- run: ruff check --output-format=github .
- run: ruff format --diff .

Wyświetl plik

@ -8,7 +8,8 @@ repos:
verbose: true
stages: [commit-msg]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.2
# Version should be kept in sync with .github/workflows/ruff.yml & also micropython
rev: v0.11.6
hooks:
- id: ruff
id: ruff-format

Wyświetl plik

@ -88,7 +88,7 @@ class FileClient:
await self._command(_COMMAND_SEND, path.encode())
with open(dest, "wb") as f: # noqa: ASYNC101
with open(dest, "wb") as f: # noqa: ASYNC230
total = 0
buf = bytearray(self._channel.our_mtu)
mv = memoryview(buf)

Wyświetl plik

@ -83,7 +83,7 @@ async def l2cap_task(connection):
if send_file:
print("Sending:", send_file)
with open(send_file, "rb") as f: # noqa: ASYNC101
with open(send_file, "rb") as f: # noqa: ASYNC230
buf = bytearray(channel.peer_mtu)
mv = memoryview(buf)
while n := f.readinto(buf):

Wyświetl plik

@ -331,8 +331,7 @@ class WM8960:
sysclk = 11289600
else:
sysclk = 12288000
if sysclk < sample_rate * 256:
sysclk = sample_rate * 256
sysclk = max(sysclk, sample_rate * 256)
if mclk_freq is None:
mclk_freq = sysclk
else: # sysclk_source == SYSCLK_MCLK
@ -691,10 +690,8 @@ class WM8960:
def alc_gain(self, target=-12, max_gain=30, min_gain=-17.25, noise_gate=-78):
def limit(value, minval, maxval):
value = int(value)
if value < minval:
value = minval
if value > maxval:
value = maxval
value = max(value, minval)
value = min(value, maxval)
return value
target = limit((16 + (target * 2) // 3), 0, 15)
@ -718,8 +715,7 @@ class WM8960:
while value > 1:
value >>= 1
lb += 1
if lb > limit:
lb = limit
lb = min(lb, limit)
return lb
attack = logb(attack / 6, 7)

Wyświetl plik

@ -189,10 +189,8 @@ class LCD160CR:
c[3] = h - 1
else:
if c[0] == c[2]:
if c[1] < 0:
c[1] = 0
if c[3] < 0:
c[3] = 0
c[1] = max(c[1], 0)
c[3] = max(c[3], 0)
else:
if c[3] < c[1]:
c[0], c[2] = c[2], c[0]

Wyświetl plik

@ -64,7 +64,7 @@ ignore = [
"ISC003", # micropython does not support implicit concatenation of f-strings
"PIE810", # micropython does not support passing tuples to .startswith or .endswith
"PLC1901",
"PLR1701",
"PLR1704", # sometimes desirable to redefine an argument to save code size
"PLR1714",
"PLR5501",
"PLW0602",
@ -72,6 +72,7 @@ ignore = [
"PLW2901",
"RUF012",
"RUF100",
"SIM101",
"W191", # tab-indent, redundant when using formatter
]
line-length = 99