Skip to content

Conversation

@BvB93
Copy link
Contributor

@BvB93 BvB93 commented Sep 27, 2021

Xref #143 and numpy/numpy#19969.

Variadic parameters were previously all encapsulated in a Sequence type, implying that each individual parameter must be a Sequence (rather than the encapsulated type).

Examples

from typing import List

def func1(*args: List[int]) -> None: ...
func1([1], [2], [3])

def func2(*args: int) -> None: ...
func2(1, 2, 3)

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, that looks correct - but also counterintuitive, the annotation is a bit unhelpful as documentation.

It may be useful to then modify the sentences below each annotation to say "Sequence of ... arrays ..." for clarity.

@rgommers rgommers added the topic: Static Typing Static typing. label Sep 27, 2021
@BvB93
Copy link
Contributor Author

BvB93 commented Sep 27, 2021

It may be useful to then modify the sentences below each annotation to say "Sequence of ... arrays ..." for clarity.

I'm personally not huge fan of the term Sequence in this context.
The term Sequence works fine-ish if, for example, the input is passed via unpacking a list of arrays (out = func(*ar_list)),
but makes less sense if the arrays are explicitly passed as individual arguments (out = func(ar1, ar2, ar3)).

How about something along the lines of "variable" or "arbitrary" number of arrays?
I'd say this leaves less room for ambiguity.

@rgommers
Copy link
Member

How about something along the lines of "variable" or "arbitrary" number of arrays?
I'd say this leaves less room for ambiguity.

Yes that sounds great to me.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks @BvB93!

@rgommers rgommers merged commit 77a921a into data-apis:main Sep 28, 2021
@BvB93 BvB93 deleted the variadic branch September 28, 2021 17:50
@asmeurer
Copy link
Member

Actually better wording would be "one or more" instead of "an arbitrary number", since none of these functions accept zero arguments, even though the *args syntax would allow it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: Static Typing Static typing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants