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/pyreverse/utils.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/pyreverse/utils.py')
-rw-r--r-- | pylint/pyreverse/utils.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pylint/pyreverse/utils.py b/pylint/pyreverse/utils.py index b68073a26..71702febf 100644 --- a/pylint/pyreverse/utils.py +++ b/pylint/pyreverse/utils.py @@ -131,7 +131,7 @@ class FilterMixIn: try: __mode += MODES[nummod] except KeyError as ex: - print("Unknown filter mode %s" % ex, file=sys.stderr) + print(f"Unknown filter mode {ex}", file=sys.stderr) self.__mode = __mode def show_attr(self, node): @@ -176,10 +176,10 @@ class ASTWalker: handler = self.handler kid = klass.__name__.lower() e_method = getattr( - handler, "visit_%s" % kid, getattr(handler, "visit_default", None) + handler, f"visit_{kid}", getattr(handler, "visit_default", None) ) l_method = getattr( - handler, "leave_%s" % kid, getattr(handler, "leave_default", None) + handler, f"leave_{kid}", getattr(handler, "leave_default", None) ) self._cache[klass] = (e_method, l_method) else: @@ -257,7 +257,7 @@ def get_annotation( label = get_annotation_label(ann) if ann: label = ( - rf"Optional[{label}]" + fr"Optional[{label}]" if getattr(default, "value", "value") is None and not label.startswith("Optional") else label |