Skip to content

Commit 30018e4

Browse files
committed
Treat ... in __doc__ as separator between varargs and kwonly args
1 parent 7ed578e commit 30018e4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

bpython/inspection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def getpydocspec(f, func):
203203
varkwargs = arg[2:]
204204
elif arg.startswith("*"):
205205
varargs = arg[1:]
206+
elif arg == "...":
207+
# At least print denotes "..." as separator between varargs and kwonly args.
208+
varargs = ""
206209
else:
207210
arg, _, default = arg.partition("=")
208211
if varargs is not None:

bpython/test/test_inspection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ def test_get_source_file(self):
118118
)
119119
self.assertEqual(encoding, "utf-8")
120120

121+
def test_getfuncprops_print(self):
122+
props = inspection.getfuncprops("print", print)
123+
124+
self.assertEqual(props.func, "print")
125+
self.assertIn("end", props.argspec.kwonly)
126+
self.assertIn("file", props.argspec.kwonly)
127+
self.assertIn("flush", props.argspec.kwonly)
128+
self.assertIn("sep", props.argspec.kwonly)
129+
self.assertEqual(props.argspec.kwonly_defaults["file"], "sys.stdout")
130+
self.assertEqual(props.argspec.kwonly_defaults["flush"], "False")
131+
121132
@unittest.skipUnless(numpy is not None, "requires numpy")
122133
def test_getfuncprops_numpy_array(self):
123134
props = inspection.getfuncprops("array", numpy.array)

0 commit comments

Comments
 (0)