-
Notifications
You must be signed in to change notification settings - Fork 224
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
Let PyGMT functions support tab autocompletion #1203
Comments
Nice idea, but just wondering if there's a way to modify the |
Here is a quick script to list the parameters:
The output looks like this. We still need to manually copy the output parameter list into each function.
|
All functions are manually updated in #1202, so they should all support auto-completion now. The only exception is |
Thanks, but what I meant was to recode the |
Actually, I'm trying to fully get rid of the |
Yes, I understand that we're working towards resolving #262. There are a lot of line changes made in 998a123, much of which appears to be similar/duplicating that of the Perhaps we need more discussion and ideas on the best way to proceed on this long-term issue. My argument is that this would be something for v0.5.0, and until we have an automated solution to sync upstream GMT module parameters and documentation (c.f. #895) with PyGMT, there is no way I feel comfortable with disabling single-character parameters in #262 because it would be limiting the utility of PyGMT (albeit one that is undocumented). |
It seems an impossible task to me.
I agree. We probably won't be able to disable single-letter parameters until v1.0.0. |
What is the push to disable single letter parameters, even at v1.0.0? I'm not a fan of single-letter parameters and think we should maximize our use of PyGMT parameter names, but does it cost us anything to remove that capability? |
Good question. I am also curious about this. The main limitation that I see to disallowing the use of single-letter parameters is that it would prevent people from using 'cutting-edge' GMT functionality. Each GMT release tends to offer several new single-character options (see https://docs.generic-mapping-tools.org/dev/changes.html), so removing PyGMT support for single-character options would make it so that users would need to wait for a PyGMT release with new aliases for the options. The impact of this is limited by PyGMT's relatively quick release cycle compared to GMT's and the (assumption here) minority of users that build GMT from source or upgrade to the latest GMT version right away, but I think it is still worth considering. |
I agree. Actually what I meant is to disallow single-letter parameters if they already have aliases. For example, currently, the |
Jupyter and most modern text editors support tab autocompletion, which is useful for typing long function and parameter names. However, currently, most PyGMT functions don't support tab autocompletion, since we use the alias system (
use_alias
),*args
, and**kwargs
. The only way I know to enable tab autocompletion is using normal Python parameters instead of relying on the**kwargs
anduse_alias
decorator (see #262 for the original issue).The solution seems straightforward. For example, for the
pygmt.info()
function, the current function is defined as:To make it support tab autocompletion, we just need to change the
def info()
part:Since all parameters are defined as normal Python parameters, tab autocompletion should work. The new function definition still keeps the
**kwargs
parameter, so that single-letter options are still supported (but we are likely to disallow single-letter options in future releases, see #262). Thus, this would be backward compatible, and is the first step to address #262.The screenshots below show how the autocompletion work after applying the changes in PR #1202:
pygmt.info()
pygmt.info()
Please give #1202 a try and leave your thoughts.
The text was updated successfully, but these errors were encountered: