RW

class component_model.utils.controls.RW(*args, **kwargs)

Bases: Protocol

Defines the read/write access function for a single control.

A function passed as rw argument when instantiating a Control instance must satisfy this protocol. The function is then accessible through the .rw property of the instantiated Control instance.

Using Protocol to define the signature of the read/write function allows for proper type checking while still providing flexibility in the implementation of the read/write function. It also allows the argument list to be empty when called for read access, which is desired in this case.

Implement the RW protocol either through a class, implementing the __call__() method, or use functools.partial() to tweak the signature of an existing function to match the signature of __call__(), and return that. See tests/test_controls.py for examples.

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)