8000 gh-118285: Fix signatures of operator.{attrgetter,itemgetter,methodcaller} instances by serhiy-storchaka · Pull Request #118316 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add a test for generic callable with __text_signature__.
  • Loading branch information
serhiy-storchaka committed Apr 29, 2024
commit df81a01a4c6a5904011ee3f1593112994fb4954e
22 changes: 22 additions & 0 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4090,6 +4090,28 @@ class C:
((('a', ..., ..., "positional_or_keyword"),),
...))

def test_signature_on_callable_objects_with_text_signature_attr(self):
class C:
__text_signature__ = '(a, /, b, c=True)'
def __call__(self, *args, **kwargs):
pass

self.assertEqual(self.signature(C), ((), ...))
self.assertEqual(self.signature(C()),
((('a', ..., ..., "positional_only"),
('b', ..., ..., "positional_or_keyword"),
('c', True, ..., "positional_or_keyword"),
),
...))

c = C()
c.__text_signature__ = '(x, y)'
self.assertEqual(self.signature(c),
((('x', ..., ..., "positional_or_keyword"),
('y', ..., ..., "positional_or_keyword"),
),
...))

def test_signature_on_wrapper(self):
class Wrapper:
def __call__(self, b):
Expand Down
0