Skip to content

New flake8-pathlib rule: os.listdir (PTH208) #14490

Closed
@sbrugman

Description

@sbrugman

The pathlib rules supported by ruff could be extended with detection with os.listdir:

import os
from pathlib import Path

p = Path(".")
print(os.listdir(p))

use instead:

from pathlib import Path

p = Path(".")
print(list(p.iterdir()))

The plugin has not been updated for two years. We've extended the plugin rules before using the PTH2XX code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing 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