We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9bc1436 commit 3115fd7Copy full SHA for 3115fd7
Lib/test/test_functools.py
@@ -3518,6 +3518,20 @@ def _(self, arg):
3518
self.assertEqual(a.v(0), ('special', 0))
3519
self.assertEqual(a.v(2.5), ('general', 2.5))
3520
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
3535
3536
class CachedCostItem:
3537
_cost = 1
0 commit comments