Skip to content

Commit

Permalink
Fix default value of default kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
bleudev committed Jun 2, 2024
1 parent ce7dcb3 commit ab1ad1e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ufpy/udict.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
CDV = TypeVar('CDV')
DV = TypeVar('DV')

class _ClassDefault: ...

@cmp_generator
@i_generator
@r_generator
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ab1ad1e

Please sign in to comment.