Skip to content

Commit

Permalink
[Python] Fix string replacement fields (#3797)
Browse files Browse the repository at this point in the history
* [Python] Fix string replacement fields

Fixes #3649

This commit closely implements python's format string syntax.

see: https://docs.python.org/3.11/library/string.html#format-string-syntax

It means, replacement field names must be valid qualified identifiers, even
though python syntactically resolves all kinds of key names.

Replacement field termination is handled separately for each kind of quotation.

* [Python] Refactor f-strings

This commit ...

1. aligns implementation of f-string replacement fields with normal string
   replacements.

2. implements f-string replacements for each kind of quotation in order to
   correctly bailout at EOL or terminating quotation mark type.

   Note: Nested quotes are supported in replacement expressions only as of
         python 3.12. They keep unsupported in format-specs.

3. moves escaped braces back into f-string-replacements context and adjusts
   its include positions (moves them before normal `escaped-chars`).

4. removes `meta.format-spec` from `:` to align scoping with replacement fields
   in normal strings.

5. adds some tests to verify syntax being prepared for python 3.12
  • Loading branch information
deathaxe authored Jul 15, 2023
1 parent dd81bb8 commit 7e58014
Show file tree
Hide file tree
Showing 2 changed files with 843 additions and 206 deletions.
Loading

0 comments on commit 7e58014

Please sign in to comment.