-
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-use-pathlib
] Extend check for invalid path suffix to include the case "."
(PTH210
)
#14902
Conversation
Thanks for suggesting this test and pointing out the bug! Of course, since it fails we can't merge it in without also having the fix 😄 Would you be interested in taking a look and fleshing out your PR? I believe this early return needs to be modified: ruff/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/dotless_pathlib_with_suffix.rs Lines 78 to 80 in d4126f6
Edit: Actually the change will be a little more involved because I don't think it makes sense to offer a fix in this case, so you'll have to change the rule to be only sometimes fixable. Let me know if you're interested and/or need any pointers navigating that change. |
The rule, which is currently called |
|
@dylwil3 Yes, I need help. I tried to figure it out and fix the |
Agree, we should probably rename it to |
crates/ruff_linter/src/rules/flake8_use_pathlib/rules/dotless_pathlib_with_suffix.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_use_pathlib/rules/dotless_pathlib_with_suffix.rs
Outdated
Show resolved
Hide resolved
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.
Looking good! In addition to Micha's suggestions, could you update the documentation comment?
We may want to add a TODO comment for when Python 3.14 is released/supported by Ruff. The rule should revert to the original behavior in that case since |
Thanks! I will try to update documentation comment. |
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.
Few more nits - almost there!
crates/ruff_linter/src/rules/flake8_use_pathlib/rules/invalid_pathlib_with_suffix.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_use_pathlib/rules/invalid_pathlib_with_suffix.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_use_pathlib/rules/invalid_pathlib_with_suffix.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_use_pathlib/rules/invalid_pathlib_with_suffix.rs
Outdated
Show resolved
Hide resolved
…pathlib_with_suffix.rs Co-authored-by: Micha Reiser <[email protected]>
…pathlib_with_suffix.rs Co-authored-by: Dylan <[email protected]>
…pathlib_with_suffix.rs Co-authored-by: Dylan <[email protected]>
…pathlib_with_suffix.rs Co-authored-by: Dylan <[email protected]>
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.
LGTM! Thanks so much for your patience, and for the great contribution!
flake8-use-pathlib
] The Path.with_suffix('.') test should fail (PTH210
)flake8-use-pathlib
] Extend check for invalid path suffix to include the case "."
(PTH210
)
Summary
Hi!
Thank you @InSyncWithFoo for the your contribution #14779!
I suggest adding a test that makes use of the
suffix='.'
. It must fail. Right now, ruff doesn't show any errors in this test.Test Plan
Tests fails