Skip to content

On the use of None in named arguments #346

Description

@lgalfaso

The behaviour of many functions when sending None as one of the named arguments is many times under defined. There are cases that there are discrepancies between implementation.

Eg
The built-in function sorted has two named parameters, these are key and reverse. Both Bazel and Starlark-Go only accept bool values for reverse, producing the errors

Error in sorted: in call to sorted(), parameter 'reverse' got value of type 'NoneType', want 'bool'

and

sorted: for parameter "reverse": got NoneType, want bool

The same is not the case for the named parameter key. Bazel accepts key = None and behaves as if this were not present (ie the identity function), while Starlark-Go produces the error

sorted: for parameter "key": got NoneType, want callable

Should there be a convention defined in the spec on what is the behaviour when explicitly sending None as one of the named parameters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions