From e94ecbc3c7993f33da096c839ea9225fa47c1691 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Thu, 19 Dec 2024 09:25:43 -0500 Subject: [PATCH 1/5] chore: Configure mypy --- pyproject.toml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b132bccc..df238198 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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]"] @@ -198,3 +206,19 @@ ignore-words-list = "objekt" ignore = [ "W002", ] + +[[tool.mypy.overrides]] +module = [ + "nipype.*", + "seaborn", + "nilearn.*", + "templateflow.*", + "bids.*", + "svgutils", + "svgutils.*", + "pylab", + "mpl_toolkits.*", + "nitransforms.*", + "IPython.*", +] +ignore_missing_imports = true From 1a7c206e363b058f49cbf15f6941aa07ca9b40a3 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Thu, 19 Dec 2024 09:40:59 -0500 Subject: [PATCH 2/5] typ: Resolve mypy complaint --- nireports/interfaces/reporting/registration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nireports/interfaces/reporting/registration.py b/nireports/interfaces/reporting/registration.py index 2d0fe983..871250f7 100644 --- a/nireports/interfaces/reporting/registration.py +++ b/nireports/interfaces/reporting/registration.py @@ -30,6 +30,7 @@ from nipype.interfaces import fsl from nipype.interfaces.base import ( File, + TraitedSpec, isdefined, traits, ) @@ -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): From 23ac12f47cf30157e720a93bd232c31eec9ee4f7 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Thu, 19 Dec 2024 09:44:37 -0500 Subject: [PATCH 3/5] chore(tox): Add typecheck environment --- tox.ini | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tox.ini b/tox.ini index 92f00deb..2cfbeae1 100644 --- a/tox.ini +++ b/tox.ini @@ -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 From 475ee5074b2d80ae40884dc1b5e831f87e7dbd49 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Thu, 19 Dec 2024 09:47:51 -0500 Subject: [PATCH 4/5] chore(ci): Run tox checks in CI --- .github/workflows/build_test_deploy.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 95cdb726..65ba2f4e 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -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 }} From cccd528c57c65b135f332e27e916c0f4d344d08f Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Thu, 19 Dec 2024 10:46:47 -0500 Subject: [PATCH 5/5] Remove redundant svgutils ignore --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index df238198..c67379a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -214,7 +214,6 @@ module = [ "nilearn.*", "templateflow.*", "bids.*", - "svgutils", "svgutils.*", "pylab", "mpl_toolkits.*",