Skip to content

Commit

Permalink
Add support for PEP701
Browse files Browse the repository at this point in the history
* fstring don't emit tk.STRING in python3.12, reattach the now separate
  tokens and pass them to Docstring preserving previous behavior.

Closes: PyCQA#646
Signed-off-by: Alfred Wingate <[email protected]>
  • Loading branch information
parona-source committed Nov 1, 2023
1 parent 6d5455e commit e969a9c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pydocstyle/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,20 @@ def parse_docstring(self):
)
self.stream.move()
return docstring
if (sys.version_info.major, sys.version_info.minor) >= (
3,
12,
) and self.current.kind == tk.FSTRING_START:
# Reattach fstring tokens together to deal with PEP 701 in python3.12
value = self.current.value
start = self.current.start[0]
while self.current.kind != tk.FSTRING_END:
self.stream.move()
value += self.current.value
end = self.current.end[0]
docstring = Docstring(value, start, end)
self.stream.move()
return docstring
return None

def parse_decorators(self):
Expand Down

0 comments on commit e969a9c

Please sign in to comment.