From 9e7428683d71c1fdee7c2281ec30227fdf2c9e78 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:35:37 +0000 Subject: [PATCH] made function less tolerant --- cylc/flow/task_job_mgr.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cylc/flow/task_job_mgr.py b/cylc/flow/task_job_mgr.py index e67b1d1c1c0..e41e05dfd30 100644 --- a/cylc/flow/task_job_mgr.py +++ b/cylc/flow/task_job_mgr.py @@ -1288,24 +1288,21 @@ def get_execution_time_limit( ) -> Union[None, float]: """Get execution time limit from config and process it. - We are making no assumptions about what can be passed in, - but passing silently and returning None if the value is - not a type convertable to a float: + If the etl from the config is a Falsy then return None. + Otherwise try and parse value as float. Examples: + >>> from pytest import raises >>> this = TaskJobManager.get_execution_time_limit + >>> this(None) >>> this("54") 54.0 >>> this({}) - - N.b. - This function does not save you from a value error: - >>> from pytest import raises >>> with raises(ValueError): - ... this("🇳🇿") + ... this('🇳🇿') """ - with suppress(TypeError): + if config_execution_time_limit: return float(config_execution_time_limit) return None