Skip to content

Commit 2a9f128

Browse files
committed
parse return type hint
1 parent 5526c7a commit 2a9f128

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

parsers/parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,13 @@ def parse_returns(self, contents):
599599
if len(match) == 0:
600600
return None
601601

602+
hint = re.search(r'^\s*def \w*\(.*\)\s*->\s*(.*):', contents)
603+
if hint:
604+
hint = hint.group(1)
605+
602606
match = match[0]
603607
return_type = match[0] + 's'
604-
return_value_type = guess_type_from_value(match[1])
608+
return_value_type = hint or guess_type_from_value(match[1])
605609

606610
return (return_type, {'type': return_value_type})
607611

0 commit comments

Comments
 (0)