Skip to content

Commit c773f42

Browse files
pdgendtkartben
authored andcommitted
scripts: list_hardware: Fix linter issues
Fix issues reported by ruff. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent b268746 commit c773f42

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,13 +19,13 @@
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
SOC_VALIDATOR = pykwalify.core.Core(schema_data=soc_schema, source_data={})
2626

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

3131
ARCH_VALIDATOR = pykwalify.core.Core(schema_data=arch_schema, source_data={})
@@ -120,7 +120,7 @@ def from_file(socs_file):
120120
'''Load SoCs from a soc.yml file.
121121
'''
122122
try:
123-
with open(socs_file, 'r') as f:
123+
with open(socs_file) as f:
124124
socs_yaml = f.read()
125125
except FileNotFoundError as e:
126126
sys.exit(f'ERROR: socs.yml file not found: {socs_file.as_posix()}', e)
@@ -176,8 +176,8 @@ def get_soc(self, name):
176176
@dataclass
177177
class Soc:
178178
name: str
179-
cpuclusters: List[str]
180-
folder: List[str]
179+
cpuclusters: list[str]
180+
folder: list[str]
181181
series: str = ''
182182
family: str = ''
183183

@@ -190,17 +190,17 @@ def extend(self, soc):
190190
@dataclass
191191
class Series:
192192
name: str
193-
folder: List[str]
193+
folder: list[str]
194194
family: str
195-
socs: List[Soc]
195+
socs: list[Soc]
196196

197197

198198
@dataclass
199199
class Family:
200200
name: str
201-
folder: List[str]
202-
series: List[Series]
203-
socs: List[Soc]
201+
folder: list[str]
202+
series: list[Series]
203+
socs: list[Soc]
204204

205205

206206
def unique_paths(paths):
@@ -221,8 +221,7 @@ def find_v2_archs(args):
221221
ARCH_VALIDATOR.source = archs
222222
ARCH_VALIDATOR.validate()
223223
except pykwalify.errors.SchemaError as e:
224-
sys.exit('ERROR: Malformed "build" section in file: {}\n{}'
225-
.format(archs_yml.as_posix(), e))
224+
sys.exit(f'ERROR: Malformed "build" section in file: {archs_yml.as_posix()}\n{e}')
226225

227226
if args.arch is not None:
228227
archs = {'archs': list(filter(

0 commit comments

Comments
 (0)