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 — gh-73536: Add support for multi-signatures by serhiy-storchaka · Pull Request #117671 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Apr 9, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Add inspect.MultiSignature which is a subclass of inspect.Signature.
  • Add inspect.signatures().
  • inspect.signature() can now return a multi-signature.
  • Support multi-signatures in pydoc.
  • Support multi-signatures in IDLE calltips.
  • Support multi-signatures in dataclasses docstrings.
  • Allow multiple @text_signature in Argument Clinic.
  • Add representable signatures for all builtin functions and methods of builtin classes except type() and super().
  • Issue: Add support for multiple signatures #73536

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland, skirpichev, and AA-Turner reacted with thumbs up emoji erlend-aasland and qy88cpn47v-art reacted with rocket emoji
All reactions
  • 👍 3 reactions
  • 🚀 2 reactions
@serhiy-storchaka
pythongh-73536: Add support of multi-signatures
9247a46
* Add inspect.MultiSignature which is a subclass of inspect.Signature.
* Add inspect.signatures().
* inspect.signature() can now return a multi-signature.
* Support multi-signatures in pydoc.
* Support multi-signatures in IDLE calltips.
* Support multi-signatures in dataclasses docstrings.
* Allow multiple @text_signature in Argument Clinic.
* Add representable signatures for all builtin functions and methods of
  builtin classes except type() and super().
@bedevere-app bedevere-app Bot mentioned this pull request Apr 9, 2024
Add support for multiple signatures #73536
Open
erlend-aasland
erlend-aasland reviewed Apr 10, 2024
View reviewed changes
Comment thread Objects/memoryobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/bltinmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 2 commits April 10, 2024 16:27
@serhiy-storchaka
Add tests and fix errors.
54db6d3
@serhiy-storchaka
Fix signatures of hex() methods.
9bbde5f
Gouvernathor
Gouvernathor reviewed Apr 10, 2024
View reviewed changes
Comment thread Lib/inspect.py


def _multisignature_get_partial(wrapped_sig, partial, extra_args=()):
last_exc = None

@Gouvernathor Gouvernathor Apr 10, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless the case of the list being empty is handled elsewhere, this could result in a raise None. Maybe that None should instead be something like Exception("Empty MultiSignature list") ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is checked in the constructor. I think even about removing this assignment, NameError is clearer indication if something goes wrong.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gouvernathor and erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

@Gouvernathor Gouvernathor Apr 11, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/inspect.py Outdated
return True
if isinstance(other, MultiSignature):
return self._signatures == other._signatures
if len(self._signatures) == 1 and isinstance(other, Signature):

@Gouvernathor Gouvernathor Apr 10, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
if len(self._signatures) == 1 and isinstance(other, Signature):
if isinstance(other, Signature):
return len(self._signatures) == 1

and the addition to Signature's eq should be removed, above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not correct, it would make a 1-element MultiSignature equal to any Signature.

You perhaps mistyped, I wrote more correct fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@Gouvernathor Gouvernathor Apr 11, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did. That's good. (I would suggest removing the line about MultiSignature in Signature's eq as I believe it's dead code now, but up to you).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not dead. It is called in SignatureSubclass() == MultiSignature(). Although it is not covered by tests yet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/inspect.py

def signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False):
"""Get a signature object for the passed callable."""
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,

@Gouvernathor Gouvernathor Apr 10, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the original Signature.from_callable is not changed and does the exact same call to _from_callable, that means both signature and Signature.from_callable may return a MultiSignature object, right ?

Strictly speaking this is not a violation of backwards compatibility as MultiSignature is a subclass of Signature, but I find it weird and it may break some strict-type behaviors. Is there a way to have those only return pure Signature objects, without breaking everything this update brings to the table ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. The idea was that inspect.signature() will start to support previously not supported cases and return a MultiSignature which should be compatible with Signature. But now I am no longer sure. They are not so well compatible as I expected, and in most cases I needed to rewrite the code to explicitly handle MultiSignature. This is why I added inspect.signatures(). Now the code is in the intermediate state -- either MultiSignature will be made more compatible with Signature and inspect.signatures() may disappear, or they will became completely different things.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gouvernathor reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@serhiy-storchaka
Refactor support of partial and partialmethod.
5c9ddb9
serhiy-storchaka
serhiy-storchaka commented Apr 11, 2024
View reviewed changes
Comment thread Python/bltinmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/memoryobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/inspect.py


def _multisignature_get_partial(wrapped_sig, partial, extra_args=()):
last_exc = None

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is checked in the constructor. I think even about removing this assignment, NameError is clearer indication if something goes wrong.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gouvernathor and erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Comment thread Lib/inspect.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/inspect.py Outdated
return True
if isinstance(other, MultiSignature):
return self._signatures == other._signatures
if len(self._signatures) == 1 and isinstance(other, Signature):

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not correct, it would make a 1-element MultiSignature equal to any Signature.

You perhaps mistyped, I wrote more correct fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/inspect.py

def signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False):
"""Get a signature object for the passed callable."""
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,

