Skip to content

Commit f8410f9

Browse files
[feat] Detect missing formatting args when the string is not interpolated too
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. Co-authored by: Alex Prabhat Bara <[email protected]>
1 parent 3b9e2d2 commit f8410f9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
We now raise a ``logging-too-few-args`` when there's no interpolation at all (i.e. ``logging.debug("Awaiting process %s")``).
2+
Previously we did not raise for such case (voluntarily).
3+
4+
Closes #9999

pylint/checkers/logging.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,6 @@ def _check_format_string(self, node: nodes.Call, format_arg: Literal[0, 1]) -> N
326326
format_arg: Index of the format string in the node arguments.
327327
"""
328328
num_args = _count_supplied_tokens(node.args[format_arg + 1 :])
329-
if not num_args:
330-
# If no args were supplied the string is not interpolated and can contain
331-
# formatting characters - it's used verbatim. Don't check any further.
332-
return
333-
334329
format_string = node.args[format_arg].value
335330
required_num_args = 0
336331
if isinstance(format_string, bytes):

0 commit comments

Comments
 (0)