Allow f-strings with %z for DTZ007#10651
Merged
dhruvmanila merged 2 commits intomainfrom Mar 29, 2024
Merged
Conversation
dd10058 to
d637aa5
Compare
zanieb
reviewed
Mar 29, 2024
Comment on lines
+113
to
+114
| // TODO(dhruvmanila): This doesn't consider f-strings that are implicitly concatenated | ||
| // to strings. For example, `f"%Y-%m-%dT%H:%M:%S{('.%f' if millis else '')}" "%z"` |
Member
There was a problem hiding this comment.
Should we check in a test case for this anyway?
Member
Author
There was a problem hiding this comment.
Ruff will raise a violation in this case even though it shouldn't. Maybe checking string literal isn't too bad 🤔
Member
There was a problem hiding this comment.
I think it's fine to have an "incorrect" test case as long as it's clearly documented, then we have a test demonstrating the fix when you get to it.
Member
Author
There was a problem hiding this comment.
I see. I've added a commit which also checks for the implicitly concatenated case.
zanieb
approved these changes
Mar 29, 2024
Contributor
|
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
This PR fixes the bug for
DTZ007rule where it didn't consider to check for the presence of%zin f-strings. It also considers the string parts of an implicitly concatenated f-strings for which I want to find a better solution (#10308).fixes: #10601
Test Plan
Add test cases and update the snapshots.