From 41b22d7b8b8ff1a1e066515b17d5da4baebd6c56 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 28 Feb 2024 09:59:07 -0500 Subject: [PATCH] Provide types for custom_seqinfo but disable type checking in the test -- I think mypy has deficiency since we do use kwargs and thus should be ok --- heudiconv/heuristics/convertall_custom.py | 9 ++++++++- heudiconv/tests/test_dicoms.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/heudiconv/heuristics/convertall_custom.py b/heudiconv/heuristics/convertall_custom.py index 780ecc76..26f0ca05 100644 --- a/heudiconv/heuristics/convertall_custom.py +++ b/heudiconv/heuristics/convertall_custom.py @@ -4,11 +4,18 @@ behavior of an already existing heuristic without complete rewrite. Such approach could be useful for heuristic like reproin to overload mapping etc. """ +from __future__ import annotations + +from typing import Any + +import nibabel.nicom.dicomwrappers as dw from .convertall import * # noqa: F403 -def custom_seqinfo(series_files, wrapper, **kw): # noqa: U100 +def custom_seqinfo( + series_files: list[str], wrapper: dw.Wrapper, **kw: Any # noqa: U100 +) -> tuple[str | None, str]: """Demo for extracting custom header fields into custom_seqinfo field Operates on already loaded DICOM data. diff --git a/heudiconv/tests/test_dicoms.py b/heudiconv/tests/test_dicoms.py index 12ac29c6..4cb28290 100644 --- a/heudiconv/tests/test_dicoms.py +++ b/heudiconv/tests/test_dicoms.py @@ -108,7 +108,7 @@ def test_custom_seqinfo() -> None: seqinfos = group_dicoms_into_seqinfos( dcmfiles, "studyUID", flatten=True, custom_seqinfo=custom_seqinfo - ) + ) # type: ignore seqinfo = list(seqinfos.keys())[0]