Skip to content

Commit

Permalink
Rename variables to make the codes more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Jun 15, 2021
1 parent dc2ffb7 commit 30cf3e2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,18 @@ def new_module(*args, **kwargs):
"""
New module that parses and replaces the registered aliases.
"""
for arg, alias in aliases.items():
if alias in kwargs and arg in kwargs:
for short_param, long_alias in aliases.items():
if long_alias in kwargs and short_param in kwargs:
raise GMTInvalidInput(
f"Parameters in short-form ({arg}) and long-form ({alias}) can't coexist."
f"Parameters in short-form ({short_param}) and "
f"long-form ({long_alias}) can't coexist."
)
if alias in kwargs:
kwargs[arg] = kwargs.pop(alias)
elif arg in kwargs:
if long_alias in kwargs:
kwargs[short_param] = kwargs.pop(long_alias)
elif short_param in kwargs:
msg = (
f"Short-form parameter ({arg}) is not recommended. "
f"Use long-form parameter '{alias}' instead."
f"Short-form parameter ({short_param}) is not recommended. "
f"Use long-form parameter '{long_alias}' instead."
)
warnings.warn(msg, category=SyntaxWarning, stacklevel=2)
return module_func(*args, **kwargs)
Expand Down

0 comments on commit 30cf3e2

Please sign in to comment.