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
Do not upgrade string annotations types wrapped in Optional
to new Union | formatting
#567
Comments
you've either opted into a python version that's newer than the one you're running or something else you're not showing -- pyupgrade only does this if it's safe |
@asottile i am running latest python 3.10 |
well then there's something you're not showing me -- watch this video and try again: https://youtu.be/ritp4gAqNMI |
you are right, I didn't finish the bug report. Sorry mac pressed submit. Not use to a github repo getting such quick attention, which is awesome btw. Here is the rest you need to replicate the issue fully. from typing import Optional
from sqlalchemy.orm import Mapped, relationship
qqq: Mapped[Optional["WorkspaceModel"]] After running pyupgrade, the output I am getting is: from sqlalchemy.orm import Mapped
qqq: Mapped["WorkspaceModel" | None] |
pyupgrade does not change that for for me, please watch the video and follow what it asks you to do |
When running a from typing import Optional
from sqlalchemy.orm import Mapped
qqq: Mapped[Optional["WorkspaceModel"]]
from sqlalchemy.orm import Mapped
qqq: Mapped["WorkspaceModel" | None] As an additional note, the output does not change if I use |
there were go, that's much more helpful and now I can reproduce you can likely work around this with |
Simplistic python code:
Output:
When running pyupgrade a segment of code was updated to use the
|
notation and caused this explosion. I worked around it, but I am sure others might run into similar issues.The text was updated successfully, but these errors were encountered: