Skip to content

Commit 477c946

Browse files
committed
feat: rework entry point and add some input format data models
- Switch to typer for cli - Use pydantic for data models - Add data model for build specification (ex. csrconfig) - Update pre-commit hook with more checks
1 parent c1e707c commit 477c946

File tree

13 files changed

+656
-332
lines changed

13 files changed

+656
-332
lines changed

.pre-commit-config.yaml

Lines changed: 82 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,84 @@
11
fail_fast: true
22
repos:
3-
- repo: local
4-
hooks:
5-
- id: ruff_format
6-
name: Python format check
7-
entry: poetry run ruff format --check --diff
8-
language: system
9-
types: [file, python]
10-
stages: [pre-commit]
11-
- id: ruff_lint
12-
name: Python lint check
13-
entry: poetry run ruff check
14-
language: system
15-
types: [file, python]
16-
stages: [pre-commit]
17-
- id: pyright
18-
name: Python type check
19-
entry: poetry run pyright
20-
language: system
21-
types: [file, python]
22-
stages: [pre-commit]
23-
- id: check-yaml
24-
name: YAML check
25-
entry: poetry run check-yaml
26-
language: python
27-
types: [yaml]
28-
stages: [pre-commit]
29-
- id: check-toml
30-
name: TOML check
31-
entry: poetry run check-toml
32-
language: python
33-
types: [toml]
34-
stages: [pre-commit]
35-
- id: check-json
36-
name: JSON check
37-
entry: poetry run check-json
38-
language: python
39-
types: [json]
40-
stages: [pre-commit]
41-
- id: commitizen
42-
name: Commit style check
43-
stages: [commit-msg]
44-
entry: cz check --commit-msg-file .git/COMMIT_EDITMSG
45-
pass_filenames: false
46-
language: system
3+
- repo: local
4+
hooks:
5+
- id: ruff-format
6+
name: Python format
7+
description: Run Python code formatting with ruff
8+
entry: poetry run ruff format
9+
language: system
10+
types: [file, python]
11+
stages: [pre-commit]
12+
13+
- id: ruff-lint
14+
name: Python lint check
15+
description: Run Python code linting with ruff
16+
entry: poetry run ruff check --fix
17+
language: system
18+
types: [file, python]
19+
stages: [pre-commit]
20+
21+
- id: pyright
22+
name: Python type check
23+
description: Run Python code type checking with pyright
24+
entry: poetry run pyright
25+
language: system
26+
types: [file, python]
27+
stages: [pre-commit]
28+
29+
- id: check-yaml
30+
name: YAML check
31+
description: Validate all changed YAML files
32+
entry: poetry run check-yaml
33+
language: python
34+
types: [yaml]
35+
stages: [pre-commit]
36+
37+
- id: check-toml
38+
name: TOML check
39+
description: Validate all changed TOML files
40+
entry: poetry run check-toml
41+
language: python
42+
types: [toml]
43+
stages: [pre-commit]
44+
45+
- id: check-json
46+
name: JSON check
47+
description: Validate all changed JSON files
48+
entry: poetry run check-json
49+
language: python
50+
types: [json]
51+
stages: [pre-commit]
52+
53+
- id: commitizen
54+
name: Commit style check
55+
description: Run commitizen to validate commit message
56+
stages: [commit-msg]
57+
entry: cz check --commit-msg-file .git/COMMIT_EDITMSG
58+
pass_filenames: false
59+
language: system
60+
61+
- id: poetry-check
62+
name: Poetry configuration check
63+
description: Run poetry check to validate config
64+
entry: poetry check
65+
language: python
66+
pass_filenames: false
67+
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
68+
69+
- id: poetry-lock
70+
name: Poetry lock update
71+
description: Run poetry lock to update lock file
72+
entry: poetry lock
73+
language: python
74+
pass_filenames: false
75+
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
76+
77+
- id: poetry-install
78+
name: poetry-install
79+
description: Run poetry install to install dependencies from the lock file
80+
entry: poetry install
81+
language: python
82+
pass_filenames: false
83+
stages: [post-checkout, post-merge]
84+
always_run: true

corsair/__init__.py

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,40 @@
1010
__title__ = "corsair"
1111
__description__ = "Control and status register (CSR) map generator for HDL projects."
1212

13-
from . import config, generators
14-
from .bitfield import BitField
15-
from .enum import EnumValue
16-
from .reg import Register
17-
from .regmap import RegisterMap
13+
14+
from .input import (
15+
AnyTarget,
16+
BaseTarget,
17+
BuildSpecification,
18+
CustomTarget,
19+
ForceNameCase,
20+
GlobalConfig,
21+
MapCHeaderTarget,
22+
MapMarkdownTarget,
23+
MapSvPackageTarget,
24+
MapVerilogHeaderTarget,
25+
MapVerilogTarget,
26+
MapVhdlTarget,
27+
RegisterReset,
28+
)
1829
from .version import __version__
1930

20-
__all__ = [
31+
__all__ = (
2132
"__version__",
22-
"RegisterMap",
23-
"Register",
24-
"EnumValue",
25-
"BitField",
26-
"config",
27-
"generators",
28-
]
33+
# specification
34+
"BuildSpecification",
35+
# targets
36+
"AnyTarget",
37+
"BaseTarget",
38+
"CustomTarget",
39+
"MapVerilogTarget",
40+
"MapVhdlTarget",
41+
"MapSvPackageTarget",
42+
"MapVerilogHeaderTarget",
43+
"MapMarkdownTarget",
44+
"MapCHeaderTarget",
45+
# configuration
46+
"ForceNameCase",
47+
"RegisterReset",
48+
"GlobalConfig",
49+
)

corsair/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from __future__ import annotations
66

7-
from . import app
7+
from . import cli
88

99
if __name__ == "__main__":
10-
app.main()
10+
cli.app()

corsair/app.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)