Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(types): Configure and run mypy checks in CI #146

Merged
merged 5 commits into from
Dec 19, 2024
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
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.*",
jhlegarreta marked this conversation as resolved.
Show resolved Hide resolved
"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
Loading