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
This commit is contained in:
Artom Lifshitz 2023-04-25 10:50:41 -04:00
parent 3fde1e570a
commit 8d0a4a1874
1 changed files with 1 additions and 1 deletions

View File

@ -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