]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: datamodel: types: alias for union of list and single element
authorAleš Mrázek <ales.mrazek@nic.cz>
Thu, 16 Feb 2023 09:22:12 +0000 (10:22 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 9 Jun 2023 11:54:07 +0000 (11:54 +0000)
manager/knot_resolver_manager/datamodel/types/types.py

index 086235351d12765d48da4435be3d105231697012..008b5e92a06fc84e1a05b67c9b13dd920c5e716f 100644 (file)
@@ -1,10 +1,14 @@
 import ipaddress
 import re
-from typing import Any, Dict, Optional, Type, Union
+from typing import Any, Dict, List, Optional, Type, TypeVar, Union
 
 from knot_resolver_manager.datamodel.types.base_types import IntRangeBase, PatternBase, StrBase, UnitBase
 from knot_resolver_manager.utils.modeling import BaseValueType
 
+_ElementType = TypeVar("_ElementType")
+
+ListOrSingle = Union[List[_ElementType], _ElementType]
+
 
 class IntNonNegative(IntRangeBase):
     _min: int = 0