Skip to content

Commit ec5bb5a

Browse files
authored
Find correct source for extended commands (#254)
1 parent e8abfd2 commit ec5bb5a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

spin/cmds/meta.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def introspect(*, cmd):
2929

3030
cmd_func = cmds[cmd]
3131
try:
32-
code = inspect.getsource(cmd_func.callback)
32+
if hasattr(cmd_func.callback, "_parent"):
33+
# `util.extend_command` was used
34+
code = inspect.getsource(cmd_func.callback._parent)
35+
else:
36+
code = inspect.getsource(cmd_func.callback)
3337
except TypeError:
3438
# Perhaps a partial, try again
3539
code = inspect.getsource(cmd_func.callback.func)

spin/cmds/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def parent_cmd(*user_args, **user_kwargs):
160160
return user_func(*args, parent_callback=parent_cmd, **kwargs)
161161

162162
my_cmd.callback = click.pass_context(callback_with_parent_callback)
163+
my_cmd.callback._parent = user_func
163164

164165
if doc is not None:
165166
my_cmd.help = doc

0 commit comments

Comments
 (0)