Function return type annotations were introduced in Python 3.5 as part of PEP 484.
A lot of Python library docs don’t explicitly specify return types and if they do, they specify it as one of the sentences in the description.
For example, is there any reason json.dumps
says:
json.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)
instead of:
json.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw) -> str
or something similar.
In json functions, it is obviously stated what’s the return type or possible return type but for many docs, it’s not obvious.
Maybe we should add known return types for built-in libraries in the docs.
Is there any discussion, ticket, tracker or topic opened for this before?