X Tutup
Skip to content

Commit 27b417d

Browse files
committed
check if we're instantiating a class and, if so, do not highlight self in argspec (i.e. treat as bound method)
1 parent 8e027d0 commit 27b417d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bpython/inspection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ def getpydocspec(f, func):
209209

210210

211211
def getargspec(func, f):
212-
is_bound_method = inspect.ismethod(f) and f.im_self is not None
212+
# Check if it's a real bound method or if it's implicitly calling __init__
213+
# (i.e. FooClass(...) and not FooClass.__init__(...) -- the former would
214+
# not take 'self', the latter would:
215+
is_bound_method = ((inspect.ismethod(f) and f.im_self is not None)
216+
or (f.__name__ == '__init__' and not
217+
func.endswith('.__init__')))
213218
try:
214219
if py3:
215220
argspec = inspect.getfullargspec(f)

0 commit comments

Comments
 (0)
X Tutup