From da5f5148b5fbf2e5e4aa84ab179750503a798525 Mon Sep 17 00:00:00 2001 From: Laurent Guerard Date: Mon, 19 Jan 2026 13:25:28 +0100 Subject: [PATCH 1/2] feat(processing): validate inputs for get_processing_settings * Added input validation for 'dimension' and 'selection' parameters. * Raises ValueError for invalid inputs with descriptive messages. --- src/imcflibs/imagej/bdv.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index 5cc7b412..e1224f28 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -21,7 +21,6 @@ from .. import pathtools from ..log import LOG as log - # internal template strings used in string formatting (note: the `"""@private"""` # pseudo-decorator is there to instruct [pdoc] to omit those variables when generating # API documentation): @@ -733,6 +732,21 @@ def get_processing_settings(dimension, selection, value, range_end): processing_option, dimension_select """ + # Validate inputs according to the function docstring + valid_dimensions = ("angle", "channel", "illumination", "tile", "timepoint") + if dimension not in valid_dimensions: + raise ValueError( + "Invalid dimension '%s', expected one of: %s" + % (dimension, ", ".join(valid_dimensions)) + ) + + valid_selections = ("single", "multiple", "range") + if selection not in valid_selections: + raise ValueError( + "Invalid selection '%s', expected one of: %s" + % (selection, ", ".join(valid_selections)) + ) + if selection == "single": processing_option = SINGLE % dimension dimension_select = "processing_" + dimension + "=[" + dimension + " %s]" % value From 925c81df2efc35ae9ae38c2a06ade316c98f7d4f Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Mon, 19 Jan 2026 14:00:16 +0100 Subject: [PATCH 2/2] Initialize variables Mostly done to help the static code analysis (Pylance) to understand this is not a "reportPossiblyUnboundVariable" case. --- src/imcflibs/imagej/bdv.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/imcflibs/imagej/bdv.py b/src/imcflibs/imagej/bdv.py index e1224f28..15230aed 100644 --- a/src/imcflibs/imagej/bdv.py +++ b/src/imcflibs/imagej/bdv.py @@ -731,6 +731,7 @@ def get_processing_settings(dimension, selection, value, range_end): tuple of str processing_option, dimension_select """ + processing_option = dimension_select = "" # Validate inputs according to the function docstring valid_dimensions = ("angle", "channel", "illumination", "tile", "timepoint")