Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-118285: Fix signatures of operator.{attrgetter,itemgetter,methodcaller} instances #118316

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Apr 26, 2024

  • Allow to specify the signature of custom callable instances of extension type by the __text_signature__ attribute.
  • Specify signatures of operator.attrgetter, operator.itemgetter, and operator.methodcaller instances.

…thodcaller} instances

* Allow to specify the signature of custom callable instances of extension
  type by the __text_signature__ attribute.
* Specify signatures of operator.attrgetter, operator.itemgetter, and
  operator.methodcaller instances.
@@ -239,7 +239,7 @@ class attrgetter:
"""
__slots__ = ('_attrs', '_call')

def __init__(self, attr, *attrs):
def __init__(self, attr, /, *attrs):
Copy link
Member

Choose a reason for hiding this comment

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

Technically, a signature change can affect some people, but it should be fine, because:

  1. most people use C version by default
  2. docs never promised that

Now C and Python signatures are the same.

@serhiy-storchaka serhiy-storchaka merged commit 444ac0b into python:main Apr 29, 2024
36 checks passed
@serhiy-storchaka serhiy-storchaka deleted the inspect-operator branch April 29, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants