From 769e198ab006c5d899c4a09f99c4908c547f180d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 13 Jun 2020 22:01:21 -0700 Subject: [PATCH] lint: Prohibit percent formatting on literal format strings. Signed-off-by: Anders Kaseorg --- tools/semgrep.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/semgrep.yml b/tools/semgrep.yml index fbe63de40f..5f4d2eafd8 100644 --- a/tools/semgrep.yml +++ b/tools/semgrep.yml @@ -116,3 +116,11 @@ rules: ... severity: ERROR message: "Guard mutable default with read-only type (Sequence, Mapping, AbstractSet)" + + - id: percent-formatting + languages: [python] + pattern-either: + - pattern: '"..." % ...' + - pattern: '("...") % ...' + severity: ERROR + message: "Prefer f-strings or .format for string formatting"