summaryrefslogtreecommitdiff
path: root/kvmd/validators/__init__.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-08 12:32:16 +0300
committerDevaev Maxim <[email protected]>2020-09-08 12:32:16 +0300
commitd528a3002e53bb7a5b5e6d9b5385252372738fbf (patch)
tree9746fb7061c82ec101f01151a440e1659799df6e /kvmd/validators/__init__.py
parentd932a937caede7f54c0f4384ce08f7ecc291af23 (diff)
refactoring
Diffstat (limited to 'kvmd/validators/__init__.py')
-rw-r--r--kvmd/validators/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/kvmd/validators/__init__.py b/kvmd/validators/__init__.py
index d6caa835..d91b37bf 100644
--- a/kvmd/validators/__init__.py
+++ b/kvmd/validators/__init__.py
@@ -23,6 +23,7 @@
import re
from typing import List
+from typing import Set
from typing import Mapping
from typing import Sequence
from typing import Callable
@@ -62,13 +63,19 @@ def check_not_none_string(arg: Any, name: str, strip: bool=True) -> str:
return arg
-def check_in_list(arg: Any, name: str, variants: Union[Sequence, Mapping]) -> Any:
+def check_in_list(arg: Any, name: str, variants: Union[Sequence, Mapping, Set]) -> Any:
if arg not in variants:
raise_error(arg, name)
return arg
-def check_string_in_list(arg: Any, name: str, variants: Union[Sequence[str], Mapping[str, Any]], lower: bool=True) -> str:
+def check_string_in_list(
+ arg: Any,
+ name: str,
+ variants: Union[Sequence[str], Mapping[str, Any], Set[str]],
+ lower: bool=True,
+) -> str:
+
arg = check_not_none_string(arg, name)
if lower:
arg = arg.lower()