Skip to content

Commit

Permalink
Merge pull request #146 from effigies/mypy
Browse files Browse the repository at this point in the history
chore(types): Configure and run mypy checks in CI
  • Loading branch information
jhlegarreta authored Dec 19, 2024
2 parents d923a42 + cccd528 commit f0690a1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,28 @@ jobs:
# Remove once OIDC is set up
with:
password: ${{ secrets.PYPI_API_TOKEN }}

checks:
runs-on: 'ubuntu-latest'
continue-on-error: true
strategy:
matrix:
check: ['style', 'spellcheck', 'typecheck']

steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
# Can remove this once there is a traits release that supports 3.13
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install tox
run: uv tool install tox --with=tox-uv
- name: Show tox config
run: tox c
- name: Show tox config (this call)
run: tox c -e ${{ matrix.check }}
- name: Run check
run: tox -e ${{ matrix.check }}
4 changes: 2 additions & 2 deletions nireports/interfaces/reporting/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from nipype.interfaces import fsl
from nipype.interfaces.base import (
File,
TraitedSpec,
isdefined,
traits,
)
Expand Down Expand Up @@ -131,10 +132,9 @@ class ApplyXFMRPT(FLIRTRPT, fsl.ApplyXFM):
output_spec = _FLIRTOutputSpecRPT


_BBRegisterInputSpec: type[TraitedSpec] = fs.preprocess.BBRegisterInputSpec6
if LooseVersion("0.0.0") < fs.Info.looseversion() < LooseVersion("6.0.0"):
_BBRegisterInputSpec = fs.preprocess.BBRegisterInputSpec
else:
_BBRegisterInputSpec = fs.preprocess.BBRegisterInputSpec6


class _BBRegisterInputSpecRPT(nrb._SVGReportCapableInputSpec, _BBRegisterInputSpec):
Expand Down
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ test = [
"pytest-xdist >= 2.5",
"sphinx >= 6",
]
types = [
"pandas-stubs",
"scipy-stubs",
"types-jinja2",
"types-pyyaml",
"pytest",
"microsoft-python-type-stubs @ git+https://github.com/microsoft/python-type-stubs.git",
]

# Aliases
docs = ["nireports[doc]"]
Expand Down Expand Up @@ -198,3 +206,18 @@ ignore-words-list = "objekt"
ignore = [
"W002",
]

[[tool.mypy.overrides]]
module = [
"nipype.*",
"seaborn",
"nilearn.*",
"templateflow.*",
"bids.*",
"svgutils.*",
"pylab",
"mpl_toolkits.*",
"nitransforms.*",
"IPython.*",
]
ignore_missing_imports = true
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ commands =
ruff format
ruff check --select ISC001

[testenv:typecheck]
description = "Run mypy type checking"
labels = check
deps =
mypy
extras = types
commands =
mypy nireports

[testenv:spellcheck]
description = Check spelling
labels = check
Expand Down

0 comments on commit f0690a1

Please sign in to comment.