Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@ on:
pull_request:

jobs:
ruff:
uses: CAVISE/pipelines/.github/workflows/python-ruff.yml@main
with:
run-lint: true
run-format-check: true

type-check:
uses: CAVISE/pipelines/.github/workflows/python-mypy.yml@main
with:
python-version: "3.12"
target-path: scripts
follow-imports-silent: true
cache-dependency-path: |
requirements.txt
pyproject.toml
requirements-file: requirements.txt

unused-code-check:
uses: CAVISE/pipelines/.github/workflows/python-deadcode.yml@main
with:
python-version: "3.12"
target-path: scripts

pre-commit:
uses: CAVISE/pipelines/.github/workflows/python-pre-commit.yml@main
with:
python-version: "3.12"
skip-hooks: ruff-check,ruff-format,mypy,deadcode
all-files: true
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default_language_version:
python: python3.12

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.0
Expand Down Expand Up @@ -34,6 +37,23 @@ repos:

- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy scripts
language: python
additional_dependencies:
- mypy
- pyyaml==6.0.3
pass_filenames: false
require_serial: true
- id: deadcode
name: deadcode
entry: deadcode scripts
language: python
additional_dependencies:
- deadcode
pass_filenames: false
require_serial: true
- id: validate-model-metadata
name: validate model metadata and artifacts
entry: python scripts/validate_metadata.py
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ The same validation runs automatically as part of pre-commit:
pre-commit run --all-files
```

## Python quality checks

Python 3.12 is used for the repository tooling. Install the development tools
through pre-commit, or run each check directly:

```bash
ruff check scripts
ruff format --check scripts
mypy scripts
deadcode scripts
```

Ruff also enforces NumPy-style docstrings for the Python scripts. Pull requests
run these four checks independently in CI, while `pre-commit run --all-files`
runs the same checks locally.

To add a bundle, first place its files into a new directory directly under
`coperception/` or `advcp/`. Then pass that directory and its source information
to the generator:
Expand Down
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tool.ruff]
line-length = 150
target-version = "py312"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "D"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.format]
docstring-code-format = true

[tool.mypy]
python_version = "3.12"
files = ["scripts"]
disallow_untyped_defs = true
check_untyped_defs = true
warn_unused_ignores = true
ignore_missing_imports = true
pretty = true

[tool.deadcode]
exclude = [".git", ".mypy_cache", ".ruff_cache"]
Loading
Loading