[flake8-pyi] Mark fix as unsafe when type annotation contains comments for duplicate-literal-member (PYI062)#14268
Merged
AlexWaygood merged 1 commit intoastral-sh:mainfrom Nov 11, 2024
Conversation
…nts for `duplicate-literal-member` (`PYI062`)
AlexWaygood
reviewed
Nov 11, 2024
crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs
Show resolved
Hide resolved
Comment on lines
+99
to
+106
| let fix = Fix::applicable_edit( | ||
| Edit::range_replacement(checker.generator().expr(&subscript), expr.range()), | ||
| if checker.comment_ranges().intersects(expr.range()) { | ||
| Applicability::Unsafe | ||
| } else { | ||
| Applicability::Safe | ||
| }, | ||
| ); |
Member
There was a problem hiding this comment.
Thanks. While I've never seen comments inside a Literal annotation in "real life", this does seem to align with the rough consensus in #9790. So this change seems good to me.
Contributor
Author
There was a problem hiding this comment.
I agree it's very rare. My primary motivation for this type of changes is to give the right example for future uses. While developing new rules we often take existing rules as base, and being rigorous now might prevent issues in future rules where the comments do matter.
Contributor
|
AlexWaygood
approved these changes
Nov 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Correctly mark fix as unsafe when comments are present within the annotation.
Test Plan
Added a test case