GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Signature.bind TypeErrors could be more helpful · Issue #83901 · python/cpython

Signature.bind TypeErrors could be more helpful #83901

New issue
Copy link
New issue
Copy link
Closed
Closed
Signature.bind TypeErrors could be more helpful#83901
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

RazerM
mannequin
opened on Feb 21, 2020
Issue body actions
BPO 39720
Nosy @RazerM

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-02-21.22:41:33.023>
labels = ['type-feature', 'library']
title = 'Signature.bind TypeErrors could be more helpful'
updated_at = <Date 2020-02-21.22:41:33.023>
user = 'https://github.com/RazerM'

bugs.python.org fields:

activity = <Date 2020-02-21.22:41:33.023>
actor = 'RazerM'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2020-02-21.22:41:33.023>
creator = 'RazerM'
dependencies = []
files = []
hgrepos = []
issue_num = 39720
keywords = []
message_count = 1.0
messages = ['362439']
nosy_count = 1.0
nosy_names = ['RazerM']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue39720'
versions = []

Activity

  1. RazerM commented on Feb 21, 2020

    @RazerM
    RazerMmannequin
    on Feb 21, 2020
    MannequinAuthor
    More actions

    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.

  2. RazerM
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancementA feature request or enhancement
    on Feb 21, 2020
  3. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  4. JelleZijlstra
    closed this as completedin f4f8133on Oct 7, 2022
  5. carljm
    added a commit that references this issue on Oct 8, 2022

    Merge branch 'main' into typewatch

    27a4980
  6. mpage
    added a commit that references this issue on Oct 11, 2022

    pythonGH-83901: Improve Signature.bind error message for missing keyw…

    c437b6e
  7. serhiy-storchaka
    added a commit that references this issue on Aug 9, 2026

    pythonGH-83901: Improve Signature.bind error message for missing keyw…

    f4f8133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.