File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -146,15 +146,14 @@ def has_default_eq(
146
146
for dataclasses the default co_filename is <string>, for attrs class, the __eq__ should contain "attrs eq generated"
147
147
"""
148
148
# inspired from https://github.com/willmcgugan/rich/blob/07d51ffc1aee6f16bd2e5a25b4e82850fb9ed778/rich/pretty.py#L68
149
- if not hasattr (obj .__eq__ , "__code__" ): # the obj does not have a code attribute
150
- return True
149
+ if hasattr (obj .__eq__ , "__code__" ) and hasattr ( obj . __eq__ . __code__ , "co_filename" ):
150
+ code_filename = obj . __eq__ . __code__ . co_filename
151
151
152
- code_filename = obj .__eq__ .__code__ .co_filename
152
+ if isattrs (obj ):
153
+ return "attrs generated eq" in code_filename
153
154
154
- if isattrs (obj ):
155
- return "attrs generated eq" in code_filename
156
-
157
- return code_filename == "<string>" # data class
155
+ return code_filename == "<string>" # data class
156
+ return True
158
157
159
158
160
159
def assertrepr_compare (config , op : str , left : Any , right : Any ) -> Optional [List [str ]]:
You can’t perform that action at this time.
0 commit comments