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.

Author RazerM
Recipients RazerM
Date 2020-02-21.22:41:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582324893.03.0.384494522706.issue39720@roundup.psfhosted.org>
In-reply-to
Content
Signature.bind does not tell you if a missing argument is keyword-only for example. I created the following snippet to examine the differences:

    import inspect
    
    def run(f):
        try:
            f()
        except TypeError as exc:
            print(exc.args[0])
        else:
            raise RuntimeError('Expected to raise!')
        sig = inspect.signature(f)
        try:
            sig.bind()
        except TypeError as exc:
            print(exc.args[0])
        else:
            raise RuntimeError('Expected to raise!')
        print()
    
    @run
    def f1(pos_only, /): ...
    
    @run
    def f2(pos_or_kw): ...
    
    @run
    def f3(*, kw_only): ...

Output on current 3.9 master:

    f1() missing 1 required positional argument: 'pos_only'
    missing a required argument: 'pos_only'
    
    f2() missing 1 required positional argument: 'pos_or_kw'
    missing a required argument: 'pos_or_kw'
    
    f3() missing 1 required keyword-only argument: 'kw_only'
    missing a required argument: 'kw_only'

I am willing to create a PR so that the TypeError for f3 says "missing a required keyword-only argument: 'kw_only'", if this would be accepted.
History
Date User Action Args
2020-02-21 22:41:33RazerMsetrecipients: + RazerM
2020-02-21 22:41:33RazerMsetmessageid: <1582324893.03.0.384494522706.issue39720@roundup.psfhosted.org>
2020-02-21 22:41:33RazerMlinkissue39720 messages
2020-02-21 22:41:32RazerMcreate