Skip to content

Commit

Permalink
Fix new mypy error in blib2to3 (psf#3674)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed May 3, 2023
1 parent e712e48 commit a07871b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/blib2to3/pgen2/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def _combinations(*l):
'"""': double3prog,
**{f"{prefix}'''": single3prog for prefix in _strprefixes},
**{f'{prefix}"""': double3prog for prefix in _strprefixes},
**{prefix: None for prefix in _strprefixes},
}

triple_quoted: Final = (
Expand Down Expand Up @@ -599,11 +598,13 @@ def generate_tokens(
):
if token[-1] == "\n": # continued string
strstart = (lnum, start)
endprog = (
endprogs[initial]
or endprogs[token[1]]
or endprogs[token[2]]
maybe_endprog = (
endprogs.get(initial)
or endprogs.get(token[1])
or endprogs.get(token[2])
)
assert maybe_endprog is not None, f"endprog not found for {token}"
endprog = maybe_endprog
contstr, needcont = line[start:], 1
contline = line
break
Expand Down
4 changes: 4 additions & 0 deletions tests/data/simple_cases/fstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
f"\"{f'{nested} inner'}\" outer"
f"space between opening braces: { {a for a in (1, 2, 3)}}"
f'Hello \'{tricky + "example"}\''
f"Tried directories {str(rootdirs)} \
but none started with prefix {parentdir_prefix}"

# output

Expand All @@ -19,3 +21,5 @@
f"\"{f'{nested} inner'}\" outer"
f"space between opening braces: { {a for a in (1, 2, 3)}}"
f'Hello \'{tricky + "example"}\''
f"Tried directories {str(rootdirs)} \
but none started with prefix {parentdir_prefix}"

0 comments on commit a07871b

Please sign in to comment.