Skip to content

Commit dae9b8c

Browse files
committed
applications: nrf5340_audio: Fix python code using ruff
This auto-fixes the code using ruff Signed-off-by: Jamie McCrae <[email protected]>
1 parent ffa6339 commit dae9b8c

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

applications/nrf5340_audio/tools/buildprog/buildprog.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99
"""
1010

1111
import argparse
12-
import sys
13-
import shutil
14-
import os
12+
import getpass
1513
import json
16-
import subprocess
14+
import os
1715
import re
18-
import getpass
16+
import shutil
17+
import subprocess
18+
import sys
1919
from pathlib import Path
20+
2021
from colorama import Fore, Style
21-
from prettytable import PrettyTable
2222
from nrf5340_audio_dk_devices import (
23+
AudioDevice,
24+
BuildConf,
2325
BuildType,
24-
Location,
26+
Core,
2527
DeviceConf,
26-
BuildConf,
27-
AudioDevice,
28+
Location,
2829
SelectFlags,
29-
Core,
3030
Transport,
3131
)
32+
from prettytable import PrettyTable
3233
from program import program_threads_run
3334

34-
3535
BUILDPROG_FOLDER = Path(__file__).resolve().parent
3636
NRF5340_AUDIO_FOLDER = (BUILDPROG_FOLDER / "../..").resolve()
3737
NRF_FOLDER = (BUILDPROG_FOLDER / "../../../..").resolve()

applications/nrf5340_audio/tools/buildprog/nrf5340_audio_dk_devices.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from dataclasses import InitVar, dataclass, field
1111
from enum import Enum
1212
from pathlib import Path
13-
from typing import List
1413

1514

1615
class SelectFlags(str, Enum):
@@ -103,8 +102,8 @@ class DeviceConf:
103102
nrf5340_audio_dk_dev: AudioDevice
104103
recover_on_fail: bool
105104

106-
cores: InitVar[List[Core]]
107-
devices: InitVar[List[AudioDevice]]
105+
cores: InitVar[list[Core]]
106+
devices: InitVar[list[AudioDevice]]
108107
_only_reboot: InitVar[SelectFlags]
109108
# Post init variables
110109
only_reboot: SelectFlags = field(init=False, default=SelectFlags.NOT)
@@ -116,7 +115,7 @@ class DeviceConf:
116115
init=False, default=SelectFlags.NOT)
117116

118117
def __post_init__(
119-
self, cores: List[Core], devices: List[AudioDevice], _only_reboot: SelectFlags,
118+
self, cores: list[Core], devices: list[AudioDevice], _only_reboot: SelectFlags,
120119
):
121120
device_selected = self.nrf5340_audio_dk_dev in devices
122121
self.only_reboot = _only_reboot if device_selected else SelectFlags.NOT

applications/nrf5340_audio/tools/buildprog/program.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
""" Tools to program multiple nRF5340 Audio DKs """
88

9+
from os import path, system
910
from threading import Thread
10-
from os import system, path
11-
from typing import List
12-
from nrf5340_audio_dk_devices import DeviceConf, SelectFlags, AudioDevice, Location
11+
12+
from nrf5340_audio_dk_devices import AudioDevice, DeviceConf, Location, SelectFlags
1313

1414
MEM_ADDR_UICR_SNR = 0x00FF80F0
1515
MEM_ADDR_UICR_CH = 0x00FF80F4
@@ -20,7 +20,7 @@ def print_location_labels(locations):
2020
labels.append(Location.MONO_AUDIO.label)
2121
print(" + ".join(labels))
2222

23-
def locations_to_bitfield(locations: List[Location]) -> int:
23+
def locations_to_bitfield(locations: list[Location]) -> int:
2424
bitfield = 0
2525
for loc in locations:
2626
bitfield |= loc.value
@@ -41,10 +41,7 @@ def __populate_uicr(dev):
4141

4242
# Write segger nr to UICR
4343
ret_val = system(cmd)
44-
if ret_val:
45-
return False
46-
else:
47-
return True
44+
return not ret_val
4845

4946

5047
def _program_cores(dev: DeviceConf) -> int:
@@ -122,7 +119,7 @@ def __program_thread(dev: DeviceConf):
122119
_program_cores(dev)
123120

124121

125-
def program_threads_run(devices_list: List[DeviceConf], sequential: bool = False):
122+
def program_threads_run(devices_list: list[DeviceConf], sequential: bool = False):
126123
"""Program devices in parallel"""
127124
threads = []
128125
# First program net cores if applicable

0 commit comments

Comments
 (0)