]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-127750: Fix annotations in singledispatchmethod signature tests (GH-143571...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 11 Jan 2026 19:47:05 +0000 (20:47 +0100)
committerGitHub <noreply@github.com>
Sun, 11 Jan 2026 19:47:05 +0000 (19:47 +0000)
These tests relied on a bug -- gh-84644, which is that singledispatch
doesn't verify the annotation is on the "first" parameter.
(cherry picked from commit 620a5b92693ac1b2cef1f90fd3c2dba1bb794552)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Lib/test/test_functools.py

index a204fd9aaf97024692177f8078da184ff4d05d8c..e042a7909ef05b14347011c89c9ab6c522503796 100644 (file)
@@ -3151,16 +3151,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
@@ -3169,7 +3164,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
@@ -3178,7 +3173,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)),