Skip to content

Commit

Permalink
apply lint recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamyar committed Jul 24, 2023
1 parent e67568c commit f96a06c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
31 changes: 20 additions & 11 deletions src/xeda/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import logging
import os
import subprocess
import sys
from enum import Enum, auto
from functools import cached_property
from pathlib import Path
Expand Down Expand Up @@ -264,7 +263,7 @@ class DVSettings(XedaBaseModel):
)
defines: Dict[str, DefineType] = Field(default={})

@root_validator(pre=True)
@root_validator(pre=True, allow_reuse=True)
def the_root_validator(cls, values: Dict[str, Any]) -> Dict[str, Any]:
value = values.get("parameters")
if not value:
Expand All @@ -287,7 +286,9 @@ def sources_to_files(cls, value):
try:
src = DesignSource(src)
except FileNotFoundError as e:
raise ValueError(f"Source file: {src} was not found: {e.strerror} {e.filename}")
raise ValueError(
f"Source file: {src} was not found: {e.strerror} {e.filename}"
) from e
sources.append(src)
return sources

Expand Down Expand Up @@ -650,15 +651,15 @@ def __init__(
if generator:
log.info("Running generator: %s", generator)
if isinstance(generator, str):
os.system(generator)
os.system(generator) # nosec S605
elif isinstance(generator, (dict, Generator)):
if isinstance(generator, (dict)):
generator = Generator(**generator)
subprocess.run(
generator.args,
executable=generator.executable,
cwd=generator.cwd,
shell=generator.shell,
shell=generator.shell, # nosec S602
check=generator.check,
env=generator.env,
)
Expand All @@ -677,7 +678,7 @@ def __init__(
except ValidationError as e:
raise DesignValidationError(
validation_errors(e.errors()), data=data, design_root=design_root # type: ignore
)
) from e

for dep in self.dependencies:
dep_design = dep.fetch_design()
Expand Down Expand Up @@ -743,10 +744,14 @@ def from_toml(
cls: Type[DesignType],
design_file: Union[str, os.PathLike],
design_root: Union[None, str, os.PathLike] = None,
overrides: Dict[str, Any] = {},
overrides: Optional[Dict[str, Any]] = None,
allow_extra: bool = False,
remove_extra: List[str] = [],
remove_extra: Optional[List[str]] = None,
) -> DesignType:
if overrides is None:
overrides = {}
if remove_extra is None:
remove_extra = []
if not isinstance(design_file, Path):
design_file = Path(design_file)
assert design_file.suffix == ".toml"
Expand All @@ -763,11 +768,15 @@ def from_file(
cls: Type[DesignType],
design_file: Union[str, os.PathLike],
design_root: Union[None, str, os.PathLike] = None,
overrides: Dict[str, Any] = {},
overrides: Optional[Dict[str, Any]] = None,
allow_extra: bool = False,
remove_extra: List[str] = [],
remove_extra: Optional[List[str]] = None,
) -> DesignType:
"""Load and validate a design description from TOML file"""
if overrides is None:
overrides = {}
if remove_extra is None:
remove_extra = []
if not isinstance(design_file, Path):
design_file = Path(design_file)
if design_file.suffix == ".toml":
Expand Down Expand Up @@ -805,7 +814,7 @@ def from_file(
design_root=e.design_root,
design_name=e.design_name,
file=str(design_file.absolute()),
)
) from e
except Exception as e:
log.error("Error processing design file: %s", design_file.absolute())
raise e
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
[tox]
minversion = 4.0
envlist = py{38,39,310,311}, mypy, flake, black
envlist = py{38,39,310,311}, mypy,
, black
requires =
tox-gh-actions
isolated_build = True

[gh-actions]
python =
3.8: py38, mypy
3.8: py38, mypy, black
3.9: py39, mypy
3.10: py310, mypy
3.11: py311, mypy, flake, black
3.11: py311, mypy, black

[testenv]
passenv =
Expand Down

0 comments on commit f96a06c

Please sign in to comment.