@serhiy-storchaka serhiy-storchaka Apr 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. The idea was that inspect.signature() will start to support previously not supported cases and return a MultiSignature which should be compatible with Signature. But now I am no longer sure. They are not so well compatible as I expected, and in most cases I needed to rewrite the code to explicitly handle MultiSignature. This is why I added inspect.signatures(). Now the code is in the intermediate state -- either MultiSignature will be made more compatible with Signature and inspect.signatures() may disappear, or they will became completely different things.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gouvernathor reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
serhiy-storchaka added 5 commits April 11, 2024 09:47
@serhiy-storchaka
Update Lib/inspect.py
5e7ca6d
@serhiy-storchaka
Remove old commented out code.
53bc04e
@serhiy-storchaka
Add $module for builtin functions.
1a3536f
@serhiy-storchaka
Tests signatures of methods. Fix more signatures in builtins, types a…
6ff7151
…nd sys modules.
@serhiy-storchaka
Merge branch 'main' into wip-inspect-multi-signature
2ad265a
@serhiy-storchaka serhiy-storchaka mentioned this pull request Apr 11, 2024
Add more signatures for builtin functions and methods #117764
Closed
@serhiy-storchaka
Merge branch 'main' into wip-inspect-multi-signature
57f3abf
@serhiy-storchaka serhiy-storchaka mentioned this pull request Jun 7, 2024
int.__round__(None) is not supported #120080
Closed
@serhiy-storchaka
Merge branch 'main' into wip-inspect-multi-signature
2227748
@skirpichev

skirpichev commented Oct 29, 2024

Copy link
Copy Markdown
Member

@serhiy-storchaka, now this again has conflicts with the main. I did pr serhiy-storchaka#22 that address this, hope it helps.

Are you thinking about writing a PEP as Petr suggested?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
skirpichev self-requested a review October 29, 2024 03:02
@skirpichev skirpichev mentioned this pull request Nov 6, 2024
gh-125897: Use positional-only parameter indicators for range() #125945
Merged
@skirpichev

skirpichev commented Feb 24, 2025

Copy link
Copy Markdown
Member

@serhiy-storchaka, will you be ok if I continue this work in a separate pr? Or you disappointed in this approach?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
skirpichev removed their request for review February 26, 2025 02:47
@AA-Turner AA-Turner mentioned this pull request Feb 27, 2025
gh-127647: Add typing.Reader and Writer protocols #127648
Merged
@Dutcho Dutcho mentioned this pull request Mar 12, 2025
Add inspect.signature support for more builtins #107161
Open
This was referenced Mar 31, 2025
gh-131885: Updates docs to make max and min iterable param positional only #131868
Merged
Update function signatures to use * and / as needed #131885
Open
@serhiy-storchaka
Merge branch 'main' into wip-inspect-multi-signature
5df505a
@merwok merwok changed the title gh-73536: Add support of multi-signatures gh-73536: Add support for multi-signatures Apr 8, 2025
serhiy-storchaka added 2 commits April 9, 2025 12:31
@serhiy-storchaka
Merge branch 'main' into wip-inspect-multi-signature
087fd94
@serhiy-storchaka
Add more tests.
452bb6f
serhiy-storchaka added 2 commits August 10, 2025 10:18
@serhiy-storchaka
Merge branch 'main' into wip-inspect-multi-signature
5a70fb0
@serhiy-storchaka
Add signatures for FrameLocalsProxyType methods.
5678904
dutow added a commit to dutow/conan-center-index that referenced this pull request Mar 30, 2026
@dutow
cpython: add patches for 3.13.12 and 3.14.3
6733dcb
Version-specific patches adapted from existing ones:

- relocatable-python-config: same change as 3.x-0001 but adjusted
  for line offset in 3.13+ python-config.sh.in (shared between
  3.13 and 3.14 since the file is identical)

- remove-module-deps: removes ProjectDependencies from the python
  project in PCbuild/pcbuild.sln (separate patches for 3.13 and
  3.14 due to different GUID sets)

- _ctypes-ffi (3.13 only): converts static formattable[] array to
  dynamic initialization for shared libffi compatibility. Not needed
  for 3.14 where this was fixed upstream by restructuring cfield.c
  into a named struct (python/cpython#117671)

The _msi-vcxproj patch is no longer needed since msilib was removed
in 3.13 per PEP 594 (python/cpython#104911).
@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@erlend-aasland erlend-aasland erlend-aasland left review comments
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner will be requested when the pull request is marked ready for review AA-Turner is a code owner
@terryjreedy terryjreedy Awaiting requested review from terryjreedy terryjreedy will be requested when the pull request is marked ready for review terryjreedy is a code owner
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger will be requested when the pull request is marked ready for review rhettinger is a code owner
@ericvsmith ericvsmith Awaiting requested review from ericvsmith ericvsmith will be requested when the pull request is marked ready for review ericvsmith is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently will be requested when the pull request is marked ready for review ericsnowcurrently is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon will be requested when the pull request is marked ready for review markshannon is a code owner
@methane methane Awaiting requested review from methane methane will be requested when the pull request is marked ready for review methane is a code owner
+1 more reviewer
@Gouvernathor Gouvernathor Gouvernathor left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@serhiy-storchaka @skirpichev @erlend-aasland @Gouvernathor
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.