-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use str instead of string as type in docstrings #14716
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
Conversation
@@ -3162,7 +3162,7 @@ def trigger_tool(self, name): | |||
|
|||
Parameters | |||
---------- | |||
name : string | |||
name : str |
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.
also add missing final dots in the sentences below? (throughout the docstrings you edited here)
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.
Trying to not get carried away too far. Otherwise the PR gets endless and even more terrible to review. These sentences need rephrasing anyway. It's better to leave them alone for now and do everything in one go when I come back.
c7e062d
to
02de05b
Compare
@@ -437,7 +437,7 @@ def __init__(self, filename, metadata=None): | |||
Parameters | |||
---------- | |||
|
|||
filename : file-like object or string | |||
filename : str or path-like or file-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.
Is chaining or
like this the style we want? Could do as str, path-like, or file-like
which reads better to me....
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's how the numpydoc docstring guide describes it:
shape : int or tuple of int
Currently we use a comma for simple tuples, e.g. center : float, float
.
I don't have a strong opinion on this, but if we change that, we need another convention for tuple to avoid ambiguity (could be (float, float)
). Everything should be changed consistently throughout the docs and we should document it in "writing documentation".
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.
If you use the Oxford comma it’s not ambiguous:
A, B, or c
A, B or c
Though I would tend to enclose tuples in brackets just to be clear
@@ -583,7 +583,7 @@ class Vf(Dvi): | |||
|
|||
Parameters | |||
---------- | |||
filename : string or bytestring |
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.
Why has bytestring
been dropped here?
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.
Because it's a path-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.
I was adding path-like
, because that's clearly missing and relevant. Technically, that would be enough (str
and bytestring
are path-like
). However, that's not quite helpful. I don't expect all of our users to know what a path-like
is, less that a str
is a path-like
. The newbie can now still see that a string is fine, and that's the most basic use-case. OTOH, a bytestring
is already a bit more advanced. Users who know bytestrings probably know path-likes (or at least could guess that if str
works, bytestring
will likely too. So bytestring
is not giving as much additional information that it's worth explicitly mentioning.
PR Summary
See also https://matplotlib.org/devdocs/devel/documenting_mpl.html#parameter-type-descriptions and the
Parameters
section of the numpydoc docstring guide.