-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Consider not applying PEP 604 by presence of __future__ #387
Comments
I'd rather use this in python3.7 so I'm gong to reject this proposal |
@asottile Would you consider enabling/disabling of this with a feature flag in non-3.10 Python? This will introduce breaking code changes for all essentially any runtime usage of type hints. ... and if not, would you consider a "documentation fix" saying e.g. "this project introduces changes that break runtime introspection of type hints"? |
runtime types should use |
@asottile So would you consider a patch that documents the breakage? Also, this isn't in regard to runtime types that differ from static types. How do you propose using Update: To clarify, this code breaks by the recent changes: from __future__ import annotations
from typing import Optional, get_type_hints
def foo() -> Optional[int]:
...
get_type_hints(foo) I don't understand how |
#389 probably does what you want |
@asottile Hey, thanks for reconsidering and fixing! 🙏 |
Applying PEP 604 on non 3.10 code will crash on libraries depending on introspection of type hints using
typing.get_type_hints
. This should apply for libraries like https://github.com/samuelcolvin/pydantic and https://github.com/konradhalas/dacite.Example:
My proposal is to only rewrite to PEP 604 when the minimum version is 3.10.
The text was updated successfully, but these errors were encountered: