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
Explicit explanation how to write docstring #933
Comments
Same problem |
@keisuke-umezawa thanks for bringing this issue up. Do you have any ideas for how to address it? |
@hvy But there are several differences between it and what we use. So it is better to write our docstrings examples?
Main differences from Example Google Style Python Docstrings
I want to add above into the coding guideliens |
One question is that:
|
I basically agree with the above comment and that it'd improve readability. I'd like to hear opinions from other developers. My concern is how to maintain the docstrings, especially if we start customizing the rules. Can we use black for that, or yapf (c.f. #956)? |
#933 (comment) (latter question) I personally find |
In my understanding, formatters do not change comments, so we can use black or yapf with any customized docstring guidelines. |
But, I also do not like customized guidelines, and as much as possible I want to follow Example Google Style Python Docstrings.
For those, we can ignore the differences above. It means we can do following:
And, in the coding guideliens, we can just add following |
Optuna Specific ConventionsAdd examples with doctestIf you want to add an example, you can add an
|
@keisuke-umezawa Thank you for your proposal. It basically sounds good to me.
If we follow the current coding convention, the example will be as follows:
I think we need to choose to keep the current convention. |
+1 for omitting the "empty line" rule for reasons already mentioned. It's not something we want to nitpick on during reviews. |
Thank you for the comments, and sorry for late relply. I want to add following changes into the coding guideliens:
|
Thanks for the updates and the separate diffs (those help). I'd like to verify this with other core developers and committers but changes basically LGTM. I have two questions.
|
Right now, I made the guideline to follow current docstrings in Optuna as much as possible. Main differences may be:
If we need to fix them, we can make issues.
yes, they are same. |
1 and 3 should be fixed but I don't think 2 should be considered an issue, i.e. examples are optional. Making issue(s) SGTM.
Thanks for the verification. Aligning to either seem fine. |
Could you tell me why you choose the method level docstring?
In addition, could you show me an example repositories which employ the method level docstring? |
Sorry, it seems that it is just my preference. I also checked other libraries s.t. sklearn, and they use class level docstring. I intended to delete the arbitrarily choice to write args in either class level or
So, I choosed |
Sound perfectly reasonable to me! |
@keisuke-umezawa |
@keisuke-umezawa, would you mind updating the coding style guide accordingly? Let me know if you're busy and maybe I could do it. |
Thanks a lot, the changes LGTM. |
@hvy If you satisfied with the current guideline, we can close this issue. How do you feel about it? |
Thanks, I'm personally okay with the new style. However, it'll require several changes (e.g. all the directives such as |
Sorry for pinging but @crcrpar do you have any inputs on these changes? |
Actually I don't have any take on how docstring should look like and I'm happy if there is one clear guideline. |
I will add description that both style is acceptable for |
I close this issue, because we achieved the goal I want to do when I opened it. |
As contributors write docstrings for their implementations, it is better to show an explicit example how to write docstrings.
e.g. in pytorch reference, it refers Google style docstrings.
Currently, in optuna, there are no explicit explanation for docstrings in the coding guideliens. Just referring pep8, and it is difficult to know how docstrings should be.
The text was updated successfully, but these errors were encountered: