]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127750: Fix annotations in singledispatchmethod signature tests (GH-143571)
authorBartosz Sławecki <bartosz@ilikepython.com>
Sun, 11 Jan 2026 19:24:19 +0000 (20:24 +0100)
committerGitHub <noreply@github.com>
Sun, 11 Jan 2026 19:24:19 +0000 (21:24 +0200)
These tests relied on a bug -- gh-84644, which is that singledispatch
doesn't verify the annotation is on the "first" parameter.

Lib/test/test_functools.py

index 459d56f82d68203864eaec89e725c23c1f932532..94b469397139c7f6182e13af9451816518bc1161 100644 (file)
@@ -3450,16 +3450,11 @@ class TestSingleDispatch(unittest.TestCase):
 
     def test_method_signatures(self):
         class A:
-            def m(self, item, arg: int) -> str:
-                return str(item)
-            @classmethod
-            def cm(cls, item, arg: int) -> str:
-                return str(item)
             @functools.singledispatchmethod
             def func(self, item, arg: int) -> str:
                 return str(item)
             @func.register
-            def _(self, item, arg: bytes) -> str:
+            def _(self, item: int, arg: bytes) -> str:
                 return str(item)
 
             @functools.singledispatchmethod
@@ -3468,7 +3463,7 @@ class TestSingleDispatch(unittest.TestCase):
                 return str(arg)
             @func.register
             @classmethod
-            def _(cls, item, arg: bytes) -> str:
+            def _(cls, item: int, arg: bytes) -> str:
                 return str(item)
 
             @functools.singledispatchmethod
@@ -3477,7 +3472,7 @@ class TestSingleDispatch(unittest.TestCase):
                 return str(arg)
             @func.register
             @staticmethod
-            def _(item, arg: bytes) -> str:
+            def _(item: int, arg: bytes) -> str:
                 return str(item)
 
         self.assertEqual(str(Signature.from_callable(A.func)),