{ } Raw JSON

bundles / traitlets latest / traitlets / traitlets / Type / __init__

function

traitlets.traitlets:Type.__init__

source: /traitlets/traitlets.py:2110

Signature

def __init__(self, default_value: t.Any = traitlets.Undefined, klass: t.Any = None, allow_none: bool = False, read_only: bool | None = None, help: str | None = None, config: t.Any | None = None, **kwargs: t.Any) → None

Summary

Construct a Type trait

Extended Summary

A Type trait specifies that its values must be subclasses of a particular class.

If only default_value is given, it is used for the klass as well. If neither are given, both default to object.

Parameters

default_value : class, str or None

The default value must be a subclass of klass. If an str, the str must be a fully specified class name, like 'foo.bar.Bah'. The string is resolved into real class, when the parent HasTraits class is instantiated.

klass : class, str [ default object ]

Values of this trait must be a subclass of klass. The klass may be specified in a string like: 'foo.bar.MyClass'. The string is resolved into real class, when the parent HasTraits class is instantiated.

allow_none : bool [ default False ]

Indicates whether None is allowed as an assignable value.

**kwargs

extra kwargs passed to ClassBasedTraitType

Aliases

  • traitlets.Type.__init__