Repository navigation
gh-161591: sync inspect.signature() docs with actual function signature - #161594
skirpichev wants to merge 3 commits into
Conversation
Documentation build overview
|
|
I prefer sphinx's version of the argument name. But renaming would introduce API break (though hardly it's severe), not sure if it worth. Kept changes minimal, per issue description. But in fact many singnatures in the inspect module are out of sync with the real code and/or just invalid. Examples: .. function:: getmembers(object[, predicate])
[...]
.. function:: getmembers_static(object[, predicate])
[...]I would prefer to fix all in one shot, in this pr, if reviewers support this. CC @sobolevn |
|
I suggest you fix the docs properly even if naming is a bit.. wrong |
9458d81 to
d749ea3
Compare
|
Ok, lets use obj... But what about other signatures? Mentioned above could be fixed easily. Should I do it in this pr? Another one, formatargvalues() - probably must wait a better repr() for lambda, see #79037. |
picnixz
left a comment
There was a problem hiding this comment.
Mmh. Now that you say it, the docs are more meaningful. Here's what I suggest:
- in this PR, align the docs with actual signature
- in a follow-up, let's decide whether to break the signatures or not; I would be favorable to. We can have a deprecation period where first arguments become deprecated when passed as keyword arguments. I made a similar change for hashlib where parameter string/data were used across multiple hash functions and I deprecated the 'string' parameter.
An alternative is to mark the first parmaeter as positional-only in the docs. It's a lie but... it would also hide the fact that it's an implementation detail and will forbid users to use named params.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Ok, lets keep this as is.
You meant:
Sure, we can introduce breaking change that way, but IMO it's overkill. Hardly someone now uses signature(obj=foo) form versus positional argument.
Then next time someone else will point to inconsistency between docs and actual API. |
|
Ok, so let's do the doc update first. That is, sync every signature with existing code first. And in a follow-up, I suggest we just break the signatures (but for that we need an issue and maybe someone else that would be ok with that) |
|
Btw, which signature is typeshed using? |
Uh oh!
There was an error while loading. Please reload this page.