mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-104799: PEP 695 backward compatibility for ast.unparse (#105846)
This commit is contained in:
parent
70c075c194
commit
957a974d4f
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