def evaluate(self) -> None: """ Evaluate this statement. """ # the base class type_class = self.namespace.get_type(self.ctor.class_type) if not isinstance(type_class, EntityLike): raise TypingException( self, "Default can only be define for an Entity, but %s is a %s" % (self.ctor.class_type, self.ctor.class_type)) inmanta_warnings.warn( CompilerDeprecationWarning( self, "Default constructors are deprecated. Use inheritance instead." )) self.type.comment = self.comment default = self.type default.set_entity(type_class) for name, value in self.ctor.get_attributes().items(): default.add_default(name, value)
def deprecated_relation_warning(p: YaccProduction) -> None: inmanta_warnings.warn( SyntaxDeprecationWarning( p[0].location, None, "The relation definition syntax" " `{entity_left} {attr_left_on_right} {multi_left} {rel} {multi_right} {entity_right} {attr_right_on_left}`" " is deprecated. Please use" " `{entity_left}.{attr_right_on_left} {multi_right} -- {entity_right}.{attr_left_on_right} {multi_left}`" " instead.".format( entity_left=p[1], attr_left_on_right=p[2], multi_left="[%s:%s]" % tuple(v if v is not None else "" for v in p[3]), rel=p[4], multi_right="[%s:%s]" % tuple(v if v is not None else "" for v in p[5]), entity_right=p[6], attr_right_on_left=p[7], ), ), )