Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use list instead of set
  • Loading branch information
sebastien-rosset committed Apr 15, 2020
commit a0d53a416d38d9f57485cb7f093fa8f91a35eca7
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ def to_str(self):
"""Returns the string representation of the model"""
return str(self.value)

def __hash__(self):
"""Returns the hash value of this object."""
return hash(self._data_store['value'])

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down Expand Up @@ -208,10 +204,6 @@ def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down Expand Up @@ -282,26 +274,24 @@ def __getattr__(self, name):
if self._path_to_item:
path_to_item.extend(self._path_to_item)
path_to_item.append(name)
values = set()
values = []
if model_instances:
for model_instance in model_instances:
if name in model_instance._data_store:
v = model_instance._data_store[name]
if isinstance(v, list):
values.add(tuple(v))
else:
values.add(v)
if v not in values:
values.append(v)
len_values = len(values)
if len_values == 0:
raise ApiKeyError(
"{0} has no key '{1}'".format(type(self).__name__, name),
path_to_item
)
elif len_values == 1:
return list(values)[0]
return values[0]
elif len_values > 1:
raise ApiValueError(
"Values stored for property {0} in {1} difffer when looking "
"Values stored for property {0} in {1} differ when looking "
"at self and self's composed instances. All values must be "
"the same".format(name, type(self).__name__),
path_to_item
Expand All @@ -315,10 +305,6 @@ def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __hash__(self):
"""Returns the hash value of this object."""
return hash(frozenset(self._data_store.items()))

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, self.__class__):
Expand Down