diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-08-30 07:57:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 07:57:05 +0200 |
commit | 66ffcbc4c59e41327be1a2b5ef65727bf0314aa9 (patch) | |
tree | 5b1f37a0ffadc2888f851337b36f75717ebf4c72 /tests/functional/l | |
parent | 1a19421058dcc04446f8b91a825ed1078959d87a (diff) | |
download | pylint-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')
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 |