-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[flake8-pyi
]: More autofixes for redundant-none-literal (PYI061
)
#14872
[flake8-pyi
]: More autofixes for redundant-none-literal (PYI061
)
#14872
Conversation
flake8-pyi
]: More autofixes for redundant-none-literal/PYI061 (PYI061
)flake8-pyi
]: More autofixes for redundant-none-literal (PYI061
)
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.
Thanks! A couple of issues here, but this broadly looks like it's on the right track :-)
crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_none_literal.rs
Outdated
Show resolved
Hide resolved
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PYI061 | 17 | 0 | 1 | 16 | 0 |
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.
Thanks @kiran-4444, this is a fantastic improvement! I pushed a couple of small changes:
- We can't safely offer the fix with the
|
syntax on Python <=3.9, as the|
syntax for unions was added in Python 3.10. Possibly we could in the future usetyping.Union
for the fix and offer it even on older versions of Python, but I think we can leave that to another PR :-) - I simplified the code slightly by combining the two
create_fix_edit()
functions
Summary
This PR solves #14537. I've tested it, and it's working as expected. I'll be updating this with tests tomorrow. The implementation isn't yet sanitised and can be refactored further. Any feedback in doing this is greatly appreciated.
Test Plan
Tested locally, will update the tests.