PEP 604 is applied to Python 3.9 code
See original GitHub issueThe PEP-604 introduces the ability to rewrite unions and with pipes, i.e. Union[int, float
into int | float
or Optional[int]
into int | None
.
This is available from Python 3.10, however, using the --py39-plus
settings the PEP-604 is wrongly applied making the code incompatible with Python 3.9.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
PEP 604 – Allow writing union types as X | Y
This PEP proposes overloading the | operator on types to allow writing Union[X, Y] as X | Y , and allows it to...
Read more >Python Type Hints - How to Upgrade Syntax with pyupgrade
PEP 585 was released in Python 3.9, and PEP 604 will be released in Python ... For example, take this code, which uses...
Read more >PEP 604 compatiblity to replace `Optional[str]` with `str | None`
We have some code that needed hashing that is backward incompatible with 1.8. So we need to fix that internally first. I did...
Read more >Support PEP 604 -- Allow writing union types as X | Y
Support PEP 604 -- Allow writing union types as X | Y ... Just in case it's helpful to you: while PEP 604...
Read more >Python 3.10 - Simplifies Unions in Type Annotations
PEP 604, Allow writing union types as X | Y; PEP 613, Explicit Type Aliases; PEP 612, Parameter Specification Variables. The focus of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think you need to have
--keep-runtime-typing
specified.@shao-wang-me it’s what I did in the end.
I’ve isolated the issue further but not able yet to reproduce it in a small and understandable PoC, so for now I disabled that transofrmation.