summaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
authorYilei "Dolee" Yang <yileiyang@google.com>2023-04-07 00:06:54 -0700
committerGitHub <noreply@github.com>2023-04-07 09:06:54 +0200
commiteeddd667a6e73ef58fb47cdda154c1751f0ffe71 (patch)
tree64faa879c44721b2e5a1ddf5319a1c513b34de8e /tests/functional
parent156da64d0fb4c06e15c5b619b91ce550d594a770 (diff)
downloadpylint-git-eeddd667a6e73ef58fb47cdda154c1751f0ffe71.tar.gz
Do not emit `logging-not-lazy` for explicitly concatenated strings. (#8546)
Diffstat (limited to 'tests/functional')
-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