Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

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: #646
Signed-off-by: Alfred Wingate <[email protected]>
  • Loading branch information
parona-source committed Nov 1, 2023
1 parent 6d5455e commit ea10780
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Release Notes
**pydocstyle** version numbers follow the
`Semantic Versioning <http://semver.org/>`_ specification.


Current development version
---------------------------

Bug Fixes

* Add support for PEP-701 fixing fstring parsing in python3.12 (#656).

6.3.0 - January 17th, 2023
--------------------------

Expand Down
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 ea10780

Please sign in to comment.