Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.10 support #763

Merged
merged 5 commits into from
Feb 22, 2021
Merged

Add Python 3.10 support #763

merged 5 commits into from
Feb 22, 2021

Conversation

hynek
Copy link
Member

@hynek hynek commented Feb 19, 2021

Python 3.10 has string types everywhere and that has unmasked a bunch of
bugs/edge cases in our code.

Especially the hooks code need a resolving helper for string types. I'm leaving
that for a separate PR.

Same for test_mypy.yml

Fixes #716

cc @euresti @ambv @frenzymadness @sscherfke

@hynek hynek added the Typing Typing/stub/Mypy/PyRight related bugs. label Feb 19, 2021
@hynek hynek added this to the 21.1.0 milestone Feb 19, 2021
"""
String annotations are passed into __init__ as is.

It fails on 3.6 due to a bug in Python.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeError: Forward references must evaluate to types. Got typing.ClassVar[int].

src/attr/_make.py Show resolved Hide resolved
tests/test_annotations.py Outdated Show resolved Hide resolved
@@ -487,10 +518,6 @@ class C:
y = attr.ib(type=str)
z = attr.ib()

assert "int" == attr.fields(C).x.type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because they don't work across Python versions (they become typing.ForwardRef or something like that). I figured it's more important it ultimately gives us what we need?

@@ -624,9 +624,8 @@ def test_init(self, slots, frozen):
with pytest.raises(TypeError) as e:
C(a=1, b=2)

assert (
assert e.value.args[0].endswith(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. What does it start with now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class names. So in this case C..

tests/test_annotations.py Outdated Show resolved Hide resolved
@hynek
Copy link
Member Author

hynek commented Feb 19, 2021

The tests have totally finished and succeeded. sigh

@hynek hynek force-pushed the py310 branch 2 times, most recently from 0d5ecdc to 939742f Compare February 22, 2021 07:50
Python 3.10 has string types everywhere and that has unmasked a bunch of
bugs/edge cases in our code.

Especially the hooks code need a resolving helper for string types. I'm leaving
that for a separate PR.

Fixes #716
Copy link
Contributor

@euresti euresti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good!

@hynek hynek merged commit 03d3fc7 into master Feb 22, 2021
@hynek hynek deleted the py310 branch February 22, 2021 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing Typing/stub/Mypy/PyRight related bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python 3.10 compatibility
2 participants