Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jul 18, 2019

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Jul 8, 2019

@@ -3162,7 +3162,7 @@ def trigger_tool(self, name):

Parameters
----------
name : string
name : str
Copy link
Contributor

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)

Copy link
Member Author

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.

@timhoffm timhoffm force-pushed the doc-str branch 2 times, most recently from c7e062d to 02de05b Compare July 16, 2019 18:44
@@ -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
Copy link
Member

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....

Copy link
Member Author

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".

Copy link
Member

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
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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.

@dstansby dstansby added this to the v3.2.0 milestone Jul 18, 2019
@dstansby dstansby merged commit 61f215c into matplotlib:master Jul 18, 2019
@timhoffm timhoffm deleted the doc-str branch July 18, 2019 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants