summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYilei "Dolee" Yang <yileiyang@google.com>2023-04-07 00:06:54 -0700
committerDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2023-04-07 09:31:39 +0200
commit011c6ac1a4efa41ce82fb230ca06f97ae50d662e (patch)
treee29b38f941f90ce535b15cf61320843d02c7e7c4 /tests
parent84d495968cebf368c69932f538ba8d7d2f0bdbd9 (diff)
downloadpylint-git-011c6ac1a4efa41ce82fb230ca06f97ae50d662e.tar.gz
Do not emit `logging-not-lazy` for explicitly concatenated strings. (#8546)
(cherry picked from commit eeddd667a6e73ef58fb47cdda154c1751f0ffe71)
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/l/logging/logging_not_lazy.py7
-rw-r--r--tests/functional/l/logging/logging_not_lazy.txt12
2 files changed, 12 insertions, 7 deletions
diff --git a/tests/functional/l/logging/logging_not_lazy.py b/tests/functional/l/logging/logging_not_lazy.py
index ab1ce008c..aa2401dbc 100644
--- a/tests/functional/l/logging/logging_not_lazy.py
+++ b/tests/functional/l/logging/logging_not_lazy.py
@@ -9,10 +9,10 @@ var = "123"
var_name = "Var:"
# Statements that should be flagged:
renamed_logging.warn("%s, %s" % (4, 5)) # [logging-not-lazy]
+renamed_logging.warn("Var: " + var) # [logging-not-lazy]
renamed_logging.exception("%s" % "Exceptional!") # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, "msg: %s" % "Run!") # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, "Var: " + var) # [logging-not-lazy]
-renamed_logging.warn("%s" + " the rest of a single string") # [logging-not-lazy]
renamed_logging.log(renamed_logging.INFO, var_name + var) # [logging-not-lazy]
# Statements that should not be flagged:
@@ -21,6 +21,11 @@ renamed_logging.log(renamed_logging.INFO, "msg: %s", "Run!")
logging.warn("%s, %s" % (4, 5))
logging.log(logging.INFO, "msg: %s" % "Run!")
logging.log("Var: " + var)
+# Explicit string concatenations are fine:
+renamed_logging.warn("%s" + " the rest of a single string")
+renamed_logging.warn("Msg: " + "%s", "first piece " + "second piece")
+renamed_logging.warn("first" + "second" + "third %s", "parameter")
+renamed_logging.warn(("first" + "second" + "third %s"))
# Regression crash test for incorrect format call
renamed_logging.error(
diff --git a/tests/functional/l/logging/logging_not_lazy.txt b/tests/functional/l/logging/logging_not_lazy.txt
index 564fa65c3..774082eb7 100644
--- a/tests/functional/l/logging/logging_not_lazy.txt
+++ b/tests/functional/l/logging/logging_not_lazy.txt
@@ -1,8 +1,8 @@
logging-not-lazy:11:0:11:39::Use lazy % formatting in logging functions:UNDEFINED
-logging-not-lazy:12:0:12:48::Use lazy % formatting in logging functions:UNDEFINED
-logging-not-lazy:13:0:13:61::Use lazy % formatting in logging functions:UNDEFINED
-logging-not-lazy:14:0:14:56::Use lazy % formatting in logging functions:UNDEFINED
-logging-not-lazy:15:0:15:59::Use lazy % formatting in logging functions:UNDEFINED
+logging-not-lazy:12:0:12:35::Use lazy % formatting in logging functions:UNDEFINED
+logging-not-lazy:13:0:13:48::Use lazy % formatting in logging functions:UNDEFINED
+logging-not-lazy:14:0:14:61::Use lazy % formatting in logging functions:UNDEFINED
+logging-not-lazy:15:0:15:56::Use lazy % formatting in logging functions:UNDEFINED
logging-not-lazy:16:0:16:57::Use lazy % formatting in logging functions:UNDEFINED
-bad-format-string:27:4:27:27::Invalid format string:UNDEFINED
-logging-format-interpolation:27:4:27:27::Use lazy % formatting in logging functions:UNDEFINED
+bad-format-string:32:4:32:27::Invalid format string:UNDEFINED
+logging-format-interpolation:32:4:32:27::Use lazy % formatting in logging functions:UNDEFINED