diff --git a/pasta/base/annotate.py b/pasta/base/annotate.py index c87b8ce..02a9c34 100644 --- a/pasta/base/annotate.py +++ b/pasta/base/annotate.py @@ -1496,6 +1496,8 @@ def check_slice_includes_step(self, node): def visit_FormattedValue(self, node): self.visit(node.value) if node.conversion != -1: + # If we have a self-documenting token, eat the '=' (see https://docs.python.org/3/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging) + self.optional_token(node, 'self_documenting', '=') self.attr( node, 'conversion', [self.ws, '!', chr(node.conversion)], diff --git a/testdata/ast/fstring.in b/testdata/ast/fstring.in index 684eb21..5cc6fa5 100644 --- a/testdata/ast/fstring.in +++ b/testdata/ast/fstring.in @@ -50,3 +50,11 @@ f""" j ) """ + +f'{k=}' + +f'{l=!s}' + +f'{m =:.3f}' + +f'{n=} l'