Skip to content

Commit 69f822b

Browse files
authored
Merge pull request #1164 from PyCQA/fstring-repr
E225: fix false-positive in 3.12
2 parents f980a1c + eeeca60 commit 69f822b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pycodestyle.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,16 @@ def missing_whitespace(logical_line, tokens):
933933
"around %s operator" % (code, optype))
934934
need_space = False
935935
elif token_type in operator_types and prev_end is not None:
936-
if text == '=' and brace_stack and brace_stack[-1] in {'l', '('}:
937-
# Allow keyword args or defaults: foo(bar=None).
936+
if (
937+
text == '=' and (
938+
# allow lambda default args: lambda x=None: None
939+
brace_stack[-1:] == ['l'] or
940+
# allow keyword args or defaults: foo(bar=None).
941+
brace_stack[-1:] == ['('] or
942+
# allow python 3.8 fstring repr specifier
943+
brace_stack[-2:] == ['f', '{']
944+
)
945+
):
938946
pass
939947
elif text in WS_NEEDED_OPERATORS:
940948
need_space = True

testsuite/python38.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ def f3(
5959
#: E741
6060
if (l := 1):
6161
pass
62+
#: Okay
63+
f'{x=}'

0 commit comments

Comments
 (0)