fix: UniqueType.map()
This commit is contained in:
parent
fe2a53860b
commit
e2286f1944
1 changed files with 3 additions and 3 deletions
|
|
@ -46,7 +46,7 @@ class UniqueType(type):
|
|||
|
||||
def unwrap(cls: type[T], value: V | type[T] | T, /) -> V:
|
||||
if value is cls or isinstance(value, cls):
|
||||
raise TypeError(f"Expected {cls}, got {value}")
|
||||
raise TypeError(f"{cls} not unwrapped")
|
||||
return value # type: ignore
|
||||
|
||||
def map(
|
||||
|
|
@ -56,8 +56,8 @@ class UniqueType(type):
|
|||
or_else: Callable[[type[T]], R],
|
||||
) -> R:
|
||||
if value is cls or isinstance(value, cls):
|
||||
return and_then(value) # type: ignore
|
||||
return or_else(cls)
|
||||
return and_then(value) # type: ignore
|
||||
|
||||
def and_then(
|
||||
cls: type[T], value: V | type[T] | T, func: Callable[[V], R]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue