Skip to content

[refurb] Add fix safety section to FURB122#18842

Merged
dylwil3 merged 2 commits intoastral-sh:mainfrom
MeGaGiGaGon:patch-4
Jun 23, 2025
Merged

[refurb] Add fix safety section to FURB122#18842
dylwil3 merged 2 commits intoastral-sh:mainfrom
MeGaGiGaGon:patch-4

Conversation

@MeGaGiGaGon
Copy link
Copy Markdown
Contributor

Summary

Part of #15584

This adds a Fix safety section to for-loop-writes (FURB122).

The fix/lint was introduced in #10630
No reasoning is given on the unsafety in the PR/code.
The unsafety is determined here:

let applicability = if checker.comment_ranges().intersects(for_stmt.range) {
Applicability::Unsafe
} else {
Applicability::Safe
};

Unsafe fix demonstration:
playground

with open("issue.txt", "w") as f:
    for i in range(10):
        # will be deleted
        f.write(str(i))

Test Plan

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

github-actions bot commented Jun 21, 2025

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 15:38
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.

Thank you!

@dylwil3 dylwil3 enabled auto-merge (squash) June 23, 2025 13:18
@dylwil3 dylwil3 merged commit 861dff1 into astral-sh:main Jun 23, 2025
31 checks passed
@dylwil3 dylwil3 added the documentation Improvements or additions to documentation label Jun 23, 2025
@MeGaGiGaGon MeGaGiGaGon deleted the patch-4 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