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: Add inspect.Signature.from_text().
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: eric.snow Nosy List: eric.snow, yselivanov
Priority: normal Keywords:

Created on 2019-07-04 00:11 by eric.snow, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 14579 open eric.snow, 2019-07-04 00:11
Messages (5)
msg347250 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2019-07-04 00:11
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.
msg347251 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2019-07-04 00:13
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.
msg362765 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-02-27 04:45
What's the actual use case for exposing this functionality?
msg363535 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2020-03-06 18:44
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).
msg363551 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-03-06 20:46
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.
History
Date User Action Args
2022-04-11 14:59:17adminsetgithub: 81678
2020-03-06 20:46:18yselivanovsetmessages: + msg363551
2020-03-06 18:44:06eric.snowsetmessages: + msg363535
2020-02-27 04:45:59yselivanovsetmessages: + msg362765
2019-07-04 02:11:12xtreaksetnosy: + yselivanov
2019-07-04 00:13:32eric.snowsetmessages: + msg347251
2019-07-04 00:11:26eric.snowcreate