Skip to content

PTH201 does not report redundant joins #10453

@tjkuson

Description

@tjkuson

Using path-constructor-current-directory (PTH201),

import pathlib


p = pathlib.Path(".") / "foo.txt"

is auto-fixed to

import pathlib


p = pathlib.Path() / "foo.txt"

by invoking ruff check --select PTH201 --fix --isolated /tmp/cwd.py using version 0.3.2.

The fix is correct. However, it would be more useful if it included the rest of the path (following the motivation of the rule, which is to reduce unnecessary explicit CWD specification). For example,

import pathlib


p = pathlib.Path("foo.txt")

Search terms: PTH201, current working directory, pathlib

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violationslinterRelated to the linter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions