TypeMap Instances

The Teleport specification defines a mathematical function t, which maps type definitions to type instances. In Teleport, this mapping is performed by instances of TypeMap. These instances behave like functions and the t() function that you import from the teleport module is actually an instance of this class:

>>> from teleport import t
>>> t
<teleport.core.TypeMap at 0x7ffcb08e7c10>
class teleport.TypeMap

When you call the t() function, you are actually calling this method. You will rarely want to override this directly.

Parameters:schema – a JSON value
Returns:a Type instance

Override this method to enable dynamic type search. It gets called if the requested type is neither a core type nor a type added by register(). In that case, this is the last resort before Undefined is thrown.

Parameters:name – a string
Returns:a subclass of Type or None

Used as a decorator to add a type to the type map.

class TruthType(ConcreteType):

    def check(self, value):
        return value is True