Skip to content

os-path-commonprefix (RUF071): update documentation #24028

@bersbersbers

Description

@bersbersbers

RUF071 recommends using os.path.commonpath over os.path.commonprefix. However, that is not always desirable, and sometimes even incorrect. The documentation should cover the differences in semantics as well as cases where RUF071 should be ignored.

This rule's recommendation is confusing for those using os.path.commonprefix with non-path strings (which I think is perfectly legitimate):

>> commonprefix(["123", "124"])
'12'
>> commonpath(["123", "124"])
''

I am not sure of the status of a string.commonprefix method in Python 3.15, but I think ruff's wording should be more carefully consider use cases such the one above.

Originally posted by @bersbersbers in #22981

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions