Release/v0.5.0 #8

Merged
rus07tam merged 20 commits from release/v0.5.0 into main 2025-11-24 16:28:03 +03:00
Showing only changes of commit e2286f1944 - Show all commits

View file

@ -46,7 +46,7 @@ class UniqueType(type):
def unwrap(cls: type[T], value: V | type[T] | T, /) -> V: def unwrap(cls: type[T], value: V | type[T] | T, /) -> V:
if value is cls or isinstance(value, cls): 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 return value # type: ignore
def map( def map(
@ -56,8 +56,8 @@ class UniqueType(type):
or_else: Callable[[type[T]], R], or_else: Callable[[type[T]], R],
) -> R: ) -> R:
if value is cls or isinstance(value, cls): if value is cls or isinstance(value, cls):
return and_then(value) # type: ignore return or_else(cls)
return or_else(cls) return and_then(value) # type: ignore
def and_then( def and_then(
cls: type[T], value: V | type[T] | T, func: Callable[[V], R] cls: type[T], value: V | type[T] | T, func: Callable[[V], R]