Skip to content

Commit 27eea51

Browse files
authored
Optimised mypy setup & github actions to use pre-commit (#2)
* Added mypy to pyproject.toml & changed pre-commit to use rye mypy * switch to pre-commit to run basic CI on GH actions * added rye run for pre-commit * added more explicit naming in gh actions * made name of flow more explicit * added tests to mypy checks * Changed pre-commit mypy run to run seperately on tests and src to accomodate missing imports in tests
1 parent c24faef commit 27eea51

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed
+5-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Basic CI
1+
name: Basic CI (mirror of local pre-commit CI)
22

33
on: [push, pull_request]
44

@@ -14,17 +14,9 @@ jobs:
1414
with:
1515
python-version: ${{ matrix.python-version }}
1616
architecture: 'x64' # GH does not support arm64, i.e. modern Mac, only x64
17-
- name: Setup rye
17+
- name: Setup rye on runner
1818
uses: eifinger/setup-rye@v2
19-
- name: Install original package
19+
- name: Install rye dependencies
2020
run: rye sync
21-
- name: Run the formatter
22-
run: rye fmt -- --diff
23-
- name: Run the linter
24-
run: rye lint --fix
25-
- name: Run the tests
26-
run: rye test
27-
- name: mypy
28-
uses: jpetrucciani/mypy-check@master
29-
with:
30-
path: 'src'
21+
- name: Run precommit CI hooks
22+
run: rye run pre-commit run --all-files

.pre-commit-config.yaml

+11-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ repos:
3333
require_serial: true
3434
additional_dependencies: []
3535
minimum_pre_commit_version: "2.9.2"
36-
- repo: https://github.com/pre-commit/mirrors-mypy
37-
rev: 'v1.10.1'
36+
- repo: local
3837
hooks:
39-
- id: mypy
40-
files: src
38+
- id: mypy-src
39+
name: mypy-src
40+
language: system
41+
entry: rye run mypy
42+
files: src
43+
- id: mypy-tests
44+
name: mypy-tests
45+
language: system
46+
entry: rye run mypy --ignore-missing-imports
47+
files: tests

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dev-dependencies = [
2020
"pre-commit>=3.7.1",
2121
"ruff>=0.5.0",
2222
"pytest>=8.2.2",
23+
"mypy>=1.10.1",
2324
]
2425

2526
[tool.hatch.metadata]

requirements-dev.lock

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ identify==2.5.36
1919
# via pre-commit
2020
iniconfig==2.0.0
2121
# via pytest
22+
mypy==1.10.1
23+
mypy-extensions==1.0.0
24+
# via mypy
2225
nodeenv==1.9.1
2326
# via pre-commit
2427
packaging==24.1
@@ -32,5 +35,7 @@ pytest==8.2.2
3235
pyyaml==6.0.1
3336
# via pre-commit
3437
ruff==0.5.0
38+
typing-extensions==4.12.2
39+
# via mypy
3540
virtualenv==20.26.3
3641
# via pre-commit

0 commit comments

Comments
 (0)