File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,14 @@ def __bytes_repr__(self, cache: Cache) -> Iterator[bytes]:
106
106
def bytes_repr (obj : object , cache : Cache ) -> Iterator [bytes ]:
107
107
cls = obj .__class__
108
108
yield f"{ cls .__module__ } .{ cls .__name__ } :{{" .encode ()
109
+ dct : Dict [str , ty .Any ]
109
110
if attrs .has (type (obj )):
110
111
# Drop any attributes that aren't used in comparisons by default
111
- dct = attrs .asdict (obj , recurse = False , filter = lambda a , _ : bool (a .eq )) # type: ignore
112
+ dct = attrs .asdict (obj , recurse = False , filter = lambda a , _ : bool (a .eq ))
113
+ elif hasattr (obj , "__slots__" ):
114
+ dct = {attr : getattr (obj , attr ) for attr in obj .__slots__ }
112
115
else :
113
- try :
116
+ dct = obj . __dict__
114
117
dct = obj .__dict__
115
118
except AttributeError as e :
116
119
try :
You can’t perform that action at this time.
0 commit comments