aboutsummaryrefslogtreecommitdiff
path: root/tools/cru-py/cru/list.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/cru-py/cru/list.py')
-rw-r--r--tools/cru-py/cru/list.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/cru-py/cru/list.py b/tools/cru-py/cru/list.py
index e329ae2..9d210b7 100644
--- a/tools/cru-py/cru/list.py
+++ b/tools/cru-py/cru/list.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from collections.abc import Callable, Iterator
-from typing import Any, Generic, Iterable, TypeAlias, TypeVar
+from typing import Any, Generic, Iterable, TypeAlias, TypeVar, overload
from ._error import CruInternalError
from ._iter import CruIterator
@@ -78,6 +78,14 @@ class CruUniqueKeyList(Generic[_T, _K]):
if len(keys) != len(set(keys)):
raise CruInternalError("Duplicate keys!")
+ @overload
+ def get_or(
+ self, key: _K, fallback: CruNotFound = CruNotFound.VALUE
+ ) -> _T | CruNotFound: ...
+
+ @overload
+ def get_or(self, key: _K, fallback: _O) -> _T | _O: ...
+
def get_or(
self, key: _K, fallback: _O | CruNotFound = CruNotFound.VALUE
) -> _T | _O | CruNotFound: