snakia.field.field

Functions

abstractmethod(funcobj)

A decorator indicating abstract methods.

final(f)

A decorator to indicate final methods and final classes.

inherit(type_[, attrs])

Create a new class that inherits from the given class.

Classes

ABC()

Helper class that provides a standard way to create an ABC using inheritance.

Field(default_value)

Generic()

Abstract base class for generic types.

PrivProperty([default_value])

TypeVar(name, *constraints[, bound, ...])

Type variable.

class snakia.field.field.Field(default_value)[source]

Bases: ABC, PrivProperty[T], Generic[T]

__init__(default_value)[source]
final classmethod custom(serialize, deserialize)[source]
Return type:

type[Field[TypeVar(R)]]

abstract deserialize(serialized, /)[source]

Deserialize a value

Parameters:

serialized (bytes) – serialized value

Returns:

deserialized value

Return type:

T

final static get_fields(class_, /)[source]
Return type:

dict[str, Field[Any]]

property name: str

Return the name of the variable associated with the property.

abstract serialize(value, /)[source]

Serialize a value

Parameters:

value (T) – value to serialize

Returns:

serialized value

Return type:

bytes