Skip to content

Commit

Permalink
Fixed autoeq in case of attributeerror
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed Nov 17, 2019
1 parent 6f09f96 commit 7a4750a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions autoclass/autoeq_.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ def __eq__(self, other):
"""
Generated by @autoeq. Relies on the hardcoded list of field names and "getattr" (object) for the value.
"""
for att_name in selected_names:
if getattr(self, att_name) != getattr(other, att_name):
return False
return True
try:
for att_name in selected_names:
if getattr(self, att_name) != getattr(other, att_name):
return False
except AttributeError:
return False
else:
return True

return __eq__

Expand Down

0 comments on commit 7a4750a

Please sign in to comment.