-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow f-strings with %z
for DTZ007
#10651
Conversation
dd10058
to
d637aa5
Compare
// 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"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check in a test case for this anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruff will raise a violation in this case even though it shouldn't. Maybe checking string literal isn't too bad 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I've added a commit which also checks for the implicitly concatenated case.
|
Summary
This PR fixes the bug for
DTZ007
rule where it didn't consider to check for the presence of%z
in 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.