Bug 1891791

Summary: python-attrs fails to build with Python 3.10: Different exception message in test ("HypClass.__init__()" vs "__init__()")
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-attrsAssignee: Lumír Balhar <lbalhar>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: lbalhar, mhroncok, python-sig, spacewar, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-06 09:07:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1890881    

Description Tomáš Hrnčiar 2020-10-27 11:35:07 UTC
python-attrs fails to build with Python 3.10.0a1.

=================================== FAILURES ===================================
____________________________ TestAddInit.test_init _____________________________

self = <tests.test_dunders.TestAddInit object at 0x7ff44db29fa0>

    @given(booleans(), booleans())
>   def test_init(self, slots, frozen):

tests/test_dunders.py:612: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_dunders.TestAddInit object at 0x7ff44db29fa0>, slots = False
frozen = False

    @given(booleans(), booleans())
    def test_init(self, slots, frozen):
        """
        If `init` is False, ignore that attribute.
        """
        C = make_class(
            "C",
            {"a": attr.ib(init=False), "b": attr.ib()},
            slots=slots,
            frozen=frozen,
        )
        with pytest.raises(TypeError) as e:
            C(a=1, b=2)
    
>       assert (
            "__init__() got an unexpected keyword argument 'a'"
            == e.value.args[0]
        )
E       assert "__init__() g... argument 'a'" == "C.__init__()... argument 'a'"
E         - C.__init__() got an unexpected keyword argument 'a'
E         ? --
E         + __init__() got an unexpected keyword argument 'a'

tests/test_dunders.py:625: AssertionError
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_init(
    self=<tests.test_dunders.TestAddInit at 0x7ff44db29fa0>,
    slots=False,
    frozen=False,
)
___________________________ TestEvolve.test_unknown ____________________________

self = <tests.test_funcs.TestEvolve object at 0x7ff44d4bafd0>

    @given(simple_classes())
>   def test_unknown(self, C):

tests/test_funcs.py:512: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_funcs.TestEvolve object at 0x7ff44d4bafd0>
C = <class 'tests.strategies.HypClass'>

    @given(simple_classes())
    def test_unknown(self, C):
        """
        Wanting to change an unknown attribute raises an
        AttrsAttributeNotFoundError.
        """
        # No generated class will have a four letter attribute.
        with pytest.raises(TypeError) as e:
            evolve(C(), aaaa=2)
        expected = "__init__() got an unexpected keyword argument 'aaaa'"
>       assert (expected,) == e.value.args
E       assert ("__init__() ...ment 'aaaa'",) == ("HypClass.__...ment 'aaaa'",)
E         At index 0 diff: "__init__() got an unexpected keyword argument 'aaaa'" != "HypClass.__init__() got an unexpected keyword argument 'aaaa'"
E         Full diff:
E         - ("HypClass.__init__() got an unexpected keyword argument 'aaaa'",)
E         ?   ---------
E         + ("__init__() got an unexpected keyword argument 'aaaa'",)

tests/test_funcs.py:521: AssertionError
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_unknown(
    self=<tests.test_funcs.TestEvolve at 0x7ff44d4bafd0>,
    C=tests.strategies.HypClass,
)
=========================== short test summary info ============================
SKIPPED [1] tests/test_make.py:461: No old-style classes in Py3
SKIPPED [1] tests/test_make.py:926: PY2-specific keyword-only error behavior
SKIPPED [1] tests/test_make.py:943: PY2-specific keyword-only error behavior
SKIPPED [1] tests/test_make.py:1839: Needs to be only caught on Python 2.
SKIPPED [1] tests/test_slots.py:419: can't break CodeType.replace() via monkeypatch
SKIPPED [1] tests/test_slots.py:466: slots without weakref_slot should only work on PyPy
XFAIL tests/test_setattr.py::TestSetAttr::test_slotted_confused
FAILED tests/test_dunders.py::TestAddInit::test_init - assert "__init__() g.....
FAILED tests/test_funcs.py::TestEvolve::test_unknown - assert ("__init__() .....
============= 2 failed, 938 passed, 6 skipped, 1 xfailed in 48.99s =============
error: Bad exit status from /var/tmp/rpm-tmp.3gszUu (%check)
    Bad exit status from /var/tmp/rpm-tmp.3gszUu (%check)

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01721574-python-attrs/

For all our attempts to build python-attrs with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-attrs/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Lumír Balhar 2020-11-13 11:42:34 UTC
The troubles in attrs library are caused by an implementation of PEP 563 — type annotations in Python 3.10 are now stored as strings for the postponed evaluation.

I've created an upstream issue: https://github.com/python-attrs/attrs/issues/716

How big blocker is this issue for you?

Comment 2 Miro Hrončok 2020-11-13 12:05:43 UTC
It doesn't really block other packages because we need to build attrs without tests first anyway.

But until it is fixed, it might cover other more severe bugs. We might want to skip the 2 tests.

Comment 3 Lumír Balhar 2020-11-13 12:53:26 UTC
I am afraid that there are namy more failing tests than just these two mentioned earlier. Have you tried to rebuild the package with 3.10a2?

Comment 4 Miro Hrončok 2020-11-13 13:33:29 UTC
We have: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-attrs/

But I have not checked the logs when writing the previous comment:

FAILED tests/test_annotations.py::TestAnnotations::test_basic_annotations - A...
FAILED tests/test_annotations.py::TestAnnotations::test_typing_annotations - ...
FAILED tests/test_annotations.py::TestAnnotations::test_only_attrs_annotations_collected
FAILED tests/test_annotations.py::TestAnnotations::test_auto_attribs[True] - ...
FAILED tests/test_annotations.py::TestAnnotations::test_auto_attribs[False]
FAILED tests/test_annotations.py::TestAnnotations::test_auto_attribs_subclassing[True]
FAILED tests/test_annotations.py::TestAnnotations::test_auto_attribs_subclassing[False]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[typing.ClassVar-True]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[typing.ClassVar-False]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[t.ClassVar-True]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[t.ClassVar-False]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[ClassVar-True]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[ClassVar-False]
FAILED tests/test_annotations.py::TestAnnotations::test_basic_resolve - asser...
FAILED tests/test_annotations.py::TestAnnotations::test_resolve_types_auto_attrib[True]
FAILED tests/test_annotations.py::TestAnnotations::test_resolve_types_auto_attrib[False]
FAILED tests/test_annotations.py::TestAnnotations::test_self_reference[True]
FAILED tests/test_annotations.py::TestAnnotations::test_self_reference[False]
FAILED tests/test_annotations.py::TestAnnotations::test_forward_reference[True]
FAILED tests/test_annotations.py::TestAnnotations::test_forward_reference[False]
FAILED tests/test_dunders.py::TestAddInit::test_init - assert "__init__() g.....
FAILED tests/test_funcs.py::TestEvolve::test_unknown - assert ("__init__() .....
============ 22 failed, 918 passed, 6 skipped, 1 xfailed in 51.49s =============

Comment 5 Ben Cotton 2021-02-09 15:21:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 6 Lumír Balhar 2021-03-30 09:18:21 UTC
Waiting for a new upstream release and there is one more compatibility PR: https://github.com/python-attrs/attrs/pull/771

Comment 7 Lumír Balhar 2021-05-05 08:56:35 UTC
New upstream issue: https://github.com/python-attrs/attrs/issues/803
and downstream PR: https://src.fedoraproject.org/rpms/python-attrs/pull-request/7

Comment 8 Lumír Balhar 2021-05-06 09:07:30 UTC
Builds fine again: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/build/2167822/