Skip to content
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

PTH201 does not detect Path("") #6085

Closed
dosisod opened this issue Jul 26, 2023 · 2 comments · Fixed by #6095
Closed

PTH201 does not detect Path("") #6085

dosisod opened this issue Jul 26, 2023 · 2 comments · Fixed by #6095

Comments

@dosisod
Copy link
Contributor

dosisod commented Jul 26, 2023

The following 3 snippets are the equivalent, though Path("") is not detected:

from pathlib import Path

Path()     # correct code
Path("")   # no error
Path(".")  # PTH201

Ruff output:

$ ruff x.py
x.py:5:6: PTH201 [*] Do not pass the current directory explicitly to `Path`

Expected output:

Ruff should emit an error for Path(""). This is a fairly common idiom according to grep.app, and is currently detected in Refurb.

@harupy
Copy link
Contributor

harupy commented Jul 26, 2023

Can I fix this?

@charliermarsh
Copy link
Member

Go for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants