Skip to content

Commit c699938

Browse files
authored
Merge pull request #13 from tinymovr/improve-templating
Improve templating
2 parents a60ab7f + a923df4 commit c699938

64 files changed

Lines changed: 1697 additions & 277 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
BasedOnStyle: LLVM
3+
IndentWidth: 4
4+
ColumnLimit: 100
5+
AllowShortFunctionsOnASingleLine: Empty
6+
AlignConsecutiveAssignments: false
7+
PointerAlignment: Left
8+
SpaceBeforeParens: Never
9+
BreakBeforeBraces: Linux
10+
IndentCaseLabels: false

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
python -m unittest
3434
- name: Test DBC Files
3535
run: |
36-
cantools dump tests/outputs/test.dbc
36+
cantools dump tests/outputs/test.dbc

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
- name: Build docs
2424
run: |
2525
cd docs
26-
make html SPHINXOPTS="-W --keep-going -n"
26+
make html SPHINXOPTS="-W --keep-going -n"

.pre-commit-README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Pre-commit Hooks for Avlos
2+
3+
This project uses [pre-commit](https://pre-commit.com/) to automatically format and lint code before commits.
4+
5+
## Setup
6+
7+
1. Install pre-commit (if not already installed):
8+
```bash
9+
pip install pre-commit
10+
```
11+
12+
2. Install the git hooks:
13+
```bash
14+
pre-commit install
15+
```
16+
17+
## What Gets Checked
18+
19+
The pre-commit hooks run the following checks:
20+
21+
- **black**: Python code formatting (line length: 127)
22+
- **isort**: Import statement sorting
23+
- **flake8**: Python linting (configured in setup.cfg)
24+
- **trailing-whitespace**: Removes trailing whitespace
25+
- **end-of-file-fixer**: Ensures files end with a newline
26+
- **check-yaml**: Validates YAML syntax
27+
- **check-added-large-files**: Prevents large files from being committed
28+
- **check-merge-conflict**: Detects merge conflict markers
29+
- **mixed-line-ending**: Ensures consistent line endings
30+
- **rstcheck**: Validates RST documentation files
31+
32+
## Manual Execution
33+
34+
To run all hooks on all files (useful after initial setup or major changes):
35+
```bash
36+
pre-commit run --all-files
37+
```
38+
39+
To run hooks on specific files:
40+
```bash
41+
pre-commit run --files path/to/file1.py path/to/file2.py
42+
```
43+
44+
To skip hooks for a single commit (not recommended):
45+
```bash
46+
git commit --no-verify
47+
```
48+
49+
## Configuration
50+
51+
- Pre-commit hooks are configured in `.pre-commit-config.yaml`
52+
- Flake8 and isort settings are in `setup.cfg`
53+
- clang-format style is configured in `.clang-format`
54+
55+
## CI Integration
56+
57+
The same linting checks run in GitHub Actions CI, so passing pre-commit locally ensures CI will pass.

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Pre-commit hooks for Avlos
2+
# See https://pre-commit.com for more information
3+
repos:
4+
# Python code formatting with black
5+
- repo: https://github.com/psf/black
6+
rev: 24.1.1
7+
hooks:
8+
- id: black
9+
language_version: python3
10+
args: ['--line-length=127']
11+
12+
# Python import sorting
13+
- repo: https://github.com/PyCQA/isort
14+
rev: 5.13.2
15+
hooks:
16+
- id: isort
17+
args: ['--profile', 'black', '--line-length', '127']
18+
19+
# Python linting with flake8
20+
- repo: https://github.com/PyCQA/flake8
21+
rev: 7.0.0
22+
hooks:
23+
- id: flake8
24+
args: ['--max-line-length=127', '--max-complexity=10', '--extend-ignore=E203,W503']
25+
26+
# Trailing whitespace and file endings
27+
- repo: https://github.com/pre-commit/pre-commit-hooks
28+
rev: v4.5.0
29+
hooks:
30+
- id: trailing-whitespace
31+
- id: end-of-file-fixer
32+
- id: check-yaml
33+
- id: check-added-large-files
34+
- id: check-merge-conflict
35+
- id: mixed-line-ending
36+
37+
# RST file checking
38+
- repo: https://github.com/rstcheck/rstcheck
39+
rev: v6.2.0
40+
hooks:
41+
- id: rstcheck
42+
args: ['--report-level=warning']
43+
additional_dependencies: ['sphinx']

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"justMyCode": false
1212
}
1313
]
14-
}
14+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"python.testing.pytestEnabled": false,
1010
"python.testing.unittestEnabled": true,
1111
"python.formatting.provider": "black"
12-
}
12+
}

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

77
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8-

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Stop writing serialization code twice. Stop debugging protocol mismatches.
1313
- 🔒 **Type-safe across the boundary** → Catch errors at build time, not runtime
1414
- 🎯 **Battle-tested** → Production-proven in [Tinymovr](https://tinymovr.com) motor controllers
1515

16-
[Αυλός (Avlόs)](https://en.wikipedia.org/wiki/Aulos) - _flute_, also _channel_.
16+
[Αυλός (Avlόs)](https://en.wikipedia.org/wiki/Aulos) - _flute_, also _channel_.
1717

1818
<p align="center">
1919
<img src="docs/diagram.png" width="800"/>
@@ -74,7 +74,7 @@ Given the above, Avlos can generate the following:
7474

7575
- [CAN DBC file](https://www.csselectronics.com/pages/can-dbc-file-database-intro) (CAN database), for every endpoint, for use with CAN-based comm channels.
7676

77-
In addition, Avlos will compute a checksum for the spec and add it as a variable to the implementation so that it can be retrieved by the client for comparing client and device specs.
77+
In addition, Avlos will compute a checksum for the spec and add it as a variable to the implementation so that it can be retrieved by the client for comparing client and device specs.
7878

7979
The output location, as well as many other attributes of the files are flexible and easily configurable.
8080

@@ -127,7 +127,7 @@ In addition, the object resulting from the deserialization of the spec can be us
127127
import yaml
128128
from avlos import deserialize
129129
from myProject import myChannel # update this
130-
130+
131131
device_description = ...
132132
obj = deserialize(yaml.safe_load(device_description))
133133
obj.set_channel(myChannel())
@@ -164,4 +164,3 @@ Between releases, development versions are automatically generated (e.g., `0.8.7
164164
## 🔑 License
165165

166166
MIT
167-

avlos/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
# Package is not installed, version will be determined from git
77
try:
88
from setuptools_scm import get_version
9-
__version__ = get_version(root='..', relative_to=__file__)
9+
10+
__version__ = get_version(root="..", relative_to=__file__)
1011
except (ImportError, LookupError):
1112
__version__ = "unknown"
1213

13-
__all__ = ["get_registry", "__version__"]
14+
__all__ = ["get_registry", "__version__"]

0 commit comments

Comments
 (0)