Skip to content

[pyflakes] Add fix safety section to docs (F601, F602)#17440

Merged
ntBre merged 2 commits intoastral-sh:mainfrom
Kalmaegi:doc_fix_safety_for_repeated_keys
Apr 18, 2025
Merged

[pyflakes] Add fix safety section to docs (F601, F602)#17440
ntBre merged 2 commits intoastral-sh:mainfrom
Kalmaegi:doc_fix_safety_for_repeated_keys

Conversation

@Kalmaegi
Copy link
Contributor

@Kalmaegi Kalmaegi commented Apr 17, 2025

Summary

add fix safety section to repeated_keys_docs, for #15584

@ntBre ntBre self-assigned this Apr 18, 2025
@ntBre ntBre added the documentation Improvements or additions to documentation label Apr 18, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thanks! I also tested this one, and it definitely removes comments.

It could also technically be unsafe if the values have side effects:

foo = {
    2: print(2),
    2: print(2),
}

The rule only offers a fix if the values are equal, but it doesn't consider potential side effects.

I think mentioning the comments is sufficient, though. This example is pretty contrived, and the comment case seems most common.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 18, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre
Copy link
Contributor

ntBre commented Apr 18, 2025

On second thought, I went ahead and added the mention of side effects, just in case. I'll merge once CI finishes!

@ntBre ntBre changed the title add fix safety section to docs [pyflakes] Add fix safety section to docs (F601, F602) Apr 18, 2025
@ntBre ntBre mentioned this pull request Apr 18, 2025
71 tasks
@ntBre ntBre enabled auto-merge (squash) April 18, 2025 18:26
@ntBre ntBre merged commit fd3fc34 into astral-sh:main Apr 18, 2025
20 checks passed
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