GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CI fails with attrs 25.2.0 · Issue #13290 · pytest-dev/pytest

CI fails with attrs 25.2.0 #13290

New issue
Copy link
New issue
Copy link
Closed
#13291
Closed
CI fails with attrs 25.2.0#13290
#13291
Copy link
Labels
status: help wanteddevelopers would like help from experts on this topic

Description

@jakkdl
jakkdl
opened on Mar 12, 2025
Issue body actions

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.py TestAssert_reprcompare_attrsclass

I 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.

Activity

  1. jakkdl
    added
    status: help wanteddevelopers would like help from experts on this topic
    on Mar 12, 2025
  2. The-Compiler commented on Mar 12, 2025

    @The-Compiler
    The-Compiler
    on Mar 12, 2025
    Member
    More actions

    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
  3. bluetech
    closed this as completedin #13291on Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wanteddevelopers would like help from experts on this topic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.