Skip to content

False negative for invalid-pathlib-with-suffix (PTH210) if method called on direct instantiation #19329

Open
@dylwil3

Description

@dylwil3

Summary

False negatives are understandable here if we can't be sure that an object is a Path object - but the below false negative seems silly because we are in a situation where we should be even more confident that we have a Path object!

from pathlib import Path

path = Path()

path.with_suffix("py") # PTH210

Path().with_suffix("py") # no lint

Playground link

Version

ruff 0.12.3 (5bc81f2 2025-07-11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions