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/message/message_definition.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/message/message_definition.py')
-rw-r--r-- | pylint/message/message_definition.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pylint/message/message_definition.py b/pylint/message/message_definition.py index a48526e9b..f7f680590 100644 --- a/pylint/message/message_definition.py +++ b/pylint/message/message_definition.py @@ -64,24 +64,24 @@ class MessageDefinition: """return the help string for the given message id""" desc = self.description if checkerref: - desc += " This message belongs to the %s checker." % self.checker_name + desc += f" This message belongs to the {self.checker_name} checker." title = self.msg if self.minversion or self.maxversion: restr = [] if self.minversion: - restr.append("< %s" % ".".join(str(n) for n in self.minversion)) + restr.append(f"< {'.'.join(str(n) for n in self.minversion)}") if self.maxversion: - restr.append(">= %s" % ".".join(str(n) for n in self.maxversion)) + restr.append(f">= {'.'.join(str(n) for n in self.maxversion)}") restriction = " or ".join(restr) if checkerref: - desc += " It can't be emitted when using Python %s." % restriction + desc += f" It can't be emitted when using Python {restriction}." else: desc += ( - " This message can't be emitted when using Python %s." % restriction + f" This message can't be emitted when using Python {restriction}." ) msg_help = normalize_text(" ".join(desc.split()), indent=" ") message_id = f"{self.symbol} ({self.msgid})" if title != "%s": title = title.splitlines()[0] - return ":{}: *{}*\n{}".format(message_id, title.rstrip(" "), msg_help) + return f":{message_id}: *{title.rstrip(' ')}*\n{msg_help}" return f":{message_id}:\n{msg_help}" |