From aba40b80e85c430013b8a8e2f9a0c030f8bfe706 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Wed, 17 Apr 2024 09:58:54 +0200 Subject: [PATCH] fix: bug in *toml* loader crashing with mixed arrays in config This happened, e.g., when trying to run MRIQC on datasets with both single-echo and multi-echo runs or with filters where some array had mixed types (e.g., `part: [null, 'mag']`). Resolves: #1264. --- mriqc/config.py | 5 ++++- pyproject.toml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mriqc/config.py b/mriqc/config.py index 32c7170e2..4f1fe6167 100644 --- a/mriqc/config.py +++ b/mriqc/config.py @@ -665,7 +665,10 @@ def from_dict(sections): def load(filename): """Load settings from file.""" - from toml import loads + try: + from tomllib import loads + except ModuleNotFoundError: # Python < 3.11 + from tomli import loads filename = Path(filename) sections = loads(filename.read_text()) diff --git a/pyproject.toml b/pyproject.toml index f088e0942..a905fa01c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dependencies = [ "statsmodels", "templateflow", "toml", + "tomli >= 1.1.0; python_version < '3.11'", "torch >= 1.10.2", ] description = "Automated Quality Control and visual reports for Quality Assessment of structural (T1w, T2w) and functional MRI of the brain."