Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tab completion in Jupyter by inserting aliases into the method signature #1282

Merged
merged 14 commits into from
Jun 16, 2021
Merged
Prev Previous commit
Next Next commit
Update decorator
  • Loading branch information
maxrjones committed May 21, 2021
commit 80821501ed1c8b1ff0bac44354ad479eff92eb86
22 changes: 8 additions & 14 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,16 @@ def tab_complete_alias(module_func):
"""
Decorator injecting aliases of a method as attributes
"""
@functools.wraps(module_func)
def wrapper(*args, **kwargs):
"""
New module instance that includes aliases in the signature.
"""
sig = signature(module_func)
param = Parameter("verbose",kind=Parameter.POSITIONAL_OR_KEYWORD,default=None)
wrapped_params = [param for param in sig.parameters.values()]
kwargs_param = wrapped_params.pop(-1)
all_params = wrapped_params + [param] + [kwargs_param]
sig = sig.replace(parameters=all_params)
wrapper.__signature__ = sig

return module_func(*args,**kwargs)
sig = signature(module_func)
param = Parameter("verbose",kind=Parameter.POSITIONAL_OR_KEYWORD,default=None)
wrapped_params = [param for param in sig.parameters.values()]
kwargs_param = wrapped_params.pop(-1)
all_params = wrapped_params + [param] + [kwargs_param]
sig_new = sig.replace(parameters=all_params)
module_func.__signature__ = sig_new

return wrapper
return module_func


def kwargs_to_strings(**conversions):
Expand Down