-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Detect missing arguments in logging format strings #10108
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
Conversation
This comment has been minimized.
This comment has been minimized.
Those home assistant warnings are actual issues, this is looking very good. |
@@ -326,10 +326,6 @@ def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> N | |||
format_arg: Index of the format string in the node arguments. | |||
""" | |||
num_args = _count_supplied_tokens(node.args[format_arg + 1 :]) | |||
if not num_args: | |||
# If no args were supplied the string is not interpolated and can contain | |||
# formatting characters - it's used verbatim. Don't check any further. |
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.
It seems to be voluntary though. Might need a dΓ©cision
π€ Effect of this PR on checked open source code: π€ Effect on home-assistant:
This comment was generated for commit fe1792b |
The original decision was taken in db8b3a4 during implementation with a different rational ("If no args were supplied, then all format strings are valid don't check any further.") and was not discussed again when the comment was updated in #2713. I think the new behavior make sense especially considering that the primer shows 4 false negative in home-assistant. I'm going to open a new merge request as this branch was deleted. |
Type of Changes
Description
This PR raises logging-too-few-args when the logging message contains placeholders but no arguments are provided as suggested by @zenlyj here: #9999 (comment)
Closes #9999