Skip to content

Commit

Permalink
fix bug preventing command callbacks decorated with @flagconverter_kw…
Browse files Browse the repository at this point in the history
…args() from being directly invoked
  • Loading branch information
Mega-JC committed Nov 5, 2022
1 parent cc977cb commit 02587ea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion snakecore/commands/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def flagconverter_kwargs_inner_deco(func: Callable[_P, _T]) -> Callable[_P, _T]:
commands.Parameter( # add generated FlagConverter class as parameter
"__flags__",
inspect.Parameter.KEYWORD_ONLY,
default=None,
annotation=flags_cls,
)
)
Expand All @@ -193,7 +194,7 @@ async def wrapper(*args, __flags__: flags_cls = None, **kwargs): # type: ignore
flagconverter_kwargs_wrapper: Callable[_P, _T] = types.FunctionType(
wrapper.__code__,
func.__globals__,
name=wrapper.__name__,
name=func.__name__,
argdefs=wrapper.__defaults__,
closure=wrapper.__closure__,
) # type: ignore
Expand All @@ -207,6 +208,7 @@ async def wrapper(*args, __flags__: flags_cls = None, **kwargs): # type: ignore
flagconverter_kwargs_wrapper.__signature__ = (
new_sig # fake signature for wrapper function
)
flagconverter_kwargs_wrapper.__kwdefaults__ = wrapper.__kwdefaults__
flagconverter_kwargs_wrapper.__wrapped_func__ = func
flagconverter_kwargs_wrapper.__wrapped_func_signature__ = sig
flagconverter_kwargs_wrapper.KeywordOnlyFlags = flags_cls
Expand Down

0 comments on commit 02587ea

Please sign in to comment.