GitHub

FromBrand

API reference for FromBrand.

class FromBrand[A, B]

from_brand(brand): apply with .pipe.

Functions

__init__

__init__(brand, identifier) -> None
ParameterTypeDescription
brandBrand[A, B]
identifierstr | None
def __init__(self, brand: Brand[A, B], identifier: str | None) -> None:
    self._brand = brand
    self._identifier = identifier

__call__

__call__[I, RD, RE](schema) -> BrandSchema[B, I, RD, RE]
ParameterTypeDescription
schemaCodec[A, I, RD, RE]

Returns BrandSchema[B, I, RD, RE]

def __call__[I, RD, RE](self, schema: Codec[A, I, RD, RE], /) -> BrandSchema[B, I, RD, RE]:
    bottom = schema.__codec__()
    checks = self._brand.checks
    checked = bottom.check(*checks) if checks else bottom
    # A brand is a ``NewType``: the checked value is the branded one.
    return BrandSchema(checked.ast, checked, self._identifier)