From 0997b432d3c6bf532d66c26f10a9091d8da79a6b Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 5 Feb 2022 18:17:14 +0100 Subject: Trying to ban f-strings --- tests/pylint/py2_compat.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/pylint/py2_compat.py b/tests/pylint/py2_compat.py index 7e136148..e0353260 100644 --- a/tests/pylint/py2_compat.py +++ b/tests/pylint/py2_compat.py @@ -51,6 +51,9 @@ class Py2CompatibilityChecker(BaseChecker): "Python 2 subprocess.Popen objects were not contextmanagers," "popen23.Popen wraps them to enable use with" "with-statements."), + "E4240": ("Use format method", + "use-format-method", + "Python 2 (and <3.6) does not support f-strings."), } # This class variable declares the options # that are configurable by the user. @@ -121,6 +124,11 @@ class Py2CompatibilityChecker(BaseChecker): self.add_message("implicit-format-spec", node=node, confidence=HIGH) + def visit_joinedstr(self, node): + """Make sure we don't use f-strings""" + if isinstance(node, astroid.nodes.JoinedStr): + self.add_message("use-format-method", node=node, confidence=HIGH) + def visit_with(self, node): """Make sure subprocess.Popen objects aren't used in with-statements""" for (cm, _) in node.items: -- cgit 1.4.1-2-gfad0