Skip to content

Commit 3e7e470

Browse files
authored
ci: Add mypy action (#365)
* Add mypy to tests.yml * Add explanation on how to run mypy in CONTRIBUTING.md
1 parent 849d7e7 commit 3e7e470

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

.github/workflows/tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,21 @@ jobs:
7272
- name: Build Documentation
7373
working-directory: docs
7474
run: uv run make dirhtml
75+
76+
mypy:
77+
name: Run mypy
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
83+
- name: Set up uv
84+
uses: astral-sh/setup-uv@v5
85+
with:
86+
python-version: '3.13'
87+
88+
- name: Install dependencies (default with full options & check)
89+
run: uv pip install '.[full]' --group check
90+
91+
- name: Run mypy
92+
run: uv run mypy src/torchjd

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ mandatory, we only provide installation steps with this tool. You can install it
7272
uv run make clean
7373
```
7474

75+
## Running `mypy`
76+
77+
From the root of the repo, run:
78+
```bash
79+
uv run mypy src/torchjd
80+
```
81+
7582
## Development guidelines
7683

7784
The following guidelines should help preserve a good code quality in TorchJD. Contributions that do

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Changelog = "https://github.com/TorchJD/torchjd/blob/main/CHANGELOG.md"
4242

4343
[dependency-groups]
4444
check = [
45-
"pre-commit>=2.9.2" # isort doesn't work before 2.9.2
45+
"mypy>=1.16.0",
46+
"pre-commit>=2.9.2", # isort doesn't work before 2.9.2
4647
]
4748

4849
doc = [

0 commit comments

Comments
 (0)