Skip to content

Commit 3115fd7

Browse files
committed
Add GH-130827 test
1 parent 9bc1436 commit 3115fd7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_functools.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3518,6 +3518,20 @@ def _(self, arg):
35183518
self.assertEqual(a.v(0), ('special', 0))
35193519
self.assertEqual(a.v(2.5), ('general', 2.5))
35203520

3521+
def test_method_self_annotation(self):
3522+
"""See GH-130827."""
3523+
class A:
3524+
@functools.singledispatchmethod
3525+
def u(self: typing.Self, arg: int | str) -> int | str: ...
3526+
3527+
@u.register
3528+
def _(self: typing.Self, arg: int) -> int:
3529+
return arg
3530+
3531+
a = A()
3532+
self.assertEqual(a.u(42), 42)
3533+
self.assertEqual(a.u("hello"), "hello")
3534+
35213535

35223536
class CachedCostItem:
35233537
_cost = 1

0 commit comments

Comments
 (0)