-
Notifications
You must be signed in to change notification settings - Fork 225
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
POC: Showcases for support type hints #2793
Conversation
3d877ff
to
966537f
Compare
projection: Any = None, | ||
area_thresh: Any = None, | ||
frame: Any = None, | ||
resolution: Literal["f", "h", "i", "l", "c", "a", None] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think if we could get this to show up in the Sphinx docs too at https://pygmt-dev--2793.org.readthedocs.build/en/2793/api/generated/pygmt.Figure.coast.html? Currently we're following GMT and it might be a bit confusing for new users on what |
means
One way is to use something like https://github.com/tox-dev/sphinx-autodoc-typehints. See example at https://pyproject-api.readthedocs.io/en/latest/#pyproject_api.Frontend.metadata_from_built on how it could look like:
But of course, this is the simple case. There are other cases where we can combine letters, and we'll need to think about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth a try.
Can anyone else check if changes in this PR work in Jupyter Notebooks? I can't make it work even after following this post (https://saturncloud.io/blog/autocomplete-jupyter-notebook/). |
Doesn't seem to work for me on JupyterLab 4.0.7: Using |
Description of proposed changes
Related to #2794.
Type Hints are powerful and can be used to provide better auto-completion (address #1203).
Here are some showcases in VSCode.
Autocompletion for
**kwargs
parametersautocompletion-parameters.webm
Autocompletion for parameter's allowed values
autocompletion-valid-values.mov
Autocompletion for dict keys
Implement the syntax 1 in #1078 (comment) and address the concern in #1078 (comment)
autocompletion-dict-keys.webm