[flake8-use-pathlib] Extend check for invalid path suffix to include the case "." (PTH210)#14902
[flake8-use-pathlib] Extend check for invalid path suffix to include the case "." (PTH210)#14902dylwil3 merged 14 commits intoastral-sh:mainfrom
flake8-use-pathlib] Extend check for invalid path suffix to include the case "." (PTH210)#14902Conversation
|
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: 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
dylwil3
left a comment
There was a problem hiding this comment.
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. |
dylwil3
left a comment
There was a problem hiding this comment.
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 <micha@reiser.io>
…pathlib_with_suffix.rs Co-authored-by: Dylan <53534755+dylwil3@users.noreply.github.com>
…pathlib_with_suffix.rs Co-authored-by: Dylan <53534755+dylwil3@users.noreply.github.com>
…pathlib_with_suffix.rs Co-authored-by: Dylan <53534755+dylwil3@users.noreply.github.com>
dylwil3
left a comment
There was a problem hiding this comment.
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