Skip to content

Commit ab648d4

Browse files
pdgendtnordicjm
authored andcommitted
[nrf fromtree] scripts: list_hardware: Fix linter issues
Fix issues reported by ruff. Signed-off-by: Pieter De Gendt <[email protected]> (cherry picked from commit c773f42)
1 parent 018e4a9 commit ab648d4

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

.ruff-excludes.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,6 @@
568568
"UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block
569569
"UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance
570570
]
571-
"./scripts/list_hardware.py" = [
572-
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
573-
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation
574-
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
575-
"UP032", # https://docs.astral.sh/ruff/rules/f-string
576-
"UP035", # https://docs.astral.sh/ruff/rules/deprecated-import
577-
]
578571
"./scripts/logging/dictionary/database_gen.py" = [
579572
"E713", # https://docs.astral.sh/ruff/rules/not-in-test
580573
"E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name

scripts/list_hardware.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
import argparse
7+
import re
8+
import sys
79
from dataclasses import dataclass
810
from pathlib import Path, PurePath
11+
912
import pykwalify.core
10-
import sys
11-
from typing import List
1213
import yaml
13-
import re
1414

1515
try:
1616
from yaml import CSafeLoader as SafeLoader
@@ -19,11 +19,11 @@
1919

2020

2121
SOC_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'soc-schema.yml')
22-
with open(SOC_SCHEMA_PATH, 'r') as f:
22+
with open(SOC_SCHEMA_PATH) as f:
2323
soc_schema = yaml.load(f.read(), Loader=SafeLoader)
2424

2525
ARCH_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'arch-schema.yml')
26-
with open(ARCH_SCHEMA_PATH, 'r') as f:
26+
with open(ARCH_SCHEMA_PATH) as f:
2727
arch_schema = yaml.load(f.read(), Loader=SafeLoader)
2828

2929
SOC_YML = 'soc.yml'
@@ -116,7 +116,7 @@ def from_file(socs_file):
116116
'''Load SoCs from a soc.yml file.
117117
'''
118118
try:
119-
with open(socs_file, 'r') as f:
119+
with open(socs_file) as f:
120120
socs_yaml = f.read()
121121
except FileNotFoundError as e:
122122
sys.exit(f'ERROR: socs.yml file not found: {socs_file.as_posix()}', e)
@@ -172,8 +172,8 @@ def get_soc(self, name):
172172
@dataclass
173173
class Soc:
174174
name: str
175-
cpuclusters: List[str]
176-
folder: List[str]
175+
cpuclusters: list[str]
176+
folder: list[str]
177177
series: str = ''
178178
family: str = ''
179179

@@ -186,17 +186,17 @@ def extend(self, soc):
186186
@dataclass
187187
class Series:
188188
name: str
189-
folder: List[str]
189+
folder: list[str]
190190
family: str
191-
socs: List[Soc]
191+
socs: list[Soc]
192192

193193

194194
@dataclass
195195
class Family:
196196
name: str
197-
folder: List[str]
198-
series: List[Series]
199-
socs: List[Soc]
197+
folder: list[str]
198+
series: list[Series]
199+
socs: list[Soc]
200200

201201

202202
def unique_paths(paths):
@@ -216,8 +216,7 @@ def find_v2_archs(args):
216216
try:
217217
pykwalify.core.Core(source_data=archs, schema_data=arch_schema).validate()
218218
except pykwalify.errors.SchemaError as e:
219-
sys.exit('ERROR: Malformed "build" section in file: {}\n{}'
220-
.format(archs_yml.as_posix(), e))
219+
sys.exit(f'ERROR: Malformed "build" section in file: {archs_yml.as_posix()}\n{e}')
221220

222221
if args.arch is not None:
223222
archs = {'archs': list(filter(

0 commit comments

Comments
 (0)