Repository navigation
CI fails with attrs 25.2.0 #13290
Copy link
Copy link
Closed
Labels
status: help wanteddevelopers would like help from experts on this topicdevelopers would like help from experts on this topic
Description
Activity
- addedstatus: help wanteddevelopers would like help from experts on this topicdevelopers would like help from experts on this topic
on Mar 12, 2025 Culprit seems to be here:
pytest/src/_pytest/assertion/util.py
Lines 157 to 172 in d149ab3
def has_default_eq( obj: object, ) -> bool: """Check if an instance of an object contains the default eq First, we check if the object's __eq__ attribute has __code__, if so, we check the equally of the method code filename (__code__.co_filename) to the default one generated by the dataclass and attr module 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 if hasattr(obj.__eq__, "__code__") and hasattr(obj.__eq__.__code__, "co_filename"): code_filename = obj.__eq__.__code__.co_filename if isattrs(obj): return "attrs generated eq" in code_filename with attrs 25.1, objects show:
(Pdb) p code_filename '<attrs generated eq test_assertion.TestAssert_reprcompare_attrsclass.test_attrs.<locals>.SimpleDataObject>'but with 25.2:
(Pdb) p code_filename '<attrs generated methods test_assertion.TestAssert_reprcompare_attrsclass.test_attrs.<locals>.SimpleDataObject>'which also aligns with test changes in the PR you linked.
So I think all that'd be required is:
diff --git i/src/_pytest/assertion/util.py w/src/_pytest/assertion/util.py index 30aee185d..c545e6cd2 100644 --- i/src/_pytest/assertion/util.py +++ w/src/_pytest/assertion/util.py @@ -169,7 +169,7 @@ def has_default_eq( code_filename = obj.__eq__.__code__.co_filename if isattrs(obj): - return "attrs generated eq" in code_filename + return "attrs generated " in code_filename return code_filename == "<string>" # data class return True
Reacted by Miro Hrončok
Metadata
Metadata
Assignees
Labels
status: help wanteddevelopers would like help from experts on this topicdevelopers would like help from experts on this topic
As seen in https://github.com/pytest-dev/pytest/actions/runs/13810374238 we're getting failing runs from attrs==25.2 in
testing/test_assertion.pyTestAssert_reprcompare_attrsclassI bisected it to python-attrs/attrs#1407 - but am unfamiliar with both attr and the parts of pytest interacting with it so am leaving further exploration for somebody else.