Beispiel #1
0
    def type_check(self, instance):
        if not isinstance(instance, ShardedKey):
            raise typehints.CompositeTypeHintError(
                "ShardedKey type-constraint violated. Valid object instance "
                "must be of type 'ShardedKey'. Instead, an instance of '%s' "
                "was received." % (instance.__class__.__name__))

        try:
            typehints.check_constraint(self.key_type, instance.key)
        except (typehints.CompositeTypeHintError,
                typehints.SimpleTypeHintError):
            raise typehints.CompositeTypeHintError(
                "%s type-constraint violated. The type of key in 'ShardedKey' "
                "is incorrect. Expected an instance of type '%s', "
                "instead received an instance of type '%s'." %
                (repr(self), typehints._unified_repr(
                    self.key_type), instance.key.__class__.__name__))
Beispiel #2
0
 def __repr__(self):
   return 'Row(%s)' % ', '.join(
       '%s=%s' % (name, typehints._unified_repr(t)) for name,
       t in self._fields)
Beispiel #3
0
 def __repr__(self):
     return 'ShardedKey[%s]' % typehints._unified_repr(self.key_type)