Bug 1891791 - python-attrs fails to build with Python 3.10: Different exception message in test ("HypClass.__init__()" vs "__init__()")
Summary: python-attrs fails to build with Python 3.10: Different exception message in ...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: python-attrs
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lumír Balhar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2020-10-27 11:35 UTC by Tomáš Hrnčiar
Modified: 2021-02-09 16:24 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github python-attrs attrs issues 716 0 None open Python 3.10 compatibility 2021-02-16 09:54:52 UTC

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.


Note You need to log in before you can comment on or make changes to this bug.