From 8b2d9d447013674de8c8618f8336658046fcb128 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:45:42 +0000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> --- cylc/flow/xtriggers/xrandom.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/cylc/flow/xtriggers/xrandom.py b/cylc/flow/xtriggers/xrandom.py index c304bc0d20a..641f60003fa 100644 --- a/cylc/flow/xtriggers/xrandom.py +++ b/cylc/flow/xtriggers/xrandom.py @@ -16,13 +16,9 @@ from random import random, randint from time import sleep -from typing import TYPE_CHECKING +from typing import Any, Dict, List, Tuple -from cylc.flow.exceptions import WorkflowConfigError - - -if TYPE_CHECKING: - from typing import Any, Dict, Tuple +from cylc.flow.exceptions import WorkflowConfigError COLORS = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] @@ -103,16 +99,14 @@ def xrandom( return satisfied, results -def validate(f_args, f_kwargs, f_signature): +def validate(f_args: List[str], f_kwargs: Dict[str, Any], f_signature: str): """Validate and manipulate args parsed from the workflow config. - percent: - 0 ≤ x ≤ 100 - secs: An int. - - If f_args used, convert to f_kwargs for clarity. - + The rules for args are: + * percent: Must be 0 ≤ x ≤ 100 + * secs: Must be an integer. """ - # convert to kwarg + # convert to kwarg for clarity f_kwargs["percent"] = f_args[0] del f_args[0]