This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 10 built-in functions need non-None .__text_signature__
Type: enhancement Stage: resolved
Components: Argument Clinic, Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, larry, rhettinger, serhiy.storchaka, terry.reedy, xloem
Priority: normal Keywords:

Created on 2021-09-27 15:46 by xloem, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg402727 - (view) Author: xloem (xloem) Date: 2021-09-27 15:46
As there is no __text_signature__ nor __signature__ attribute on basic builtin functions such as print or open, inspect.signature() cannot enumerate their parameters.

It seems adding these might not be a complex task for somebody familiar with the code.
msg403038 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-10-01 22:42
I agree that finishing this would be nice.  In branch main (3.11.0a0), open and print now have non-None versions of this attribute.  However,

for ob in builtins.__dict__.values():
    if (str(ob).startswith('<built-in function') and
        ob.__text_signature__ is None):
        print(ob)
# prints   
<built-in function __build_class__>
<built-in function __import__>
<built-in function breakpoint>
<built-in function dir>
<built-in function getattr>
<built-in function iter>
<built-in function max>
<built-in function min>
<built-in function next>
<built-in function vars>

So there are still some to do.

for ob in builtins.__dict__.values():
    if (str(ob).startswith('<class') and
        ob.__init__.__text_signature__ is None):
        print(ob)
# prints nothing.
msg403079 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-10-03 08:33
There are reasons for this. There is no supported by inspect.signature() syntax to adequately define the signature of say getattr(). It has one required parameter and one optional parameter, but the default value of the optional parameter cannot be expressed.
msg403105 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-10-03 18:07
As Serhiy says, this is a known issue that we can't do anything about until signature objects become more expressive.  The C code already has comments such as:

     /* AC: cannot convert yet, waiting for *args support */
     /* AC: cannot convert yet, as needs PEP 457 group support in inspect */
msg403133 - (view) Author: xloem (xloem) Date: 2021-10-04 12:51
Thanks for your time.

Just a note that this is likely a docs issue if nothing else.  I may never have opened this issue if the missing functions were listed in the inspect module documentation.
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89465
2021-10-04 12:51:18xloemsetmessages: + msg403133
2021-10-03 18:07:50rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg403105

resolution: wont fix
stage: test needed -> resolved
2021-10-03 08:33:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg403079
2021-10-03 03:49:05eric.araujosetnosy: + eric.araujo
2021-10-01 22:42:56terry.reedysetnosy: + terry.reedy
title: basic builtin functions missing __text_signature__ attributes -> 10 built-in functions need non-None .__text_signature__
messages: + msg403038

versions: + Python 3.11, - Python 3.8
stage: test needed
2021-09-27 15:46:25xloemcreate