Skip to content

Commit 463acd9

Browse files
authored
feat: see methods from the bound function (#193)
* feat: see methods from the bound function Signed-off-by: nstarman <[email protected]> * test: add test for the dispatcher. Signed-off-by: nstarman <[email protected]> --------- Signed-off-by: nstarman <[email protected]>
1 parent ba3a974 commit 463acd9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

plum/function.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,8 @@ def wrapped_method(*args, **kw_args):
515515
# extended, so unwrapping is likely never desired.
516516

517517
return wrapped_method
518+
519+
@property
520+
def methods(self) -> List[Signature]:
521+
"""list[:class:`.signature.Signature`]: All available methods."""
522+
return self._f.methods

tests/test_dispatcher.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ def g(x: float):
4040
assert dispatch.classes[b]["g"].methods[0].signature == Sig(float, precedence=1)
4141

4242

43+
def test_bound_function_attributes():
44+
"""Test the attributes on a bound function."""
45+
dispatch = Dispatcher()
46+
47+
class A:
48+
@dispatch
49+
def f(self, x: int):
50+
pass
51+
52+
# The 'methods' should point to those of the underlying object.
53+
assert A().f.methods is A.f.methods
54+
assert A().f.methods is A().f._f.methods
55+
56+
4357
def test_dispatch_multi():
4458
dispatch = Dispatcher()
4559

0 commit comments

Comments
 (0)