-
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
Emit error PTH118 for os.sep.join()
#5905
Comments
I can take this one (also working on some other pathlib ports from refurb) Nice catch, and also interesting to learn about grep.app. I've been using the GitHub search functionality so far |
I've found that GitHub search doesn't find exactly for what I'm looking for while grep.app does, in addition to providing case-insensitive and regex searching. It's also great for gauging how impactful a new rule might be, and finding potential edge-cases. And thank you for taking the time to port parts of Refurb into Ruff! I've added a lot of checks since #1348 was opened, and I've been meaning to leave a comment with an updated list but haven't had the time. I'll find some time this weekend to update the list! |
Any idea why folks are using |
Just realised that we should also detect the opposite: This should be a new rule, the requires a combination of |
One thing to note is that >>> import os
>>> os.path.join("hello", "world")
'hello/world'
>>> os.sep.join(("hello", "", "world"))
'hello//world' This isn't an issue when using it for the >>> from pathlib import Path
>>> Path("hello", "", "world") == Path("hello", "world")
True |
Closes #5905 Co-authored-by: Charlie Marsh <[email protected]>
Implements #5905 (comment) --------- Co-authored-by: konsti <[email protected]>
The following shows 2 similar snippets of code, but only one is picked up by Ruff currently:
os.sep.join()
acts the same asos.path.join()
, just written differently. Searching on grep.app shows that this is a somewhat common idiom.Running:
Expected:
An error for both
os.sep.join
andos.path.join
.The text was updated successfully, but these errors were encountered: