[issue38333] add type signatures to library function docs

Guido van Rossum report at bugs.python.org
Wed Oct 2 18:13:00 EDT 2019


Guido van Rossum <guido at python.org> added the comment:

@phr

To be clear, I agree that there's nothing wrong with adding signatures to docs. We just need to find a way to do it. There will definitely be some cases where it's better not to have a type rather than trying to spell out the actual type in the docs.

My "unacceptable" comment was meant in response to Vedran's suggestion that it would be okay to lie in the docs about the signature for sum(). If the truth is too subtle to use a specific type signature we should keep the words. (The words for sum() are actually pretty clear.)

FWIW: My objection against vague docs was specifically about situations where the word "string" is used without clarifying if this allows bytes. I've also seen docs that were even more vague, e.g. "a name" or "a filename".

Signatures in the code won't "break" the code (they are ignored at runtime) but if present they should nevertheless be precise since they will be used by type checkers. Signatures in code are *not* just documentation. Only in very limited situations would I be okay with lies in signatures -- this would have to be done on a case by case basis.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38333>
_______________________________________


More information about the Python-bugs-list mailing list