Skip to content

PTH201 does not detect Path("") #6085

@dosisod

Description

@dosisod

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions