Skip to content

[flake8-use-pathlib] Add fix safety section to PTH201#18837

Merged
dylwil3 merged 1 commit intoastral-sh:mainfrom
MeGaGiGaGon:fix-safety-section-path_constructor_current_directory
Jun 23, 2025
Merged

[flake8-use-pathlib] Add fix safety section to PTH201#18837
dylwil3 merged 1 commit intoastral-sh:mainfrom
MeGaGiGaGon:fix-safety-section-path_constructor_current_directory

Conversation

@MeGaGiGaGon
Copy link
Copy Markdown
Contributor

@MeGaGiGaGon MeGaGiGaGon commented Jun 20, 2025

Summary

Part of #15584

This adds a Fix safety section to path-constructor-current-directory (PTH201)

I could not track down the original PR as this rule is so old it has gone through several large ruff refactors.
The unsafety is determined here:

if checker.comment_ranges().intersects(range) {
Applicability::Unsafe
} else {
Applicability::Safe
}

Unsafe code example:
playground

from pathlib import Path
Path(#
    "."#
)

Test Plan

N/A, no tests/functionality affected

@MeGaGiGaGon MeGaGiGaGon mentioned this pull request Jun 20, 2025
71 tasks
@github-actions
Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser requested a review from dylwil3 June 21, 2025 16:18
Copy link
Copy Markdown
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you!

@dylwil3 dylwil3 merged commit ec07a0f into astral-sh:main Jun 23, 2025
35 checks passed
@dylwil3 dylwil3 added the documentation Improvements or additions to documentation label Jun 23, 2025
@MeGaGiGaGon MeGaGiGaGon deleted the fix-safety-section-path_constructor_current_directory branch June 23, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants