Browse Source

scripts: list_hardware: Fix linter issues

Fix issues reported by ruff.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
pull/85392/head
Pieter De Gendt 1 month ago committed by Benjamin Cabé
parent
commit
c773f42013
  1. 7
      .ruff-excludes.toml
  2. 29
      scripts/list_hardware.py

7
.ruff-excludes.toml

@ -568,13 +568,6 @@ @@ -568,13 +568,6 @@
"UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block
"UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance
]
"./scripts/list_hardware.py" = [
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
"UP032", # https://docs.astral.sh/ruff/rules/f-string
"UP035", # https://docs.astral.sh/ruff/rules/deprecated-import
]
"./scripts/logging/dictionary/database_gen.py" = [
"E713", # https://docs.astral.sh/ruff/rules/not-in-test
"E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name

29
scripts/list_hardware.py

@ -4,13 +4,13 @@ @@ -4,13 +4,13 @@
# SPDX-License-Identifier: Apache-2.0
import argparse
import re
import sys
from dataclasses import dataclass
from pathlib import Path, PurePath
import pykwalify.core
import sys
from typing import List
import yaml
import re
try:
from yaml import CSafeLoader as SafeLoader
@ -19,13 +19,13 @@ except ImportError: @@ -19,13 +19,13 @@ except ImportError:
SOC_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'soc-schema.yml')
with open(SOC_SCHEMA_PATH, 'r') as f:
with open(SOC_SCHEMA_PATH) as f:
soc_schema = yaml.load(f.read(), Loader=SafeLoader)
SOC_VALIDATOR = pykwalify.core.Core(schema_data=soc_schema, source_data={})
ARCH_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'arch-schema.yml')
with open(ARCH_SCHEMA_PATH, 'r') as f:
with open(ARCH_SCHEMA_PATH) as f:
arch_schema = yaml.load(f.read(), Loader=SafeLoader)
ARCH_VALIDATOR = pykwalify.core.Core(schema_data=arch_schema, source_data={})
@ -120,7 +120,7 @@ class Systems: @@ -120,7 +120,7 @@ class Systems:
'''Load SoCs from a soc.yml file.
'''
try:
with open(socs_file, 'r') as f:
with open(socs_file) as f:
socs_yaml = f.read()
except FileNotFoundError as e:
sys.exit(f'ERROR: socs.yml file not found: {socs_file.as_posix()}', e)
@ -176,8 +176,8 @@ class Systems: @@ -176,8 +176,8 @@ class Systems:
@dataclass
class Soc:
name: str
cpuclusters: List[str]
folder: List[str]
cpuclusters: list[str]
folder: list[str]
series: str = ''
family: str = ''
@ -190,17 +190,17 @@ class Soc: @@ -190,17 +190,17 @@ class Soc:
@dataclass
class Series:
name: str
folder: List[str]
folder: list[str]
family: str
socs: List[Soc]
socs: list[Soc]
@dataclass
class Family:
name: str
folder: List[str]
series: List[Series]
socs: List[Soc]
folder: list[str]
series: list[Series]
socs: list[Soc]
def unique_paths(paths):
@ -221,8 +221,7 @@ def find_v2_archs(args): @@ -221,8 +221,7 @@ def find_v2_archs(args):
ARCH_VALIDATOR.source = archs
ARCH_VALIDATOR.validate()
except pykwalify.errors.SchemaError as e:
sys.exit('ERROR: Malformed "build" section in file: {}\n{}'
.format(archs_yml.as_posix(), e))
sys.exit(f'ERROR: Malformed "build" section in file: {archs_yml.as_posix()}\n{e}')
if args.arch is not None:
archs = {'archs': list(filter(

Loading…
Cancel
Save