-
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
TYP: Add type hints and improve docstrings of load_tile_map function #3087
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e61f70d
TYP: Add type hints and improve docstrings of load_tile_map function
seisman 3a02b5a
Fix the error about undefiend xyzservices
seisman f482e70
Fix
seisman 698d523
Merge branch 'main' into typing/tile_map
seisman 1cd04de
Update pygmt/datasets/tile_map.py
seisman 6095b2c
Merge branch 'main' into typing/tile_map
seisman a2e3674
Merge branch 'main' into typing/tile_map
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Now there are two sections,
Return type
andReturns
, and the returned object is written in italic instead of bold style. I personally prefer the current documentation version, as I think the returned object and its data type should be stated together (analogous to the parameters).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.
Need to check if sphinx-autodoc-typehint provides an option to control the behavior. https://github.com/tox-dev/sphinx-autodoc-typehints#options
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 don't think sphinx-autodoc-typehint provides such an option, so there is little we can do unless we decide not to add type hints for the return values.
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.
There was a
napoleon_use_rtype = True
option that was tried in #937. Does it work here, or is that what sphinx-autodoc-typehint is using?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.
Can you try
napoleon_preprocess_types = True
as suggested at sphinx-doc/sphinx#9394?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.
napoleon_use_rtype = True
incorrectly parsesraster
as the return type:napoleon_preprocess_types = True
andnapoleon_use_rtype = False
is not bad: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.
https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#confval-napoleon_preprocess_types
When setting
napoleon_preprocess_types = True
,raster
is parsed as type definitions, so it's rendered the same way as the return typeDataArray
. Strictly speaking, it's still incorrect.Actually, the name of the returned value should not appear in the NumPy-style docstrings (see https://www.sphinx-doc.org/en/master/usage/extensions/example_numpy.html#example-numpy). I.e., we should change
to
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.
It looks like they are using something like
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.
That version doesn't have type hints for the return value.
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.
Some related discussions:
Returns
andYields
sections numpy/numpydoc#356