summaryrefslogtreecommitdiff
path: root/tests/functional/l
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-08-30 07:57:05 +0200
committerGitHub <noreply@github.com>2021-08-30 07:57:05 +0200
commit66ffcbc4c59e41327be1a2b5ef65727bf0314aa9 (patch)
tree5b1f37a0ffadc2888f851337b36f75717ebf4c72 /tests/functional/l
parent1a19421058dcc04446f8b91a825ed1078959d87a (diff)
downloadpylint-git-66ffcbc4c59e41327be1a2b5ef65727bf0314aa9.tar.gz
Add ``Consider-using-f-string`` checker (#4796)
* Add ``consider-using-f-string`` checker This adds a checker for normal strings which are formatted with ``.format()`` or '%'. The message is a convention to nudge users towards using f-strings. This closes #3592 * Update pylint code to use f-strings After adding `consider-using-f-strings` the codebase showed numerous cases of formatting which could be f-strings. This commit changes most of these to become f-strings, or adds ignores. * Apply suggestions from code review Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/functional/l')
-rw-r--r--tests/functional/l/logging_format_interpolation.py2
-rw-r--r--tests/functional/l/logging_not_lazy.py3
-rw-r--r--tests/functional/l/logging_not_lazy_with_logger.py1
-rw-r--r--tests/functional/l/logging_not_lazy_with_logger.txt6
4 files changed, 6 insertions, 6 deletions
diff --git a/tests/functional/l/logging_format_interpolation.py b/tests/functional/l/logging_format_interpolation.py
index 8defa940b..782e3834b 100644
--- a/tests/functional/l/logging_format_interpolation.py
+++ b/tests/functional/l/logging_format_interpolation.py
@@ -1,5 +1,5 @@
# pylint: disable=no-member, no-absolute-import, import-error,line-too-long
-# pylint: disable=invalid-name,missing-docstring,wrong-import-order,wrong-import-position
+# pylint: disable=invalid-name,missing-docstring,wrong-import-order,wrong-import-position, consider-using-f-string
try:
import __builtin__ as builtins
except ImportError:
diff --git a/tests/functional/l/logging_not_lazy.py b/tests/functional/l/logging_not_lazy.py
index c0634327f..28aa3b783 100644
--- a/tests/functional/l/logging_not_lazy.py
+++ b/tests/functional/l/logging_not_lazy.py
@@ -1,4 +1,4 @@
-# pylint: disable=missing-docstring,no-member,deprecated-method,invalid-name
+# pylint: disable=missing-docstring,no-member,deprecated-method,invalid-name, consider-using-f-string
# Muck up the names in an effort to confuse...
import logging as renamed_logging
@@ -14,7 +14,6 @@ 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]
-var_name = 'Var:'
# Statements that should not be flagged:
renamed_logging.warn('%s, %s', 4, 5)
renamed_logging.log(renamed_logging.INFO, 'msg: %s', 'Run!')
diff --git a/tests/functional/l/logging_not_lazy_with_logger.py b/tests/functional/l/logging_not_lazy_with_logger.py
index ef2221f23..69d0e9bd4 100644
--- a/tests/functional/l/logging_not_lazy_with_logger.py
+++ b/tests/functional/l/logging_not_lazy_with_logger.py
@@ -1,4 +1,5 @@
"""Logging warnings using a logger class."""
+# pylint: disable=consider-using-f-string
from __future__ import absolute_import
import logging
diff --git a/tests/functional/l/logging_not_lazy_with_logger.txt b/tests/functional/l/logging_not_lazy_with_logger.txt
index 31fe45c6d..43d9c1620 100644
--- a/tests/functional/l/logging_not_lazy_with_logger.txt
+++ b/tests/functional/l/logging_not_lazy_with_logger.txt
@@ -1,4 +1,4 @@
-logging-not-lazy:8:0::Use lazy % formatting in logging functions
logging-not-lazy:9:0::Use lazy % formatting in logging functions
-logging-not-lazy:11:0::Use lazy % formatting in logging functions
-logging-not-lazy:13:0::Use lazy % formatting in logging functions
+logging-not-lazy:10:0::Use lazy % formatting in logging functions
+logging-not-lazy:12:0::Use lazy % formatting in logging functions
+logging-not-lazy:14:0::Use lazy % formatting in logging functions