classification
Title: docstring of "type" could use an update
Type: Stage: resolved
Components: Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: larry, lukasz.langa, mark.dickinson, miss-islington
Priority: normal Keywords: patch

Created on 2021-10-06 13:54 by mark.dickinson, last changed 2021-11-06 20:21 by lukasz.langa. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29439 merged mark.dickinson, 2021-11-06 10:56
PR 29452 merged miss-islington, 2021-11-06 19:08
PR 29453 merged miss-islington, 2021-11-06 19:08
Messages (8)
msg403302 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-10-06 13:54
The docstring of the "type" builtin is mildly confusing. Here's what the first few lines of the output for `help(type)` look like for me (on Python 3.10.0rc2):

class type(object)
 |  type(object_or_name, bases, dict)
 |  type(object) -> the object's type
 |  type(name, bases, dict) -> a new type

The first line there seems redundant, and potentially misleading, since it suggests that `type(object, bases, dict)` might be legal.

The third line is missing mention of possible keyword arguments.
msg403309 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-10-06 15:07
Larry: the first line was introduced in #20189. Does it still make sense to keep it at this point?
msg403314 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2021-10-06 15:17
Removing it makes sense to me.  Not sure what I was thinking, way back when.  Thanks for catching--and volunteering to fix--this!
msg405880 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-06 19:08
It's unclear what the original comment was about. BPO-20189 is somewhat cryptic to me too. `inspect.signature` never supported `type`, `round`, `int`, and so on. I checked 3.4.10 and 3.5.10 and in each case it looks like this:

>>> inspect.signature(type)
Traceback (most recent call last):
...
ValueError: no signature found for builtin <class 'type'>


In fact, there's open issues on that, like BPO-44618.
msg405881 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-06 19:08
New changeset 91275207296c39e495fe118019a757c4ddefede8 by Mark Dickinson in branch 'main':
bpo-45392: Update the docstring of the 'type' built-in (GH-29439)
https://github.com/python/cpython/commit/91275207296c39e495fe118019a757c4ddefede8
msg405885 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-06 20:18
New changeset f5287ecd59d83a662490f89188a0fc2ef3718f8b by Miss Islington (bot) in branch '3.9':
bpo-45392: Update the docstring of the 'type' built-in (GH-29439) (GH-29453)
https://github.com/python/cpython/commit/f5287ecd59d83a662490f89188a0fc2ef3718f8b
msg405886 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-06 20:21
New changeset 045f205ba4710c4c633364a4e2e098483af936e5 by Miss Islington (bot) in branch '3.10':
bpo-45392: Update the docstring of the 'type' built-in (GH-29439) (GH-29452)
https://github.com/python/cpython/commit/045f205ba4710c4c633364a4e2e098483af936e5
msg405887 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-06 20:21
Thanks, Mark! ✨ 🍰 ✨
History
Date User Action Args
2021-11-06 20:21:56lukasz.langasetstatus: open -> closed
versions: + Python 3.9, Python 3.10, Python 3.11
messages: + msg405887

resolution: fixed
stage: patch review -> resolved
2021-11-06 20:21:12lukasz.langasetmessages: + msg405886
2021-11-06 20:18:07lukasz.langasetmessages: + msg405885
2021-11-06 19:08:56miss-islingtonsetpull_requests: + pull_request27708
2021-11-06 19:08:52miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request27707
2021-11-06 19:08:51lukasz.langasetmessages: + msg405881
2021-11-06 19:08:04lukasz.langasetnosy: + lukasz.langa
messages: + msg405880
2021-11-06 10:56:28mark.dickinsonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27693
2021-10-06 15:17:55larrysetmessages: + msg403314
2021-10-06 15:07:41mark.dickinsonsetnosy: + larry
messages: + msg403309
2021-10-06 13:54:59mark.dickinsoncreate