[flake8-use-pathlib] Add an autofix for the last path component (PTH206) by jinchuntan · Pull Request #29454 · astral-sh/ruff · GitHub
Skip to content

[flake8-use-pathlib] Add an autofix for the last path component (PTH206) - #29454

Closed
jinchuntan wants to merge 1 commit into
astral-sh:mainfrom
jinchuntan:feat/pth206-name-fix
Closed

jinchuntan wants to merge 1 commit into
astral-sh:mainfrom
jinchuntan:feat/pth206-name-fix

Conversation

@jinchuntan

Copy link
Copy Markdown

Adds a preview autofix for PTH206 that replaces path.split(os.sep)[-1] with Path(path).name. The fix is unsafe because Path normalizes trailing separators and . components so the result can change. Other indices and assignment targets stay unfixed. Includes regression coverage for aliases and parenthesized expressions. All 34 pathlib tests and 3 regression suites pass. Related to #2331.

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre October 18, 2026 01:58
@ntBre ntBre added the bot:ai-policy-close Auto-close a PR due to a violation of the org AI policy label Oct 19, 2026
@astral-sh-bot

astral-sh-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

@astral-sh-bot astral-sh-bot Bot closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ai-policy-close Auto-close a PR due to a violation of the org AI policy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants