support pypy

This commit is contained in:
Yuval Shimon 2021-12-12 15:14:24 +02:00
parent df74e5c532
commit 2d7905b13b
1 changed files with 6 additions and 7 deletions

View File

@ -146,15 +146,14 @@ def has_default_eq(
for dataclasses the default co_filename is <string>, for attrs class, the __eq__ should contain "attrs eq generated" for dataclasses the default co_filename is <string>, for attrs class, the __eq__ should contain "attrs eq generated"
""" """
# inspired from https://github.com/willmcgugan/rich/blob/07d51ffc1aee6f16bd2e5a25b4e82850fb9ed778/rich/pretty.py#L68 # inspired from https://github.com/willmcgugan/rich/blob/07d51ffc1aee6f16bd2e5a25b4e82850fb9ed778/rich/pretty.py#L68
if not hasattr(obj.__eq__, "__code__"): # the obj does not have a code attribute if hasattr(obj.__eq__, "__code__") and hasattr(obj.__eq__.__code__, "co_filename"):
return True code_filename = obj.__eq__.__code__.co_filename
code_filename = obj.__eq__.__code__.co_filename if isattrs(obj):
return "attrs generated eq" in code_filename
if isattrs(obj): return code_filename == "<string>" # data class
return "attrs generated eq" in code_filename return True
return code_filename == "<string>" # data class
def assertrepr_compare(config, op: str, left: Any, right: Any) -> Optional[List[str]]: def assertrepr_compare(config, op: str, left: Any, right: Any) -> Optional[List[str]]: