We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d1f3a0b commit 60a21f2Copy full SHA for 60a21f2
python/asthelper.py
@@ -90,10 +90,13 @@ def _handle_functions(self, node):
90
for arg in chain(node.args.args, node.args.kwonlyargs):
91
type_hint = None
92
if arg.annotation is not None:
93
- # ast.unparse doesn't work in python 3.8, needs to use astunparse instead
+ # ast.unparse doesn't work for python <= 3.8
94
if sys.version_info[0] == 3 and sys.version_info[1] == 8:
95
- import astunparse
96
- type_hint = astunparse.unparse(arg.annotation)
+ from unparse import Unparser
+ from io import StringIO
97
+ v = StringIO()
98
+ Unparser(arg.annotation, file=v)
99
+ type_hint = v.getvalue()
100
else:
101
type_hint = ast.unparse(arg.annotation)
102
self.arguments.append({"arg": arg.arg, "type": type_hint})
0 commit comments