atom.typed module

class atom.typed.ForwardTyped(resolve, args=None, kwargs=None, *, factory=None, optional=True)[source]

Bases: atom.typed.Typed

A Typed which delays resolving the type definition.

The first time the value is accessed or modified, the type will be resolved and the forward typed will behave identically to a normal typed.

args
clone()[source]

Create a clone of the ForwardTyped instance.

default(owner)[source]

Called to retrieve the default value.

This is called the first time the default value is retrieved for the member. It resolves the type and updates the internal default handler to behave like a normal Typed member.

kwargs
optional
resolve
validate(owner, old, new)[source]

Called to validate the value.

This is called the first time a value is validated for the member. It resolves the type and updates the internal validate handler to behave like a normal Typed member.

class atom.typed.Typed(kind, args=None, kwargs=None, *, factory=None, optional=True)[source]

Bases: atom.catom.Member

A value which allows objects of a given type or types.

Values will be tested using the PyObject_TypeCheck C API call. This call is equivalent to type(obj) in cls.mro(). It is less flexible but can be faster than Instance. Use Instance when allowing you need a tuple of types or (abstract) types relying on custom __isinstancecheck__ and Typed when the value type is explicit.

If optional is True, the value of a Typed may be set to None, otherwise None is not considered as a valid value.