mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Mangle __parameters in __annotations__ dict properly. Issue #20625.
This commit is contained in:
parent
b59e4425d5
commit
34ce99f66d
5 changed files with 37 additions and 1 deletions
|
|
@ -2390,6 +2390,22 @@ class TestSignatureObject(unittest.TestCase):
|
|||
self.assertEqual(sig.return_annotation, 42)
|
||||
self.assertEqual(sig, inspect.signature(test))
|
||||
|
||||
def test_signature_on_mangled_parameters(self):
|
||||
class Spam:
|
||||
def foo(self, __p1:1=2, *, __p2:2=3):
|
||||
pass
|
||||
class Ham(Spam):
|
||||
pass
|
||||
|
||||
self.assertEqual(self.signature(Spam.foo),
|
||||
((('self', ..., ..., "positional_or_keyword"),
|
||||
('_Spam__p1', 2, 1, "positional_or_keyword"),
|
||||
('_Spam__p2', 3, 2, "keyword_only")),
|
||||
...))
|
||||
|
||||
self.assertEqual(self.signature(Spam.foo),
|
||||
self.signature(Ham.foo))
|
||||
|
||||
|
||||
class TestParameterObject(unittest.TestCase):
|
||||
def test_signature_parameter_kinds(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue