-
Notifications
You must be signed in to change notification settings - Fork 897
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
chore: Add docstrings and types to Version class #5262
Conversation
93148d2
to
a6db113
Compare
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 like that you are following google's python style guide: https://google.github.io/styleguide/pyguide.html
Let's avoid extra empty newlines in the docstrings as we are dedicating a lot of vertical real-estate to these docstrings already.
I have thoughts...let's not merge this quite yet |
nit: If we change More broadly, if we're wanting to standardize on a format, I'd prefer we use the Sphinx format. Reasons:
Since existing tooling generally supports both formats, I don't think there's any loss from not using Google format. |
No objections from me for cheap test coverage :D
Good points. The only reservations that I have are that sphinx has a little more boilerplate and a little more work for my eyes to parse than google-styled docstrings. I'm sure I'll get used to sphinx docstrings without issue. I'll update this PR unless @blackboxsw or @aciba90 has any strong objections. Lets open a PR or file an issue to make sure that we eventually get this documented and update the current docstrings (and maybe a CI job for doctest while we're at it?) |
I don't think we need to include every field every time. E.g., there's a stackoverflow answer that has this: """
This is a reST style.
:param param1: this is a first param
:param param2: this is a second param
:returns: this is a description of what is returned
:raises keyError: raises an exception
""" Which is a lot less boilerplate. Since we (ideally) have types specific in the function definition, we shouldn't also need them in the docstring. |
Thanks for the discussion. I do not care much about which docstring format we use, but more about picking up one and be consistent with it. If we choose a new one, we could use https://github.com/dadadel/pyment to convert existent docstrings if we want. To lint / enforce docstrings to follow a particular style, we could use https://docs.astral.sh/ruff/settings/#lint_pydocstyle_convention, since https://github.com/PyCQA/pydocstyle has been deprecated in favor of ruff. |
I can see this being useful to get started with some modules that are more important. These are the ones that I would start with
+1 |
|
Thanks for pinging! @holmanb I went into a rabbit hole: canonical/pycloudlib#374 |
ebcbb92
to
063f921
Compare
@TheRealFalcon @aciba90 @blackboxsw I just updated with a sphinx docstring fyi |
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.
This version LGTM, but lets give @blackboxsw and @aciba90 time for any additional bikeshedding.
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.
LGTM, thanks!
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.) |
@aciba90 I misread your earlier comment, my apologies. I thought that this was suggesting to add docstrings by default to all functions, but now that I've re-read I understand what you said.
Yes 100% agreed. I think that we should do a bulk update of all comments in the project (or at least in |
Additional Context
chore: Add docstrings and types to Version class