From ab1ad1e0a1d700497655fdbdd4fdeee132de40fb Mon Sep 17 00:00:00 2001 From: bleudev Date: Sun, 2 Jun 2024 15:20:58 +0300 Subject: [PATCH] Fix default value of `default` kwarg --- ufpy/udict.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ufpy/udict.py b/ufpy/udict.py index a30e67e..4a6c094 100644 --- a/ufpy/udict.py +++ b/ufpy/udict.py @@ -14,6 +14,8 @@ CDV = TypeVar('CDV') DV = TypeVar('DV') +class _ClassDefault: ... + @cmp_generator @i_generator @r_generator @@ -167,8 +169,8 @@ def get(self, *, value: VT) -> KT | CDV: ... def get(self, *, value: VT, default: DV) -> KT | DV: ... def get( - self, *, key: KT | None = None, index: int | None = None, value: VT | None = None, - default: DV | CDV = 'class default' + self, *, key: KT = None, index: int = None, value: VT = None, + default: DV | CDV = _ClassDefault ) -> KT | VT | CDV | DV: """ Get a value with key or it's index. @@ -205,7 +207,7 @@ def get( if index and index > len(self): raise IndexError('Index is bigger that length of UDict.') - if default == 'class default': + if default == _ClassDefault: default = self.__default if value: