question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PEP 604 is applied to Python 3.9 code

See original GitHub issue

The 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
shao-wang-mecommented, Jul 7, 2022

I think you need to have --keep-runtime-typing specified.

0reactions
expobraincommented, Jul 7, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found