When an assertion fails comparing dataclasses which has InitVar fields, the diff printing function fails with an AttributeError as it attempts to access the InitVar field. InitVar fields are not actually attributes stored in the dataclass, and I believe pytest needs to inspect the type here as dataclass does to ensure it's not treated as a real attribute.
___________________________________________ test_demonstrate ___________________________________________
> assert Foo(1, 2) == Foo(1, 3)
E AssertionError: assert Foo(real_attr=2) == Foo(real_attr=3)
E (pytest_assertion plugin: representation of details failed: /home/ayoon/.cache/pypoetry/virtualenvs/neoscore-ptOHLkol-py3.10/lib/python3.10/site-packages/_pytest/assertion/util.py:454: AttributeError: 'Foo' object has no attribute 'init_only'.
E Probably an object has a faulty __repr__.)
I'm running on Python 3.10.2, and my reproduction environment's pip list gives: