-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Autofix for none-not-at-end-of-union (RUF036)
#15139
base: main
Are you sure you want to change the base?
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF036 | 477 | 0 | 87 | 390 | 0 |
E501 | 1 | 1 | 0 | 0 | 0 |
applicability, | ||
) | ||
}; | ||
diagnostic.set_fix(fix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set the fix to all the diagnostics?
Thanks for working on this! Can you add some tests with nested and mixed uses of unions? Like these: def f(x: None | Union[None ,int]): ...
def g(x: int | (str | None) | list): ...
def h(x: Union[int, Union[None, list | set]]: ... also the examples from def _detect_active_python(io: None | IO = None) -> Path | None: ... |
It looks like in the ecosystem check a bunch of violations were removed with no fix, so I'm wondering if a syntax error was introduced by the fix. Maybe when there is a default argument something goes wrong? |
Summary
Close #15136. Implement autofix for
none-not-at-end-of-union (RUF036)
Test Plan
Existing tests