summaryrefslogtreecommitdiffstats
path: root/Lib/ast.py
diff options
context:
space:
mode:
authorBatuhan Taşkaya <47358913+isidentical@users.noreply.github.com>2020-03-15 19:56:57 (GMT)
committerGitHub <noreply@github.com>2020-03-15 19:56:57 (GMT)
commit5b66ec166b81c8a77286da2c0d17be3579c3069a (patch)
treefb90f42e9e26438f995a56909b7b8f7d8dbfd39e /Lib/ast.py
parentac10e0c93218627d1a639db0b7b41714c5f6a883 (diff)
downloadcpython-5b66ec166b81c8a77286da2c0d17be3579c3069a.zip
cpython-5b66ec166b81c8a77286da2c0d17be3579c3069a.tar.gz
cpython-5b66ec166b81c8a77286da2c0d17be3579c3069a.tar.bz2
bpo-38870: Implement support for ast.FunctionType in ast.unparse (GH-19016)
Diffstat (limited to 'Lib/ast.py')
-rw-r--r--Lib/ast.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/ast.py b/Lib/ast.py
index 077eb92..e347d8b 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -741,6 +741,15 @@ class _Unparser(NodeVisitor):
def visit_Module(self, node):
self._write_docstring_and_traverse_body(node)
+ def visit_FunctionType(self, node):
+ with self.delimit("(", ")"):
+ self.interleave(
+ lambda: self.write(", "), self.traverse, node.argtypes
+ )
+
+ self.write(" -> ")
+ self.traverse(node.returns)
+
def visit_Expr(self, node):
self.fill()
self.set_precedence(_Precedence.YIELD, node.value)