1 from translate.misc.typecheck import CheckType, _TC_TypeError, check_type, Type
2 from translate.misc.typecheck import register_type, Or, _TC_Exception, _TC_KeyError
3 from translate.misc.typecheck import _TC_LengthError
4
5
6
7
8
9 -class Set(CheckType):
11 self.type = set(set_list)
12 self._types = [Type(t) for t in self.type]
13
14
15 if len(self._types) > 1:
16 self._type = Or(*self.type)
17 elif len(self._types) == 1:
18
19 t = self.type.pop()
20 self._type = t
21 self.type.add(t)
22
24 return "Set(" + str([e for e in self.type]) + ")"
25
26 __repr__ = __str__
27
48
50 if self.__class__ is not other.__class__:
51 return False
52 return self.type == other.type
53
55 return hash(str(hash(self.__class__)) + str(hash(frozenset(self.type))))
56
57 @classmethod
59 if isinstance(obj, set):
60 return Set(obj)
61
62 register_type(Set)
63