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 — Add inspect.Signature.from_text(). · Issue #81678 · python/cpython

Add inspect.Signature.from_text(). #81678

New issue
Copy link
New issue
Copy link
Open
Open
Add inspect.Signature.from_text().#81678
Copy link
Assignees
ericsnowcurrently
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

@ericsnowcurrently
ericsnowcurrently
opened on Jul 4, 2019
Issue body actions
BPO 37497
Nosy @ericsnowcurrently, @1st1
PRs
  • gh-81678: Add inspect.Signature.from_text() #14579
  • 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 = 'https://github.com/ericsnowcurrently'
    closed_at = None
    created_at = <Date 2019-07-04.00:11:26.728>
    labels = ['type-feature', 'library', '3.9']
    title = 'Add inspect.Signature.from_text().'
    updated_at = <Date 2020-03-06.20:46:18.865>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2020-03-06.20:46:18.865>
    actor = 'yselivanov'
    assignee = 'eric.snow'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-07-04.00:11:26.728>
    creator = 'eric.snow'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37497
    keywords = []
    message_count = 5.0
    messages = ['347250', '347251', '362765', '363535', '363551']
    nosy_count = 2.0
    nosy_names = ['eric.snow', 'yselivanov']
    pr_nums = ['14579']
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue37497'
    versions = ['Python 3.9']

    Activity

    1. ericsnowcurrently commented on Jul 4, 2019

      @ericsnowcurrently
      ericsnowcurrently
      on Jul 4, 2019
      MemberAuthor
      More actions

      In early 2014 (3.3), when argument clinic was added, we added support for turning func.__text_signature__ into an inspect.Signature object. However, the functionality to convert a string into a Signature was never exposed publicly. Here's a patch to do so.

      Note that inspect.signature() will also support taking a string.

    2. ericsnowcurrently
      added
      3.9 (EOL)end of lifeend of life
      on Jul 4, 2019
    3. ericsnowcurrently
      self-assigned this
      on Jul 4, 2019
    4. ericsnowcurrently
      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 Jul 4, 2019
    5. ericsnowcurrently commented on Jul 4, 2019

      @ericsnowcurrently
      ericsnowcurrently
      on Jul 4, 2019
      MemberAuthor
      More actions

      Note that there has been a little discussion of this in the past, particularly around the time that argument clinic was introduced: https://bugs.python.org/issue23967#msg241140.

    6. 1st1 commented on Feb 27, 2020

      @1st1
      1st1
      on Feb 27, 2020
      Member
      More actions

      What's the actual use case for exposing this functionality?

    7. ericsnowcurrently commented on Mar 6, 2020

      @ericsnowcurrently
      ericsnowcurrently
      on Mar 6, 2020
      MemberAuthor
      More actions

      Honestly, I don't recall exactly the concrete use case for which I opened this. :) I *think* it was related to applying a more restrictive signature onto an existing function (e.g. with a decorator).

    8. 1st1 commented on Mar 6, 2020

      @1st1
      1st1
      on Mar 6, 2020
      Member
      More actions

      I'd be fine with Signature.from_text(), but not with Signature constructor / signature() function accepting both callable and string arguments. Overall, I think that we ought to have a real need to add this new API, so unless there's a good (or any, really) use case I'd say we shouldn't merge this now.

    9. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    10. erlend-aasland
      removed
      3.9 (EOL)end of lifeend of life
      on Jan 8, 2024
    11. serhiy-storchaka
      added this to Inspect issues 🔍on Mar 5, 2024
    12. tungol commented on Dec 8, 2024

      @tungol
      tungol
      on Dec 8, 2024
      Contributor
      More actions

      This came up for me recently. I wanted to create a better signature for a built-in class's __init__ method by converting the signature from the underlying class. The text of the signature was easy to manipulate, but then I had no way to convert it to a signature object.

      I worked around it by creating the signature object for the underlying class first, and then modifying it with replace(). That's not a bad work-around, but there were a couple extra considerations that I thought were slightly easier to handle when generating the text of the signature I wanted directly.

      I agree that that's no need for inspect.signature() to understand the text format itself.

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

    Metadata

    Metadata

    Assignees

    • @ericsnowcurrently
      ericsnowcurrently

    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

    • Inspect issues 🔍
      Status
      No status
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — 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.