Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit abf0e5a

Browse files
author
Juanjo Alvarez
committed
Add comment to explain that a nil or missing return field doesnt mean that the function returns None
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 6fcd35d commit abf0e5a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

driver/normalizer/normalizer.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ func funcDefMap(typ string, async bool) Mapping {
3737
uast.KeyPos: Var("_pos"),
3838
uast.KeyType: Var("_type"),
3939
}},
40-
// Will be filled only if there is a Python3 type annotation
40+
// Will be filled only if there is a Python3 type annotation. If the field is
41+
// missing or the value is nil it DOESNT mean that the function returns None,
42+
// just that there is no annotation (but the function could still return some
43+
// other type!).
4144
{Name: "returns", Optional: "ret_opt", Op: Cases("ret_case",
4245
Is(nil),
4346
Obj{
@@ -73,6 +76,8 @@ func funcDefMap(typ string, async bool) Mapping {
7376
"Type": UASTType(uast.FunctionType{}, Fields{
7477
{Name: "Arguments", Op: Var("arguments")},
7578
{Name: "Returns", Optional: "ret_opt", Op: Cases("ret_case",
79+
// Dont add None here as default, read the comment on the upper
80+
// side of the annotation
7681
Is(nil),
7782
Arr(UASTType(uast.Argument{},
7883
Obj{

0 commit comments

Comments
 (0)