typedargs/typeinfo.py
def inject_type(self, name, typeobj):
        """
        Given a module-like object that defines a type, add it to our type system so that
        it can be used with the iotile tool and with other annotated API functions.
        """

        name = self._canonicalize_type(name)
        _, is_complex, _ = self.split_type(name)

        if self.is_known_type(name):
            raise ArgumentError("attempting to inject a type that is already defined", type=name)

        if (not is_complex) and self._is_factory(typeobj):
            if name in self.type_factories:
                raise ArgumentError("attempted to inject a complex type factory that is already defined", type=name)
            self.type_factories[name] = typeobj
        else:
            self._validate_type(typeobj)
            self.known_types[name] = typeobj

        if not hasattr(typeobj, "default_formatter"):
            raise ArgumentError("type is invalid, does not have default_formatter function", type=typeobj, methods=dir(typeobj))
def inject_type(self, name, typeobj):
        """
        Given a module-like object that defines a type, add it to our type system so that
        it can be used with the iotile tool and with other annotated API functions.
        """

        name = self._canonicalize_type(name)
        _, is_complex, _ = self.split_type(name)

        if self.is_known_type(name):
            raise ArgumentError("attempting to inject a type that is already defined", type=name)

        if (not is_complex) and self._is_factory(typeobj):
            if name in self.type_factories:
                raise ArgumentError("attempted to inject a complex type factory that is already defined", type=name)
            self.type_factories[name] = typeobj
        else:
            self._validate_type(typeobj)
            self.known_types[name] = typeobj

        if not hasattr(typeobj, "default_formatter"):
            raise ArgumentError("type is invalid, does not have default_formatter function", type=typeobj, methods=dir(typeobj))
def inject_type ( self , name , typeobj ) : name = self . _canonicalize_type ( name ) _ , is_complex , _ = self . split_type ( name ) if self . is_known_type ( name ) : raise ArgumentError ( "attempting to inject a type that is already defined" , type = name ) if ( not is_complex ) and self . _is_factory ( typeobj ) : if name in self . type_factories : raise ArgumentError ( "attempted to inject a complex type factory that is already defined" , type = name ) self . type_factories [ name ] = typeobj else : self . _validate_type ( typeobj ) self . known_types [ name ] = typeobj if not hasattr ( typeobj , "default_formatter" ) : raise ArgumentError ( "type is invalid, does not have default_formatter function" , type = typeobj , methods = dir ( typeobj ) )
Given a module-like object that defines a type, add it to our type system so that
        it can be used with the iotile tool and with other annotated API functions.
Given a module - like object that defines a type add it to our type system so that it can be used with the iotile tool and with other annotated API functions .