with_constructor_default(default): apply with .pipe to a
schema whose Type is exactly default's (T is invariant, so a
default of another type is a type error).
Functions#
__init__#
__init__(default) -> None| Parameter | Type | Description |
|---|---|---|
default | Effect[T, Issue] |
def __init__(self, default: Effect[T, Issue]) -> None:
self._default = default__call__#
__call__[S, E, RD, RE](schema: Codec[S, E, RD, RE], /) -> WithConstructorDefault[S, E, RD, RE]
__call__[E, RD, RE](schema: Codec[T, E, RD, RE], /) -> WithConstructorDefault[T, E, RD, RE]| Parameter | Type | Description |
|---|---|---|
schema |
@overload
def __call__[S, E, RD, RE](
self: ConstructorDefault[Never], schema: Codec[S, E, RD, RE], /
) -> WithConstructorDefault[S, E, RD, RE]: ...
@overload
def __call__[E, RD, RE](
self, schema: Codec[T, E, RD, RE], /
) -> WithConstructorDefault[T, E, RD, RE]: ...
def __call__(
self, schema: Codec[Any, Any, Any, Any], /
) -> WithConstructorDefault[Any, Any, Any, Any]:
# A default that never succeeds (``fx.fail(issue)``) suits any schema.
node = ast.with_constructor_default(schema.__codec__().ast, self._default)
return WithConstructorDefault(node, self._default)