Skip to content

Commit

Permalink
made function less tolerant
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Jan 9, 2024
1 parent 9ec9caa commit 9e74286
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cylc/flow/task_job_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9e74286

Please sign in to comment.