-
Notifications
You must be signed in to change notification settings - Fork 32
Create rule S7946: Logging statements should use lazy evaluation to avoid performance overhead #5551
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
base: master
Are you sure you want to change the base?
Conversation
|
|
rules/S7946/python/rule.adoc
Outdated
| return template.format(**kwargs) | ||
|
|
||
| # Easy to forget the formatter | ||
| logging.info("User {action}: {amount:.2f} {item}") # Noncompliant |
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.
Is this meant to be a f-string or template string?
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 would make sense to be either of them. But this whole example is really bad I will rewrite 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.
Thinking about I am not sure how much we could detect if it is a t-string that is passed to a function and then used in a logging.xxxx method.
|
I have rewrote the rule to make more sense sadly this rule does not apply to Python 3.14 anymore. |
|
|





You can preview this rule here (updated a few minutes after each push).
Review
A dedicated reviewer checked the rule description successfully for: