-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend PEP 604 rewrites to support some quoted annotations (#5725)
## Summary Python doesn't allow `"Foo" | None` if the annotation will be evaluated at runtime (see the comments in the PR, or the semantic model documentation for more on what this means and when it is true), but it _does_ allow it if the annotation is typing-only. This, for example, is invalid, as Python will evaluate `"Foo" | None` at runtime in order to populate the function's `__annotations__`: ```python def f(x: "Foo" | None): ... ``` This, however, is valid: ```python def f(): x: "Foo" | None ``` As is this: ```python from __future__ import annotations def f(x: "Foo" | None): ... ``` Closes #5706.
- Loading branch information
1 parent
549173b
commit 932c9a4
Showing
3 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters