Skip to content

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

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

ntBre merged 2 commits into
astral-sh:mainfrom
Kalmaegi:doc_fix_safety_for_repeated_keys

Conversation

@Kalmaegi

@Kalmaegi Kalmaegi commented Apr 17, 2025 •

Copy link
Copy Markdown
Contributor

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 public-facing documentation label Apr 18, 2025

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Apr 18, 2025 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre

ntBre commented Apr 18, 2025

Copy link
Copy Markdown
Contributor

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
21 of 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to public-facing documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants