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

Commit

Permalink
Add comment to explain that a nil or missing return field doesnt mean…
Browse files Browse the repository at this point in the history
… that the function returns None

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
  • Loading branch information
Juanjo Alvarez committed Feb 15, 2019
1 parent 6fcd35d commit abf0e5a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion driver/normalizer/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func funcDefMap(typ string, async bool) Mapping {
uast.KeyPos: Var("_pos"),
uast.KeyType: Var("_type"),
}},
// Will be filled only if there is a Python3 type annotation
// Will be filled only if there is a Python3 type annotation. If the field is
// missing or the value is nil it DOESNT mean that the function returns None,
// just that there is no annotation (but the function could still return some
// other type!).
{Name: "returns", Optional: "ret_opt", Op: Cases("ret_case",
Is(nil),
Obj{
Expand Down Expand Up @@ -73,6 +76,8 @@ func funcDefMap(typ string, async bool) Mapping {
"Type": UASTType(uast.FunctionType{}, Fields{
{Name: "Arguments", Op: Var("arguments")},
{Name: "Returns", Optional: "ret_opt", Op: Cases("ret_case",
// Dont add None here as default, read the comment on the upper
// side of the annotation
Is(nil),
Arr(UASTType(uast.Argument{},
Obj{
Expand Down

0 comments on commit abf0e5a

Please sign in to comment.