mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-104799: PEP 695 backward compatibility for ast.unparse (GH-105846) (#105862)
(cherry picked from commit 957a974d4f
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
e6982c5860
commit
5ca707d1e4
3 changed files with 80 additions and 3 deletions
|
@ -1051,7 +1051,8 @@ class _Unparser(NodeVisitor):
|
|||
self.fill("@")
|
||||
self.traverse(deco)
|
||||
self.fill("class " + node.name)
|
||||
self._type_params_helper(node.type_params)
|
||||
if hasattr(node, "type_params"):
|
||||
self._type_params_helper(node.type_params)
|
||||
with self.delimit_if("(", ")", condition = node.bases or node.keywords):
|
||||
comma = False
|
||||
for e in node.bases:
|
||||
|
@ -1083,7 +1084,8 @@ class _Unparser(NodeVisitor):
|
|||
self.traverse(deco)
|
||||
def_str = fill_suffix + " " + node.name
|
||||
self.fill(def_str)
|
||||
self._type_params_helper(node.type_params)
|
||||
if hasattr(node, "type_params"):
|
||||
self._type_params_helper(node.type_params)
|
||||
with self.delimit("(", ")"):
|
||||
self.traverse(node.args)
|
||||
if node.returns:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue