From 8d0a4a18747dd7023a684123799f5773c49de0f3 Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Tue, 25 Apr 2023 10:50:41 -0400 Subject: [PATCH] Fix delayed log interpolation false positives Previously, we detected non-delayed string interpolation by checking for the presence of '.format'. This can turn up false positives, like '.format_message('. Fix this by checking for '.format('. Hacking version 6.0.0 got released with a bumped and fixed version of flake8 that started detecting pep8 errors lurking in code, but also started detecting these false positives, so once this patch is merged we'll need a new hacking release so that projects can correctly bump their hacking version. Change-Id: I49e12b0dedbfd7820984cc5393f9ca2f72be89cb --- hacking/checks/other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacking/checks/other.py b/hacking/checks/other.py index 923c7088..39fe6f56 100644 --- a/hacking/checks/other.py +++ b/hacking/checks/other.py @@ -55,5 +55,5 @@ def hacking_delayed_string_interpolation(logical_line, noqa): # There are some cases where string formatting of the arguments are # needed, so don't include those when checking. line = re.sub(r",.*", '', line) - if '%' in line or '.format' in line: + if '%' in line or '.format(' in line: yield 0, msg