Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Do not use types for *args, **kwargs #585

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

timhoffm
Copy link
Contributor

@timhoffm timhoffm commented Oct 16, 2024

Docstrings are primarily intended for the caller, and there *args, **kwargs are not variables with a type but a signature pattern (this is also hinted at by using *args, **kwargs instead of args, kwargs as parameter names). It's rather confusing to try and type them, I'd even claim it's misleading and will tempt less experienced programmers to call def func(*args) with *args declared as tuple with a single tuple argument func((1, 2, 3)).

This omission is also not an information loss for the few people, who look at the signature from the function body perspective (aka developers). That args and kwargs resolve to a tuple / dict in the function is a hard-coded fact.

Docstrings are primarily intended for the caller, and there *args, **kwargs are not variables with a type but a signature pattern (this is also hinted at by using *args, **kwargs instead of args, kwargs as parameter names). It's rather confusing to try and type them, I'd even claim it's misleading and will tempt less experienced programmers to call `def func(*args)` with *args declared as tuple with a single tuple argument `func((1, 2, 3))`.

This omission is also not an information loss for the few people, who look at the signature from the function body perspective (aka developers). That args and kwargs resolve to a tuple / dict in the function is a hard-coded fact.
Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

This makes sense to me, thanks @timhoffm .

Also - FWIW the test failures appear to be related to a change in sphinx 8.1 and are unrelated to these changes.

@larsoner
Copy link
Collaborator

Merged main into this branch and marking for merge-when-green, thanks in advance @timhoffm !

@larsoner larsoner merged commit 2af51f7 into numpy:main Oct 17, 2024
25 of 26 checks passed
@stefanv stefanv added this to the 1.9.0 milestone Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants