Skip to content

Commit 9861730

Browse files
committed
Some clean up
1 parent 84a5467 commit 9861730

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

bpython/inspection.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ def fixlongargs(f: Callable, argspec: ArgSpec) -> ArgSpec:
185185
# IndexError is raised in inspect.findsource(), can happen in
186186
# some situations. See issue #94.
187187
return argspec
188-
signature = "".join(src[0])
189-
kwparsed = parsekeywordpairs(signature)
188+
kwparsed = parsekeywordpairs("".join(src[0]))
190189

191190
for i, (key, value) in enumerate(zip(keys, values)):
192191
if len(repr(value)) != len(kwparsed[key]):
@@ -201,7 +200,7 @@ def fixlongargs(f: Callable, argspec: ArgSpec) -> ArgSpec:
201200
)
202201

203202

204-
def getpydocspec(f, func):
203+
def _getpydocspec(f: Callable) -> Optional[ArgSpec]:
205204
try:
206205
argspec = pydoc.getdoc(f)
207206
except NameError:
@@ -218,7 +217,7 @@ def getpydocspec(f, func):
218217
defaults = []
219218
varargs = varkwargs = None
220219
kwonly_args = []
221-
kwonly_defaults = dict()
220+
kwonly_defaults = {}
222221
for arg in s.group(2).split(","):
223222
arg = arg.strip()
224223
if arg.startswith("**"):
@@ -266,15 +265,14 @@ def getfuncprops(func: str, f: Callable) -> Optional[FuncProps]:
266265
return None
267266
try:
268267
argspec = _get_argspec_from_signature(f)
269-
argspec = fixlongargs(f, argspec)
270-
fprops = FuncProps(func, argspec, is_bound_method)
268+
fprops = FuncProps(func, fixlongargs(f, argspec), is_bound_method)
271269
except (TypeError, KeyError, ValueError):
272-
argspec = getpydocspec(f, func)
273-
if argspec is None:
270+
argspec_pydoc = _getpydocspec(f)
271+
if argspec_pydoc is None:
274272
return None
275273
if inspect.ismethoddescriptor(f):
276-
argspec.args.insert(0, "obj")
277-
fprops = FuncProps(func, argspec, is_bound_method)
274+
argspec_pydoc.args.insert(0, "obj")
275+
fprops = FuncProps(func, argspec_pydoc, is_bound_method)
278276
return fprops
279277

280278

0 commit comments

Comments
 (0)