about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2022-02-05 18:17:14 +0100
committertoonn <toonn@toonn.io>2022-02-05 19:30:09 +0100
commit0997b432d3c6bf532d66c26f10a9091d8da79a6b (patch)
treeb73c2f714d5e1173ed32e04f75f7503da608db16
parentc744128d0775e9de9db73a4f2185037d6a42a92c (diff)
downloadranger-0997b432d3c6bf532d66c26f10a9091d8da79a6b.tar.gz
Trying to ban f-strings
-rw-r--r--tests/pylint/py2_compat.py8
1 files changed, 8 insertions, 0 deletions
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: