Skip to content

Commit 7a4750a

Browse files
author
Sylvain MARIE
committed
Fixed autoeq in case of attributeerror
1 parent 6f09f96 commit 7a4750a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

autoclass/autoeq_.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,14 @@ def __eq__(self, other):
157157
"""
158158
Generated by @autoeq. Relies on the hardcoded list of field names and "getattr" (object) for the value.
159159
"""
160-
for att_name in selected_names:
161-
if getattr(self, att_name) != getattr(other, att_name):
162-
return False
163-
return True
160+
try:
161+
for att_name in selected_names:
162+
if getattr(self, att_name) != getattr(other, att_name):
163+
return False
164+
except AttributeError:
165+
return False
166+
else:
167+
return True
164168

165169
return __eq__
166170

0 commit comments

Comments
 (0)