From a2d1a5d2e661c9a2df03f66a012c7b336c77b93f Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 17 Jun 2024 13:58:36 +0200 Subject: [PATCH 1/2] really allow in-range validator for txt just enabling the linter https://github.com/galaxyproject/galaxy/pull/18403 was not sufficient --- lib/galaxy/tools/parameters/validation.py | 2 +- test/unit/app/tools/test_parameter_validation.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/parameters/validation.py b/lib/galaxy/tools/parameters/validation.py index cf02d86c56b5..6334fd95f8b8 100644 --- a/lib/galaxy/tools/parameters/validation.py +++ b/lib/galaxy/tools/parameters/validation.py @@ -165,7 +165,7 @@ def __init__(self, message, range_min, range_max, exclude_min=False, exclude_max op1 = "<" if self.exclude_max: op2 = "<" - expression = f"float('{self.min}') {op1} value {op2} float('{self.max}')" + expression = f"float('{self.min}') {op1} float(value) {op2} float('{self.max}')" if message is None: message = f"Value ('%s') must {'not ' if negate == 'true' else ''}fulfill {expression}" super().__init__(message, expression, negate) diff --git a/test/unit/app/tools/test_parameter_validation.py b/test/unit/app/tools/test_parameter_validation.py index bddb0e325309..8442f435a083 100644 --- a/test/unit/app/tools/test_parameter_validation.py +++ b/test/unit/app/tools/test_parameter_validation.py @@ -217,11 +217,11 @@ def test_InRangeValidator(self): ) p.validate(10) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < value <= float\('20'\)" + ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" ): p.validate(15) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < value <= float\('20'\)" + ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" ): p.validate(20) p.validate(21) From 5297fa3137ed9eb3585500fd2013323650047f48 Mon Sep 17 00:00:00 2001 From: M Bernt Date: Tue, 18 Jun 2024 09:59:33 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- test/unit/app/tools/test_parameter_validation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/app/tools/test_parameter_validation.py b/test/unit/app/tools/test_parameter_validation.py index 8442f435a083..23df864ae3e4 100644 --- a/test/unit/app/tools/test_parameter_validation.py +++ b/test/unit/app/tools/test_parameter_validation.py @@ -217,11 +217,11 @@ def test_InRangeValidator(self): ) p.validate(10) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" + ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < float\(value\) <= float\('20'\)" ): p.validate(15) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" + ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < float\(value\) <= float\('20'\)" ): p.validate(20) p.validate(21)