Skip to content

Commit

Permalink
de-duplicate the two regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsadhwani committed Jul 31, 2024
1 parent d84c837 commit b3f17f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/blib2to3/pgen2/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def _combinations(*l: str) -> Set[str]:
)

# beginning of a single quoted f-string. must not end with `{{` or `\N{`
SingleLbrace = r"(?:\\N{|\\[^{]|{{|[^'\\{])*(?<!\\N){(?!{)"
DoubleLbrace = r'(?:\\N{|\\[^{]|{{|[^"\\{])*(?<!\\N){(?!{)'
SingleLbrace = r"(?:\\N{|\\[^{]|{{|[^\n'\\{])*(?<!\\N)({)(?!{)"
DoubleLbrace = r'(?:\\N{|\\[^{]|{{|[^\n"\\{])*(?<!\\N)({)(?!{)'

# beginning of a triple quoted f-string. must not end with `{{` or `\N{`
Single3Lbrace = r"(?:\\N{|\\[^{]|{{|'(?!'')|[^'{\\])*(?<!\\N){(?!{)"
Expand Down Expand Up @@ -175,8 +175,8 @@ def _combinations(*l: str) -> Set[str]:
_string_middle_double = r'(?:[^\n"\\]|\\.)*'

# FSTRING_MIDDLE and LBRACE, must not end with a `{{` or `\N{`
_fstring_middle_single = r"(?:\\N{|\\[^{]|{{|[^\n'{\\])*(?<!\\N)({)(?!{)"
_fstring_middle_double = r'(?:\\N{|\\[^{]|{{|[^\n"{\\])*(?<!\\N)({)(?!{)'
_fstring_middle_single = SingleLbrace
_fstring_middle_double = DoubleLbrace

# First (or only) line of ' or " string.
ContStr = group(
Expand Down

0 comments on commit b3f17f4

Please sign in to comment.