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 compatibility for Postponed Evaluation of Annotations (PEP 563) #15739

Open
function2-llx opened this issue Feb 20, 2022 · 6 comments · May be fixed by #15795
Open

Add compatibility for Postponed Evaluation of Annotations (PEP 563) #15739

function2-llx opened this issue Feb 20, 2022 · 6 comments · May be fixed by #15795

Comments

@function2-llx
Copy link

@function2-llx function2-llx commented Feb 20, 2022

Hello,

The code says that it will add compatibility for Postponed Evaluation of Annotations (PEP 563) when Python 3.9 is released (which already happened on 2020.10.5). Is there any plan to complete this?

if isinstance(field.type, str):
raise ImportError(
"This implementation is not compatible with Postponed Evaluation of Annotations (PEP 563), "
"which can be opted in from Python 3.7 with `from __future__ import annotations`. "
"We will add compatibility when Python 3.9 is released."
)

@LysandreJik
Copy link
Member

@LysandreJik LysandreJik commented Feb 22, 2022

Hey! We don't have to do the bandwidth to do it right now, but we'd welcome contributions! Let me tag this as a first good issue, and let me know if you're interested in taking a stab at it!

@function2-llx
Copy link
Author

@function2-llx function2-llx commented Feb 23, 2022

I'm glad to help with that, maybe it'll take some time. I never contribute here, I'll try to follow the CONTRIBUTING.md, post progress here and submit PR later, any discussion telling me if I'm doing right would be great.

@function2-llx
Copy link
Author

@function2-llx function2-llx commented Feb 23, 2022

According to discussion here and solution provided by Pydantic, we may just call typing.get_type_hints on some dataclass to get type of a field instead of relying on field.type.

Also, typing module is still under development, thus changes notably across different versions of Python. Since Python 3.6 reached its end-of-life last year (https://endoflife.date/python), dropping support for Python 3.6 would be reasonable and make this implementation much easier as well. There seems to be no plan on this (see also #15720).

@LysandreJik
Copy link
Member

@LysandreJik LysandreJik commented Feb 23, 2022

I understand; as mentioned in the thread you linked, we're unlikely to drop support for Python 3.6 just yet, but we'll definitely keep in mind that this particular issue would be solved in a simpler manner were we to drop support for it.

@function2-llx function2-llx linked a pull request that will close this issue Feb 23, 2022
4 tasks
@rahimt420
Copy link

@rahimt420 rahimt420 commented Mar 7, 2022

I'm glad to help with that, maybe it'll take some time. Like sparkanime.com

@function2-llx
Copy link
Author

@function2-llx function2-llx commented Mar 8, 2022

@rahimt420 Hello, thanks for the offer! However, I've already submitted #15795 to resolve this issue. It will be great if you could leave any suggestions there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants