Skip to content

Commit 2884777

Browse files
feat(tidy3d): FXC-3573 add mypy to CI
1 parent 31d3717 commit 2884777

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

.github/workflows/tidy3d-python-client-tests.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,33 @@ jobs:
171171
run: ruff format --check --diff
172172
- name: Run ruff check
173173
run: ruff check tidy3d
174-
174+
175+
mypy:
176+
name: static-type-checks (mypy)
177+
needs: determine-test-scope
178+
if: needs.determine-test-scope.outputs.code_quality_tests == 'true'
179+
runs-on: ubuntu-latest
180+
steps:
181+
- uses: actions/checkout@v4
182+
with:
183+
fetch-depth: 1
184+
submodules: false
185+
persist-credentials: false
186+
187+
- name: set-python-3.10
188+
uses: actions/setup-python@v4
189+
with:
190+
python-version: '3.10'
191+
192+
- name: Install mypy
193+
run: |
194+
python -m pip install --upgrade pip
195+
pip install "mypy==1.13.0"
196+
197+
- name: Run mypy
198+
run: |
199+
mypy --config-file=pyproject.toml
200+
175201
zizmor:
176202
name: Run zizmor 🌈
177203
runs-on: ubuntu-latest
@@ -637,6 +663,7 @@ jobs:
637663
- local-tests
638664
- remote-tests
639665
- lint
666+
- mypy
640667
- verify-schema-change
641668
- lint-commit-messages
642669
- lint-branch-name
@@ -656,6 +683,12 @@ jobs:
656683
run: |
657684
echo "❌ Linting failed."
658685
exit 1
686+
687+
- name: check-mypy-result
688+
if: ${{ needs.determine-test-scope.outputs.code_quality_tests == 'true' && needs.mypy.result != 'success' }}
689+
run: |
690+
echo "❌ Mypy type checking failed."
691+
exit 1
659692
660693
- name: check-schema-change-verification
661694
if: ${{ needs.verify-schema-change.result != 'success' }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ repos:
2929
hooks:
3030
- id: mypy
3131
name: mypy (type signatures)
32-
files: ^tidy3d/web
32+
pass_filenames: false
3333
args:
3434
- --config-file=pyproject.toml

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ python_files = "*.py"
317317

318318
[tool.mypy]
319319
python_version = "3.10"
320+
files = [
321+
"tidy3d/web",
322+
]
320323
ignore_missing_imports = true
321324
follow_imports = "skip"
322325
disallow_untyped_defs = true

0 commit comments

Comments
 (0)