Open saippuakauppias opened 1 year ago
These are intentional, right now we don't autofix UP007 errors that are used outside of annotations (e.g., on the right-hand side of an assignment). (pyupgrade
doesn't either.)
Its caused some subtle bugs in the past: https://github.com/charliermarsh/ruff/issues/3215, https://github.com/charliermarsh/ruff/issues/2981. It was also discussed here: https://github.com/charliermarsh/ruff/issues/4108.
It's possible that it's actually fine to fix these, with the exception that we can't rewrite Union[new_types]
to new_types
. I'm not certain.
It would be very helpful to autofix the PEP604 |
unions, but have it gated behind an unsafe fix.
I'm using --add-noqa
as a workaround for now.
Example:
Run output: