Core
Generated from the type stubs and docstrings. Do not edit by hand.
AvroRegistrySerde
Section titled “AvroRegistrySerde”Avro serde with Confluent Schema Registry integration.
Wire format: [0x00 magic][schema_id: 4 bytes BE][avro payload]
Schema registration is lazy (happens on first serialize() call). Reader schemas are fetched from the registry on first deserialize() per schema ID and cached for the serde’s lifetime.
TLS/mTLS: pass ca_path to trust a custom CA, or cert_path + key_path for mutual TLS (both required together; applies only when registry_url is https://). Encrypted private keys are not supported - key_path must point to an unencrypted PEM.
reader_schema: the schema every record is resolved INTO on deserialize (standard Avro schema resolution); without one a record decodes to its own writer schema’s shape, fetched by the id in its framing.
logical_types and strict: as for AvroSerde. See the docsite for a usage example including mTLS setup.
timeout_ms: the bound on one registry HTTP request, from connect to the last byte of the response (default 5000, 1 to 300000; ValueError otherwise). A call that makes one request fails within about this long when the registry is down or silent. A failed lookup, including a 404 for an unknown schema id, is remembered for 5 seconds, so records that need the same schema do not each ask the registry again; a registry follower that is behind on a brand-new id keeps that id failing for up to 5 seconds. A batch asks for each schema id at most once and, once the registry is unreachable or answers 5xx, makes no further requests; records that needed one fail with that error.
AvroRegistrySerde(registry_url: str, subject: str, schema: str, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None, reader_schema: Optional[str] = None, *, logical_types: Literal['python', 'raw'] = 'python', strict: bool = False, timeout_ms: int = 5000)for_topic
Section titled “for_topic”for_topic(registry_url: str, topic: str, schema: str, is_key: bool = False, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None, reader_schema: Optional[str] = None, *, logical_types: Literal['python', 'raw'] = 'python', strict: bool = False, timeout_ms: int = 5000) -> AvroRegistrySerderegister
Section titled “register”register(self) -> Ok[int] | Err[SerdeError]subject
Section titled “subject”subject(self) -> strserialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: Iterable[Any]) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: Iterable[Any]) -> BytesListdeserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_objects
Section titled “deserialize_many_objects”deserialize_many_objects(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_from_packed
Section titled “deserialize_many_from_packed”deserialize_many_from_packed(self, packed: bytes, count: int) -> IListcheck_compatibility
Section titled “check_compatibility”check_compatibility(self, schema: str, version: Optional[str] = None) -> Ok[bool] | Err[SerdeError]list_versions
Section titled “list_versions”list_versions(self) -> Ok[list[int]] | Err[SerdeError]get_schema_by_version
Section titled “get_schema_by_version”get_schema_by_version(self, version: int) -> Ok[str] | Err[SerdeError]delete_version
Section titled “delete_version”delete_version(self, version: int) -> Ok[bool] | Err[SerdeError]AvroSerde
Section titled “AvroSerde”Avro serde over a single schema, returning Either instead of raising.
Logical types convert as fastavro (and so confluent-kafka) converts them: timestamp-* to an aware UTC datetime, local-timestamp-* to a naive datetime, date to a date, time-* to a time, decimal to a Decimal, uuid to a UUID. Writing takes those types or the plain value on the wire.
logical_types: “raw” decodes logical types to their value on the wire instead - int, bytes or str. Encoding takes either form whichever is chosen.
strict: refuse what fastavro converts by guessing - a naive datetime for a timestamp-* (fastavro takes it as the host’s local time), a datetime for a date (fastavro drops its time), and a decoded decimal with more digits than its precision (fastavro rounds it).
AvroSerde(schema_json: str, *, logical_types: Literal['python', 'raw'] = 'python', strict: bool = False)serialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: Iterable[Any]) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: Iterable[Any]) -> BytesListdeserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: Iterable[bytes] | BytesList) -> IListBytesList
Section titled “BytesList”BytesList(items: Any = ...)empty(cls) -> BytesListfrom_packed
Section titled “from_packed”from_packed(buf: bytes, count: int) -> BytesListget(self, index: int) -> Some[bytes] | _Nothingappend
Section titled “append”append(self, item: bytes) -> BytesListto_list
Section titled “to_list”to_list(self) -> list[bytes]to_packed
Section titled “to_packed”to_packed(self) -> bytesto_ilist
Section titled “to_ilist”to_ilist(self) -> IList[bytes]length
Section titled “length”length(self) -> intis_empty
Section titled “is_empty”is_empty(self) -> boolindex(self, value: Any, start: int = 0, stop: int = ...) -> intcount(self, value: Any) -> intDeserializationError
Section titled “DeserializationError”Duration
Section titled “Duration”A typed time-span value backed by an i64 nanosecond count.
Mirrors Scala’s FiniteDuration - a precise, immutable quantity of time
with unit-converting constructors and full arithmetic support.
nanos(n: int) -> Durationmicros
Section titled “micros”micros(n: int) -> Durationmillis
Section titled “millis”millis(n: int) -> Durationseconds
Section titled “seconds”seconds(n: float) -> Durationminutes
Section titled “minutes”minutes(n: float) -> Durationhours(n: float) -> Durationdays(n: float) -> Durationfrom_timedelta
Section titled “from_timedelta”from_timedelta(td: Any) -> Durationto_nanos
Section titled “to_nanos”to_nanos(self) -> intto_millis
Section titled “to_millis”to_millis(self) -> intto_seconds
Section titled “to_seconds”to_seconds(self) -> floatto_timedelta
Section titled “to_timedelta”to_timedelta(self) -> AnyEither
Section titled “Either”A value (Ok) or an error (Err). Subclassed by Ok and Err, the same
way Scala’s Either is by Right/Left, so Either[A, E] is a real generic
and isinstance(x, Either) holds for both. Abstract: build values through the
factories below (or Ok/Err directly), not Either(...).
ok(value: T) -> Ok[T]err(error: E) -> Err[E]try_of
Section titled “try_of”try_of(f: Callable[[], T]) -> Either[T, Exception]cond(condition: bool, ok: T, err: E) -> Either[T, E]sequence
Section titled “sequence”sequence(values: Iterable[Either[T, E]]) -> Either[list[T], E]traverse
Section titled “traverse”traverse(values: Iterable[_A], fn: Callable[[_A], Either[U, F]]) -> Either[list[U], F]map(self, f: Callable[..., Any]) -> Either[Any, E]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Either[Any, E]map_err
Section titled “map_err”map_err(self, f: Callable[..., Any]) -> Either[T, Any]ensure
Section titled “ensure”ensure(self, predicate: Callable[[T], bool], error: Callable[[T], F]) -> Either[T, E | F]ensure(self, predicate: Callable[[T], bool], error: F) -> Either[T, E | F]tap(self, fn: Callable[[T], Any]) -> Either[T, E]tap_err
Section titled “tap_err”tap_err(self, fn: Callable[[E], Any]) -> Either[T, E]flatten
Section titled “flatten”flatten(self: Either[Ok[U], E]) -> Either[U, E]flatten(self: Either[Err[F], E]) -> Err[E | F]flatten(self: Either[Either[U, F], E]) -> Either[U, E | F]bimap(self, err_fn: Callable[[E], F], ok_fn: Callable[[T], U]) -> Either[U, F]recover
Section titled “recover”recover(self, f: Callable[[E], Any]) -> Either[Any, Any]recover_with
Section titled “recover_with”recover_with(self, f: Callable[[E], Either[Any, Any]]) -> Either[Any, Any]or_else
Section titled “or_else”or_else(self, alt: Either[Any, Any] | Callable[[], Either[Any, Any]]) -> Either[Any, Any]fold(self, err: Callable[..., Any], ok: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> T | Uunwrap_or_raise
Section titled “unwrap_or_raise”unwrap_or_raise(self, exc: Any = None) -> Anyto_option
Section titled “to_option”to_option(self) -> Option[T]is_ok(self) -> boolis_err
Section titled “is_err”is_err(self) -> boolErr(error: E)Fields:
error: E
map(self, f: Callable[..., Any]) -> Err[E]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Err[E]recover
Section titled “recover”recover(self, f: Callable[[E], Any]) -> Either[Any, Any]recover_with
Section titled “recover_with”recover_with(self, f: Callable[[E], Either[Any, Any]]) -> Either[Any, Any]map_err
Section titled “map_err”map_err(self, f: Callable[..., Any]) -> Err[Any]ensure
Section titled “ensure”ensure(self, predicate: Callable[[Any], bool], error: F | Callable[[Any], F]) -> Err[E]tap(self, fn: Callable[[Any], Any]) -> Err[E]tap_err
Section titled “tap_err”tap_err(self, fn: Callable[[E], Any]) -> Err[E]flatten
Section titled “flatten”flatten(self) -> Err[E]bimap(self, err_fn: Callable[[E], F], ok_fn: Callable[[Any], U]) -> Err[F]or_else
Section titled “or_else”or_else(self, alt: Either[Any, Any] | Callable[[], Either[Any, Any]]) -> Either[Any, Any]fold(self, err: Callable[..., Any], ok: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> Uunwrap_or_raise
Section titled “unwrap_or_raise”unwrap_or_raise(self, exc: Any = None) -> Anyto_option
Section titled “to_option”to_option(self) -> _Nothingis_ok(self) -> boolis_err
Section titled “is_err”is_err(self) -> boolFailure
Section titled “Failure”Failure(error: BaseException)Fields:
error: BaseException
map(self, f: Callable[..., Any]) -> Failureflat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Failuretap(self, fn: Callable[[Any], Any]) -> Failuretap_failure
Section titled “tap_failure”tap_failure(self, fn: Callable[[BaseException], Any]) -> Failureflatten
Section titled “flatten”flatten(self) -> Failurerecover
Section titled “recover”recover(self, f: Callable[[Any], Any]) -> Try[Any]recover_with
Section titled “recover_with”recover_with(self, f: Callable[[Any], Try[Any]]) -> Try[Any]or_else
Section titled “or_else”or_else(self, alt: Try[Any] | Callable[[], Try[Any]]) -> Try[Any]fold(self, failure: Callable[..., Any], success: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> Uto_either
Section titled “to_either”to_either(self) -> Err[Any]is_success
Section titled “is_success”is_success(self) -> boolis_failure
Section titled “is_failure”is_failure(self) -> boolFloatList
Section titled “FloatList”FloatList(items: Any = ...)empty(cls) -> FloatListmap_float
Section titled “map_float”map_float(self, f: Callable[[float], float]) -> FloatListfilter
Section titled “filter”filter(self, pred: Callable[[float], bool]) -> FloatListfold_left
Section titled “fold_left”fold_left(self, initial: Any, f: Callable[..., Any]) -> Anyadd_scalar
Section titled “add_scalar”add_scalar(self, n: float) -> FloatListsub_scalar
Section titled “sub_scalar”sub_scalar(self, n: float) -> FloatListmul_scalar
Section titled “mul_scalar”mul_scalar(self, n: float) -> FloatListdiv_scalar
Section titled “div_scalar”div_scalar(self, n: float) -> FloatListabs_vals
Section titled “abs_vals”abs_vals(self) -> FloatListclamp_vals
Section titled “clamp_vals”clamp_vals(self, lo: float, hi: float) -> FloatListzip_add
Section titled “zip_add”zip_add(self, other: FloatList) -> FloatListzip_mul
Section titled “zip_mul”zip_mul(self, other: FloatList) -> FloatListsum(self) -> floatmin(self) -> floatmax(self) -> floatmean(self) -> floatstd_dev
Section titled “std_dev”std_dev(self) -> floatto_list
Section titled “to_list”to_list(self) -> list[float]to_ilist
Section titled “to_ilist”to_ilist(self) -> IList[float]length
Section titled “length”length(self) -> intis_empty
Section titled “is_empty”is_empty(self) -> boolindex(self, value: Any, start: int = 0, stop: int = ...) -> intcount(self, value: Any) -> intIList(items: Any = ...)empty(cls) -> IList[Any]map(self, f: Callable[..., Any]) -> IList[Any]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> IList[Any]filter
Section titled “filter”filter(self, pred: Callable[..., bool]) -> IList[T]fold_left
Section titled “fold_left”fold_left(self, initial: Any, f: Callable[..., Any]) -> Anyhead(self) -> Some[T] | _Nothinglast(self) -> Some[T] | _Nothingtail(self) -> IList[T]find(self, pred: Callable[..., bool]) -> Some[T] | _Nothingtake(self, n: int) -> IList[T]drop(self, n: int) -> IList[T]distinct
Section titled “distinct”distinct(self) -> IList[T]zip(self, other: IList[Any]) -> IList[tuple[T, Any]]append
Section titled “append”append(self, item: T) -> IList[T]prepend
Section titled “prepend”prepend(self, item: T) -> IList[T]concat
Section titled “concat”concat(self, other: IList[T]) -> IList[T]to_list
Section titled “to_list”to_list(self) -> list[T]collect_ok
Section titled “collect_ok”collect_ok(self) -> IList[Any]collect_err
Section titled “collect_err”collect_err(self) -> IList[Any]partition_either
Section titled “partition_either”partition_either(self) -> tuple[IList[Any], IList[Any]]length
Section titled “length”length(self) -> intis_empty
Section titled “is_empty”is_empty(self) -> boolindex(self, value: Any, start: int = 0, stop: int = ...) -> intcount(self, value: Any) -> intKeys are found as in a dict: placed by Python’s hash() and compared with ==, so any key equal to a stored one finds it, whatever its type.
An IMap iterates in a fixed order that depends only on its contents, not on insertion order, the process or PYTHONHASHSEED, when every key is an exact str or bytes, an int, float, bool or None, or a tuple or frozenset of those. The order is by a 64-bit value computed from each key’s content, on first iteration, and it is neither insertion order nor sorted order. A key that hashes by identity (a plain object), through a str (a plain Enum member), or a str or bytes subclass with its own hash, iterates in a process-dependent order, and NaN keys with identical bits, or distinct keys of another type that share a hash, stay in insertion order among themselves.
IMap(items: Any = ...)empty(cls) -> IMap[Any, Any]get(self, key: object, /) -> Optional[V]get(self, key: object, default: V, /) -> Vget(self, key: object, default: _T, /) -> V | _Tget_option
Section titled “get_option”get_option(self, key: K) -> Some[V] | _Nothingset(self, key: K, value: V) -> IMap[K, V]remove
Section titled “remove”remove(self, key: K) -> IMap[K, V]contains
Section titled “contains”contains(self, key: K) -> boolto_dict
Section titled “to_dict”to_dict(self) -> dictkeys(self) -> KeysView[K]values
Section titled “values”values(self) -> ValuesView[V]items(self) -> ItemsView[K, V]map_values
Section titled “map_values”map_values(self, f: Callable[[V], Any]) -> IMap[K, Any]filter_values
Section titled “filter_values”filter_values(self, pred: Callable[[V], bool]) -> IMap[K, V]merge(self, other: IMap[K, V]) -> IMap[K, V]length
Section titled “length”length(self) -> intis_empty
Section titled “is_empty”is_empty(self) -> boolKeys are found as in a frozenset: placed by Python’s hash() and compared with ==, so any key equal to a stored one finds it, whatever its type.
An ISet iterates in a fixed order that depends only on its contents, not on insertion order, the process or PYTHONHASHSEED, when every key is an exact str or bytes, an int, float, bool or None, or a tuple or frozenset of those. The order is by a 64-bit value computed from each key’s content, on first iteration, and it is neither insertion order nor sorted order. A key that hashes by identity (a plain object), through a str (a plain Enum member), or a str or bytes subclass with its own hash, iterates in a process-dependent order, and NaN keys with identical bits, or distinct keys of another type that share a hash, stay in insertion order among themselves.
ISet(items: Optional[Iterable[T]] = None)empty(cls) -> ISet[Any]add(self, item: T) -> ISet[T]remove
Section titled “remove”remove(self, item: T) -> ISet[T]contains
Section titled “contains”contains(self, item: T) -> boolunion(self, other: ISet[T]) -> ISet[T]intersection
Section titled “intersection”intersection(self, other: ISet[T]) -> ISet[T]difference
Section titled “difference”difference(self, other: ISet[T]) -> ISet[T]is_subset_of
Section titled “is_subset_of”is_subset_of(self, other: ISet[T]) -> boolmap(self, f: Callable[[T], Any]) -> ISet[Any]filter
Section titled “filter”filter(self, pred: Callable[[T], bool]) -> ISet[T]to_set
Section titled “to_set”to_set(self) -> set[T]to_ilist
Section titled “to_ilist”to_ilist(self) -> IList[T]size(self) -> intis_empty
Section titled “is_empty”is_empty(self) -> boolisdisjoint
Section titled “isdisjoint”isdisjoint(self, other: Iterable[Any]) -> boolIntList
Section titled “IntList”IntList(items: Any = ...)empty(cls) -> IntListmap_int
Section titled “map_int”map_int(self, f: Callable[[int], int]) -> IntListfilter
Section titled “filter”filter(self, pred: Callable[[int], bool]) -> IntListfold_left
Section titled “fold_left”fold_left(self, initial: Any, f: Callable[..., Any]) -> Anyadd_scalar
Section titled “add_scalar”add_scalar(self, n: int) -> IntListsub_scalar
Section titled “sub_scalar”sub_scalar(self, n: int) -> IntListmul_scalar
Section titled “mul_scalar”mul_scalar(self, n: int) -> IntListdiv_scalar
Section titled “div_scalar”div_scalar(self, n: int) -> IntListabs_vals
Section titled “abs_vals”abs_vals(self) -> IntListclamp_vals
Section titled “clamp_vals”clamp_vals(self, lo: int, hi: int) -> IntListzip_add
Section titled “zip_add”zip_add(self, other: IntList) -> IntListzip_mul
Section titled “zip_mul”zip_mul(self, other: IntList) -> IntListsum(self) -> intmin(self) -> intmax(self) -> intmean(self) -> floatstd_dev
Section titled “std_dev”std_dev(self) -> floatto_list
Section titled “to_list”to_list(self) -> list[int]to_ilist
Section titled “to_ilist”to_ilist(self) -> IList[int]length
Section titled “length”length(self) -> intis_empty
Section titled “is_empty”is_empty(self) -> boolindex(self, value: Any, start: int = 0, stop: int = ...) -> intcount(self, value: Any) -> intIntSet
Section titled “IntSet”IntSet(items: Any = ...)empty(cls) -> IntSetadd(self, value: int) -> IntSetremove
Section titled “remove”remove(self, value: int) -> IntSetcontains
Section titled “contains”contains(self, value: Any) -> boolunion(self, other: IntSet) -> IntSetintersection
Section titled “intersection”intersection(self, other: IntSet) -> IntSetdifference
Section titled “difference”difference(self, other: IntSet) -> IntSetsymmetric_difference
Section titled “symmetric_difference”symmetric_difference(self, other: IntSet) -> IntSetis_subset
Section titled “is_subset”is_subset(self, other: IntSet) -> boolis_disjoint
Section titled “is_disjoint”is_disjoint(self, other: IntSet) -> boolcardinality
Section titled “cardinality”cardinality(self) -> intto_list
Section titled “to_list”to_list(self) -> list[int]to_bytes
Section titled “to_bytes”to_bytes(self) -> bytesfrom_bytes
Section titled “from_bytes”from_bytes(data: bytes) -> IntSetis_empty
Section titled “is_empty”is_empty(self) -> boolisdisjoint
Section titled “isdisjoint”isdisjoint(self, other: Iterable[Any]) -> boolInvalid
Section titled “Invalid”Invalid(error: E)Fields:
errors: tuple[E, ...]
sequence
Section titled “sequence”sequence(values: Iterable[Validated[U, F]]) -> Validated[list[U], F]traverse
Section titled “traverse”traverse(values: Iterable[_A], fn: Callable[[_A], Validated[U, F]]) -> Validated[list[U], F]JsonSchemaRegistrySerde
Section titled “JsonSchemaRegistrySerde”JSON Schema serde with Confluent Schema Registry integration.
Wire format: [0x00 magic][schema_id: 4 bytes BE][json payload]
Same magic byte as Avro; content is JSON. NOTE: payloads are NOT validated against the JSON Schema - this serde provides Confluent wire framing ([0x00][schema_id:4B BE][json]) and registry registration only. (confluent’s JSONSerializer validates; pyrula does not yet.)
timeout_ms: the bound on one registry HTTP request, from connect to the last byte of the response (default 5000, 1 to 300000; ValueError otherwise). A failed registration is remembered for 5 seconds, so serializing many records against a registry that is down makes one request, not one per record; register() always asks again.
JsonSchemaRegistrySerde(registry_url: str, subject: str, schema: str, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None, *, timeout_ms: int = 5000)for_topic
Section titled “for_topic”for_topic(registry_url: str, topic: str, schema: str, is_key: bool = False, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None, *, timeout_ms: int = 5000) -> JsonSchemaRegistrySerderegister
Section titled “register”register(self) -> Ok[int] | Err[SerdeError]subject
Section titled “subject”subject(self) -> strserialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: Iterable[Any]) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: Iterable[Any]) -> BytesListdeserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_objects
Section titled “deserialize_many_objects”deserialize_many_objects(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_from_packed
Section titled “deserialize_many_from_packed”deserialize_many_from_packed(self, packed: bytes, count: int) -> IListcheck_compatibility
Section titled “check_compatibility”check_compatibility(self, schema: str, version: Optional[str] = None) -> Ok[bool] | Err[SerdeError]list_versions
Section titled “list_versions”list_versions(self) -> Ok[list[int]] | Err[SerdeError]get_schema_by_version
Section titled “get_schema_by_version”get_schema_by_version(self, version: int) -> Ok[str] | Err[SerdeError]delete_version
Section titled “delete_version”delete_version(self, version: int) -> Ok[bool] | Err[SerdeError]JsonSerde
Section titled “JsonSerde”JsonSerde()serialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: Iterable[Any]) -> IListserialize_many_raw
Section titled “serialize_many_raw”serialize_many_raw(self, items: Iterable[Any]) -> BytesListdeserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_raw
Section titled “deserialize_many_raw”deserialize_many_raw(self, bytes_list: Iterable[bytes] | BytesList) -> IListNonEmptyList
Section titled “NonEmptyList”A list with at least one element.
head, last, and reduce are total - they return T, not Option[T],
because the non-empty invariant is enforced at construction time.
from_list is the safe boundary: it returns Option[NonEmptyList[T]].
NonEmptyList(head: T, *tail: T)of(head: T, *tail: T) -> NonEmptyList[T]from_list
Section titled “from_list”from_list(items: IList[T] | list[T]) -> Option[NonEmptyList[T]]head(self) -> Ttail(self) -> IList[T]last(self) -> Tmap(self, f: Callable[[T], Any]) -> NonEmptyList[Any]flat_map
Section titled “flat_map”flat_map(self, f: Callable[[T], NonEmptyList[Any]]) -> NonEmptyList[Any]reduce
Section titled “reduce”reduce(self, f: Callable[[T, T], T]) -> Tfold_left
Section titled “fold_left”fold_left(self, init: Any, f: Callable[[Any, T], Any]) -> Anyappend
Section titled “append”append(self, item: T) -> NonEmptyList[T]prepend
Section titled “prepend”prepend(self, item: T) -> NonEmptyList[T]to_ilist
Section titled “to_ilist”to_ilist(self) -> IList[T]to_list
Section titled “to_list”to_list(self) -> list[T]length
Section titled “length”length(self) -> intindex(self, value: Any, start: int = 0, stop: int = ...) -> intcount(self, value: Any) -> intOk(value: T)Fields:
value: T
map(self, f: Callable[..., Any]) -> Ok[Any]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Anymap_err
Section titled “map_err”map_err(self, f: Callable[..., Any]) -> Ok[T]ensure
Section titled “ensure”ensure(self, predicate: Callable[[T], bool], error: Callable[[T], F]) -> Either[T, F]ensure(self, predicate: Callable[[T], bool], error: F) -> Either[T, F]tap(self, fn: Callable[[T], Any]) -> Ok[T]tap_err
Section titled “tap_err”tap_err(self, fn: Callable[[Any], Any]) -> Ok[T]flatten
Section titled “flatten”flatten(self: Ok[_EitherResult]) -> _EitherResultbimap(self, err_fn: Callable[[Any], F], ok_fn: Callable[[T], U]) -> Ok[U]recover
Section titled “recover”recover(self, f: Callable[[Any], Any]) -> Ok[T]recover_with
Section titled “recover_with”recover_with(self, f: Callable[[Any], Either[Any, Any]]) -> Ok[T]or_else
Section titled “or_else”or_else(self, alt: Either[Any, Any] | Callable[[], Either[Any, Any]]) -> Ok[T]fold(self, err: Callable[..., Any], ok: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Tget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> Tunwrap_or_raise
Section titled “unwrap_or_raise”unwrap_or_raise(self, exc: Any = None) -> Tto_option
Section titled “to_option”to_option(self) -> Some[T]is_ok(self) -> boolis_err
Section titled “is_err”is_err(self) -> boolOption
Section titled “Option”Some(value) or Nothing; subclassed by both like Scala’s Option.
of(value: Optional[T]) -> Option[T]when(condition: bool, value: T) -> Option[T]from_callable
Section titled “from_callable”from_callable(f: Callable[[], T]) -> Option[T]sequence
Section titled “sequence”sequence(values: Iterable[Option[T]]) -> Option[list[T]]traverse
Section titled “traverse”traverse(values: Iterable[_A], fn: Callable[[_A], Option[U]]) -> Option[list[U]]map(self, f: Callable[..., Any]) -> Option[Any]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Option[Any]tap(self, fn: Callable[[T], Any]) -> Option[T]flatten
Section titled “flatten”flatten(self: Option[Some[U]]) -> Option[U]flatten(self: Option[_Nothing]) -> _Nothingflatten(self: Option[Option[U]]) -> Option[U]filter
Section titled “filter”filter(self, pred: Callable[..., bool]) -> Option[T]get_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> T | Uor_else
Section titled “or_else”or_else(self, alt: Option[Any] | Callable[[], Option[Any]]) -> Option[Any]fold(self, nothing_val: Any, some_fn: Callable[..., Any]) -> Anyto_either
Section titled “to_either”to_either(self, left: Any) -> Either[T, Any]to_either_with
Section titled “to_either_with”to_either_with(self, error_factory: Callable[[], E]) -> Either[T, E]to_list
Section titled “to_list”to_list(self) -> IList[T]is_some
Section titled “is_some”is_some(self) -> boolis_nothing
Section titled “is_nothing”is_nothing(self) -> boolis_empty
Section titled “is_empty”is_empty(self) -> boolProtobufRegistrySerde
Section titled “ProtobufRegistrySerde”Protobuf serde with Confluent Schema Registry integration.
Wire format: [0x00 magic][schema_id: 4 bytes BE][msg-index zigzag varint array][protobuf payload]
Accepts a serialized FileDescriptorSet and a fully-qualified message name.
Deserialization decodes to Python dicts using prost-reflect; no compiled
message types needed. Registration requires proto_source (the .proto
source text) so the Confluent SR can parse and validate the schema.
LIMITATION: the Confluent message-index is always written as [0] (first message) - only correct when message_name is the first top-level message; multi-message/nested .proto files will not interoperate with Confluent consumers that rely on the message index.
NOTE: proto3 implicit-presence scalar fields at their default are omitted on deserialize, absent from the returned dict (standard protobuf semantics). NOTE: enum fields accept the enum value name (str) or number (int) on serialize; deserialize returns the number (int).
timeout_ms: the bound on one registry HTTP request, from connect to the last byte of the response (default 5000, 1 to 300000; ValueError otherwise). A failed registration is remembered for 5 seconds, so serializing many records against a registry that is down makes one request, not one per record; register() always asks again.
ProtobufRegistrySerde(registry_url: str, subject: str, file_descriptor_set: bytes, message_name: str, proto_source: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None, *, timeout_ms: int = 5000)for_topic
Section titled “for_topic”for_topic(registry_url: str, topic: str, file_descriptor_set: bytes, message_name: str, is_key: bool = False, proto_source: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None, *, timeout_ms: int = 5000) -> ProtobufRegistrySerderegister
Section titled “register”register(self) -> Ok[int] | Err[SerdeError]subject
Section titled “subject”subject(self) -> strserialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]serialize_with_id
Section titled “serialize_with_id”serialize_with_id(self, obj: Any, schema_id: int) -> Ok[bytes] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: Iterable[Any]) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: Iterable[Any]) -> BytesListdeserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_objects
Section titled “deserialize_many_objects”deserialize_many_objects(self, bytes_list: Iterable[bytes] | BytesList) -> IListdeserialize_many_from_packed
Section titled “deserialize_many_from_packed”deserialize_many_from_packed(self, packed: bytes, count: int) -> IListcheck_compatibility
Section titled “check_compatibility”check_compatibility(self, proto_source: str, version: Optional[str] = None) -> Ok[bool] | Err[SerdeError]list_versions
Section titled “list_versions”list_versions(self) -> Ok[list[int]] | Err[SerdeError]get_schema_by_version
Section titled “get_schema_by_version”get_schema_by_version(self, version: int) -> Ok[str] | Err[SerdeError]delete_version
Section titled “delete_version”delete_version(self, version: int) -> Ok[bool] | Err[SerdeError]RecordedError
Section titled “RecordedError”A journaled exception that could not be rebuilt as its original class.
type_path is the original module:qualname and message its text;
str() is the message, and serializing it again writes the original pair.
RecordedError(type_path: str, message: str)Fields:
type_path: strmessage: str
SerdeError
Section titled “SerdeError”SerializationError
Section titled “SerializationError”Some(value: T)Fields:
value: T
map(self, f: Callable[..., Any]) -> Some[Any]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Anytap(self, fn: Callable[[T], Any]) -> Some[T]flatten
Section titled “flatten”flatten(self: Some[_OptionResult]) -> _OptionResultfilter
Section titled “filter”filter(self, pred: Callable[..., bool]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Tget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> Tor_else
Section titled “or_else”or_else(self, alt: Option[Any] | Callable[[], Option[Any]]) -> Some[T]fold(self, nothing_val: Any, some_fn: Callable[..., Any]) -> Anyto_either
Section titled “to_either”to_either(self, left: Any) -> Ok[T]to_either_with
Section titled “to_either_with”to_either_with(self, error_factory: Callable[[], E]) -> Ok[T]to_list
Section titled “to_list”to_list(self) -> IList[T]is_some
Section titled “is_some”is_some(self) -> boolis_nothing
Section titled “is_nothing”is_nothing(self) -> boolis_empty
Section titled “is_empty”is_empty(self) -> boolSuccess
Section titled “Success”Success(value: T)Fields:
value: T
map(self, f: Callable[..., Any]) -> Anyflat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Anytap(self, fn: Callable[[T], Any]) -> Success[T]tap_failure
Section titled “tap_failure”tap_failure(self, fn: Callable[[BaseException], Any]) -> Success[T]flatten
Section titled “flatten”flatten(self: Success[_TryResult]) -> _TryResultrecover
Section titled “recover”recover(self, f: Callable[[Any], Any]) -> Success[T]recover_with
Section titled “recover_with”recover_with(self, f: Callable[[Any], Try[Any]]) -> Success[T]or_else
Section titled “or_else”or_else(self, alt: Try[Any] | Callable[[], Try[Any]]) -> Success[T]fold(self, failure: Callable[..., Any], success: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Tget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> Tto_either
Section titled “to_either”to_either(self) -> Ok[T]is_success
Section titled “is_success”is_success(self) -> boolis_failure
Section titled “is_failure”is_failure(self) -> boolSuccess(value) or Failure(exc); subclassed by both like Scala’s Try.
apply(f: Callable[[], T]) -> Try[T]of(f: Callable[[], T]) -> Try[T]sequence
Section titled “sequence”sequence(values: Iterable[Try[T]]) -> Try[list[T]]traverse
Section titled “traverse”traverse(values: Iterable[_A], fn: Callable[[_A], Try[U]]) -> Try[list[U]]map(self, f: Callable[..., Any]) -> Try[Any]flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Try[Any]tap(self, fn: Callable[[T], Any]) -> Try[T]tap_failure
Section titled “tap_failure”tap_failure(self, fn: Callable[[BaseException], Any]) -> Try[T]flatten
Section titled “flatten”flatten(self: Try[Success[U]]) -> Try[U]flatten(self: Try[Failure]) -> Failureflatten(self: Try[Try[U]]) -> Try[U]recover
Section titled “recover”recover(self, f: Callable[[Any], Any]) -> Try[Any]recover_with
Section titled “recover_with”recover_with(self, f: Callable[[Any], Try[Any]]) -> Try[Any]or_else
Section titled “or_else”or_else(self, alt: Try[Any] | Callable[[], Try[Any]]) -> Try[Any]fold(self, failure: Callable[..., Any], success: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyget_or_else_with
Section titled “get_or_else_with”get_or_else_with(self, factory: Callable[[], U]) -> T | Uto_either
Section titled “to_either”to_either(self) -> Either[T, Any]is_success
Section titled “is_success”is_success(self) -> boolis_failure
Section titled “is_failure”is_failure(self) -> boolValid(value: T)Fields:
value: T
sequence
Section titled “sequence”sequence(values: Iterable[Validated[U, F]]) -> Validated[list[U], F]traverse
Section titled “traverse”traverse(values: Iterable[_A], fn: Callable[[_A], Validated[U, F]]) -> Validated[list[U], F]Validated
Section titled “Validated”Like Either, but zip accumulates errors instead of short-circuiting.
valid(value: T) -> Validated[T, E]invalid
Section titled “invalid”invalid(error: E) -> Validated[T, E]from_either
Section titled “from_either”from_either(either: Either[T, E]) -> Validated[T, E]cond(condition: bool, value: T, error: E) -> Validated[T, E]sequence
Section titled “sequence”sequence(values: Iterable[Validated[U, F]]) -> Validated[list[U], F]traverse
Section titled “traverse”traverse(values: Iterable[_A], fn: Callable[[_A], Validated[U, F]]) -> Validated[list[U], F]map(self, f: Callable[[T], Any]) -> Validated[Any, E]map_err
Section titled “map_err”map_err(self, f: Callable[[tuple[E, ...]], Any]) -> Validated[T, Any]zip(self, other: Validated[Any, E]) -> Validated[Any, E]fold(self, invalid: Callable[[tuple[E, ...]], Any], valid: Callable[[T], Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: T) -> Tto_either
Section titled “to_either”to_either(self) -> Either[T, tuple[E, ...]]is_valid
Section titled “is_valid”is_valid(self) -> boolis_invalid
Section titled “is_invalid”is_invalid(self) -> boolConstants
Section titled “Constants”Nothing: _Nothing = _nothing()
Functions
Section titled “Functions”case(cls: type[T]) -> type[T]Make cls a frozen dataclass. Use dataclasses.replace and dataclasses.asdict.
do(func: Callable[..., Any]) -> Callable[..., Any]do_async
Section titled “do_async”do_async(func: Callable[..., Any]) -> Callable[..., Any]flow(*funcs: Callable[..., Any]) -> Callable[..., Any]Compose funcs left to right into a single callable.
match(value: Any) -> Callable[..., Any]match(value)(on(T1, h1), on(T2, h2), ...): dispatch to the first matching
handler. For a @sealed hierarchy, raises if any concrete case is uncovered.
newtype
Section titled “newtype”newtype(name: str, base_type: type[T]) -> type[T]A lightweight subclass of base_type named name, for a distinct domain type.
newtype_strict
Section titled “newtype_strict”newtype_strict(name: str, base_type: type[T], *, validate: Optional[Callable[..., bool]] = None, err_msg: Optional[str] = None) -> type[T]Like newtype, but raises on construction if validate rejects the value.
on(typ: type[T], handler: Callable[..., Any]) -> AnyBuild a match arm: dispatch to handler when the value is an instance of typ.
partial
Section titled “partial”partial(f: Callable[..., Any], *args: Any, **kwargs: Any) -> Callable[..., Any]pipe(value: Any, *funcs: Callable[..., Any]) -> AnyThread value through funcs left to right, each result feeding the next.
sealed
Section titled “sealed”sealed(cls: type[T]) -> type[T]Mark cls as a closed hierarchy: match enforces exhaustiveness over its cases.
Subclasses may be declared only in the module that defines cls; any other module
gets a TypeError at class creation.