snakia.property

Functions

classproperty(fget[, fset, fdel])

Create a class property.

initonly()

Factory for Initonly.

readonly(value, *[, strict])

Create a readonly property with the given value.

Classes

CellProperty(fget[, fset, fdel])

A property that uses a cell to store its value.

ClassProperty(fget[, fset, fdel])

Class property

HookProperty(on_get[, on_set, on_del])

A property that calls a function when the property is set, get, or deleted.

Initonly()

Property that can only be set once.

PrivProperty()

Property([fget, fset, fdel])

A property that can be set, get, and deleted.

Readonly(fget, *[, strict])

Readonly property.

class snakia.property.CellProperty(fget, fset=<function func>, fdel=<function func>)[source]

Bases: Generic[T]

A property that uses a cell to store its value.

__init__(fget, fset=<function func>, fdel=<function func>)[source]
deleter(fdel, /)[source]

Descriptor deleter.

Return type:

Self

getter(fget, /)[source]

Descriptor getter.

Return type:

Self

setter(fset, /)[source]

Descriptor setter.

Return type:

Self

class snakia.property.ClassProperty(fget, fset=<function func>, fdel=<function func>)[source]

Bases: Generic[T]

Class property

__init__(fget, fset=<function func>, fdel=<function func>)[source]
deleter(fdel, /)[source]

Descriptor deleter.

Return type:

Self

getter(fget, /)[source]

Descriptor getter.

Return type:

Self

setter(fset, /)[source]

Descriptor setter.

Return type:

Self

class snakia.property.HookProperty(on_get, on_set=<function func>, on_del=<function func>)[source]

Bases: PrivProperty[T], Generic[T]

A property that calls a function when the property is set, get, or deleted.

__init__(on_get, on_set=<function func>, on_del=<function func>)[source]
deleter(on_del, /)[source]

Descriptor deleter.

Return type:

Self

getter(on_get, /)[source]

Descriptor getter.

Return type:

Self

property name: str

Return the name of the variable associated with the property.

setter(on_set, /)[source]

Descriptor setter.

Return type:

Self

class snakia.property.Initonly[source]
class snakia.property.Initonly(default_value: T)
class snakia.property.Initonly(*, default_factory: Callable[[Self], T])

Bases: PrivProperty[T], Generic[T]

Property that can only be set once.

__init__(default_value=<class 'snakia.types.unique.Unset'>, default_factory=<class 'snakia.types.unique.Unset'>)
property name: str

Return the name of the variable associated with the property.

class snakia.property.PrivProperty[source]
class snakia.property.PrivProperty(default_value: T)
class snakia.property.PrivProperty(*, default_factory: Callable[[Self], T])

Bases: Generic[T]

__init__(default_value=<class 'snakia.types.unique.Unset'>, default_factory=<class 'snakia.types.unique.Unset'>)[source]
property name: str

Return the name of the variable associated with the property.

class snakia.property.Property(fget=<function func>, fset=<function func>, fdel=<function func>)[source]

Bases: Generic[T]

A property that can be set, get, and deleted.

__init__(fget=<function func>, fset=<function func>, fdel=<function func>)[source]
deleter(fdel, /)[source]

Descriptor deleter.

Return type:

Property[TypeVar(T)]

getter(fget, /)[source]

Descriptor getter.

Return type:

Property[TypeVar(T)]

property name: str
setter(fset, /)[source]

Descriptor setter.

Return type:

Property[TypeVar(T)]

class snakia.property.Readonly(fget, *, strict=False)[source]

Bases: Property[T], Generic[T]

Readonly property.

__init__(fget, *, strict=False)[source]
deleter(fdel, /)

Descriptor deleter.

Return type:

Property[TypeVar(T)]

getter(fget, /)

Descriptor getter.

Return type:

Property[TypeVar(T)]

property name: str
setter(fset, /)

Descriptor setter.

Return type:

Property[TypeVar(T)]

snakia.property.classproperty(fget, fset=<function func>, fdel=<function func>)[source]

Create a class property.

Return type:

ClassProperty[TypeVar(T)]

Args:

fget (Callable[[Any], T], optional): The getter function. Defaults to empty.func. fset (Callable[[Any, T], None], optional): The setter function. Defaults to empty.func. fdel (Callable[[Any], None], optional): The deleter function. Defaults to empty.func.

Returns:

Self: The class property.

snakia.property.initonly()[source]

Factory for Initonly.

Return type:

Initonly[Any]

snakia.property.readonly(value, *, strict=False)[source]

Create a readonly property with the given value.

Return type:

Readonly[TypeVar(T)]

Args:

value (T): The value to set the readonly property to.

Returns:

Readonly[T]: The readonly property.

Modules

cell_property

hook_property

priv_property

property