fix weird failure in variant values (#22328)

This commit is contained in:
Danny McClanahan 2021-03-16 23:04:51 +00:00 committed by GitHub
parent 912606ad9a
commit 18fbd58fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,8 +282,21 @@ def _value_setter(self, value):
# to a set # to a set
self._value = tuple(sorted(set(value))) self._value = tuple(sorted(set(value)))
def _cmp_value(self):
"""Returns a tuple of strings containing the values stored in
the variant.
Returns:
tuple of str: values stored in the variant
"""
value = self._value
if not isinstance(value, tuple):
value = (value,)
stringified = tuple(str(x) for x in value)
return stringified
def _cmp_key(self): def _cmp_key(self):
return self.name, self.value return self.name, self._cmp_value()
def copy(self): def copy(self):
"""Returns an instance of a variant equivalent to self """Returns an instance of a variant equivalent to self