mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
fix inspect.formatargspec on functions with keyword-only arguments without defaults #4959
This commit is contained in:
parent
c10c34d6cb
commit
9953a8dfd6
4 changed files with 15 additions and 1 deletions
|
@ -105,3 +105,7 @@ def keyworded(*arg1, arg2=1):
|
|||
#line 105
|
||||
def annotated(arg1: list):
|
||||
pass
|
||||
|
||||
#line 109
|
||||
def keyword_only_arg(*, arg):
|
||||
pass
|
||||
|
|
|
@ -386,6 +386,9 @@ class TestClassesAndFunctions(unittest.TestCase):
|
|||
|
||||
self.assertRaises(ValueError, self.assertArgSpecEquals,
|
||||
mod2.annotated, [])
|
||||
self.assertRaises(ValueError, self.assertArgSpecEquals,
|
||||
mod2.keyword_only_arg, [])
|
||||
|
||||
|
||||
def test_getfullargspec(self):
|
||||
self.assertFullArgSpecEquals(mod2.keyworded, [], varargs_e='arg1',
|
||||
|
@ -396,6 +399,10 @@ class TestClassesAndFunctions(unittest.TestCase):
|
|||
self.assertFullArgSpecEquals(mod2.annotated, ['arg1'],
|
||||
ann_e={'arg1' : list},
|
||||
formatted='(arg1: list)')
|
||||
self.assertFullArgSpecEquals(mod2.keyword_only_arg, [],
|
||||
kwonlyargs_e=['arg'],
|
||||
formatted='(*, arg)')
|
||||
|
||||
|
||||
def test_getargspec_method(self):
|
||||
class A(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue