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 /pylint/checkers/raw_metrics.py | |
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 'pylint/checkers/raw_metrics.py')
-rw-r--r-- | pylint/checkers/raw_metrics.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pylint/checkers/raw_metrics.py b/pylint/checkers/raw_metrics.py index 22bd096cb..eb3f717ff 100644 --- a/pylint/checkers/raw_metrics.py +++ b/pylint/checkers/raw_metrics.py @@ -29,7 +29,7 @@ def report_raw_stats(sect, stats, old_stats): total_lines = stats["total_lines"] if not total_lines: raise EmptyReportError() - sect.description = "%s lines have been analyzed" % total_lines + sect.description = f"{total_lines} lines have been analyzed" lines = ("type", "number", "%", "previous", "difference") for node_type in ("code", "docstring", "comment", "empty"): key = node_type + "_lines" @@ -40,7 +40,7 @@ def report_raw_stats(sect, stats, old_stats): diff_str = diff_string(old, total) else: old, diff_str = "NC", "NC" - lines += (node_type, str(total), "%.2f" % percent, str(old), diff_str) + lines += (node_type, str(total), f"{percent:.2f}", str(old), diff_str) sect.append(Table(children=lines, cols=5, rheaders=1)) |