Skip to content

Python 3.10 compatibility #716

@frenzymadness

Description

@frenzymadness

Hello.

We have already started testing RPM packages in Fedora with Python 3.10a2 and attrs is currently not compatible.

The problem is caused by the implementation of PEP 563 — type annotations are now stored as strings which cause asserts like this one to fail:

class TestAnnotations:
    """
    Tests for types derived from variable annotations (PEP-526).
    """

    def test_basic_annotations(self):
        """
        Sets the `Attribute.type` attr from basic type annotations.
        """

        @attr.s
        class C:
            x: int = attr.ib()
            y = attr.ib(type=str)
            z = attr.ib()

        assert int is attr.fields(C).x.type

The value stored in attr.fields(C).x.type is a string "int" instead of a class int.

It seems it was discussed before in #424

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTypingTyping/stub/Mypy/PyRight related bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions