scripts: list_hardware: Fix linter issues
Fix issues reported by ruff. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
parent
b2687468b5
commit
c773f42013
2 changed files with 14 additions and 22 deletions
|
@ -568,13 +568,6 @@
|
||||||
"UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block
|
"UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block
|
||||||
"UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance
|
"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" = [
|
"./scripts/logging/dictionary/database_gen.py" = [
|
||||||
"E713", # https://docs.astral.sh/ruff/rules/not-in-test
|
"E713", # https://docs.astral.sh/ruff/rules/not-in-test
|
||||||
"E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name
|
"E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
|
|
||||||
import pykwalify.core
|
import pykwalify.core
|
||||||
import sys
|
|
||||||
from typing import List
|
|
||||||
import yaml
|
import yaml
|
||||||
import re
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from yaml import CSafeLoader as SafeLoader
|
from yaml import CSafeLoader as SafeLoader
|
||||||
|
@ -19,13 +19,13 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
SOC_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'soc-schema.yml')
|
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_schema = yaml.load(f.read(), Loader=SafeLoader)
|
||||||
|
|
||||||
SOC_VALIDATOR = pykwalify.core.Core(schema_data=soc_schema, source_data={})
|
SOC_VALIDATOR = pykwalify.core.Core(schema_data=soc_schema, source_data={})
|
||||||
|
|
||||||
ARCH_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'arch-schema.yml')
|
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_schema = yaml.load(f.read(), Loader=SafeLoader)
|
||||||
|
|
||||||
ARCH_VALIDATOR = pykwalify.core.Core(schema_data=arch_schema, source_data={})
|
ARCH_VALIDATOR = pykwalify.core.Core(schema_data=arch_schema, source_data={})
|
||||||
|
@ -120,7 +120,7 @@ class Systems:
|
||||||
'''Load SoCs from a soc.yml file.
|
'''Load SoCs from a soc.yml file.
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
with open(socs_file, 'r') as f:
|
with open(socs_file) as f:
|
||||||
socs_yaml = f.read()
|
socs_yaml = f.read()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
sys.exit(f'ERROR: socs.yml file not found: {socs_file.as_posix()}', e)
|
sys.exit(f'ERROR: socs.yml file not found: {socs_file.as_posix()}', e)
|
||||||
|
@ -176,8 +176,8 @@ class Systems:
|
||||||
@dataclass
|
@dataclass
|
||||||
class Soc:
|
class Soc:
|
||||||
name: str
|
name: str
|
||||||
cpuclusters: List[str]
|
cpuclusters: list[str]
|
||||||
folder: List[str]
|
folder: list[str]
|
||||||
series: str = ''
|
series: str = ''
|
||||||
family: str = ''
|
family: str = ''
|
||||||
|
|
||||||
|
@ -190,17 +190,17 @@ class Soc:
|
||||||
@dataclass
|
@dataclass
|
||||||
class Series:
|
class Series:
|
||||||
name: str
|
name: str
|
||||||
folder: List[str]
|
folder: list[str]
|
||||||
family: str
|
family: str
|
||||||
socs: List[Soc]
|
socs: list[Soc]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Family:
|
class Family:
|
||||||
name: str
|
name: str
|
||||||
folder: List[str]
|
folder: list[str]
|
||||||
series: List[Series]
|
series: list[Series]
|
||||||
socs: List[Soc]
|
socs: list[Soc]
|
||||||
|
|
||||||
|
|
||||||
def unique_paths(paths):
|
def unique_paths(paths):
|
||||||
|
@ -221,8 +221,7 @@ def find_v2_archs(args):
|
||||||
ARCH_VALIDATOR.source = archs
|
ARCH_VALIDATOR.source = archs
|
||||||
ARCH_VALIDATOR.validate()
|
ARCH_VALIDATOR.validate()
|
||||||
except pykwalify.errors.SchemaError as e:
|
except pykwalify.errors.SchemaError as e:
|
||||||
sys.exit('ERROR: Malformed "build" section in file: {}\n{}'
|
sys.exit(f'ERROR: Malformed "build" section in file: {archs_yml.as_posix()}\n{e}')
|
||||||
.format(archs_yml.as_posix(), e))
|
|
||||||
|
|
||||||
if args.arch is not None:
|
if args.arch is not None:
|
||||||
archs = {'archs': list(filter(
|
archs = {'archs': list(filter(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue