Skip to content

Commit 2938c2a

Browse files
committed
Raise an warning for the use of short-form parameters when long-forms are available
1 parent 1ab551d commit 2938c2a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pygmt/helpers/decorators.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def use_alias(**aliases):
359359
Traceback (most recent call last):
360360
...
361361
pygmt.exceptions.GMTInvalidInput:
362-
Arguments in short-form (J) and long-form (projection) can't coexist
362+
Parameters in short-form (J) and long-form (projection) can't coexist.
363363
"""
364364

365365
def alias_decorator(module_func):
@@ -375,10 +375,16 @@ def new_module(*args, **kwargs):
375375
for arg, alias in aliases.items():
376376
if alias in kwargs and arg in kwargs:
377377
raise GMTInvalidInput(
378-
f"Arguments in short-form ({arg}) and long-form ({alias}) can't coexist"
378+
f"Parameters in short-form ({arg}) and long-form ({alias}) can't coexist."
379379
)
380380
if alias in kwargs:
381381
kwargs[arg] = kwargs.pop(alias)
382+
elif arg in kwargs:
383+
msg = (
384+
f"Short-form parameter ({arg}) is not recommended. "
385+
f"Use long-form parameter '{alias}' instead."
386+
)
387+
warnings.warn(msg, category=FutureWarning, stacklevel=2)
382388
return module_func(*args, **kwargs)
383389

384390
new_module.aliases = aliases

0 commit comments

Comments
 (0)