Skip to content
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

Various docstring and type annotation updates #953

Merged
merged 21 commits into from
Jul 4, 2023

Conversation

benhoyt
Copy link
Collaborator

@benhoyt benhoyt commented Jun 15, 2023

The intent here is to sprinkle a bit of consistency over our reference docs. There's currently a fair bit of duplication, lack of type information on attributes, or just unclear docs, and so on. One of the biggest changes was giving instance attributes proper type annotations and separating out and enhancing their docstrings.

I've spent 30 minutes or so a day on this for the last couple of weeks, and got through all the docs (viewable version here). It's not perfect, but I think it's a definite improvement for #920.

Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

ops/framework.py Outdated Show resolved Hide resolved
ops/model.py Show resolved Hide resolved
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@benhoyt benhoyt marked this pull request as ready for review June 30, 2023 02:31
Comment on lines +927 to +934
"""Set the name and UUID of the model that this is representing.

This cannot be called once begin() has been called. But it lets you set the value that
will be returned by Model.name and Model.uuid.
This cannot be called once :meth:`begin` has been called. But it lets
you set the value that will be returned by :attr:`Model.name <ops.Model.name>`
and :attr:`Model.uuid <ops.Model.uuid>`.

This is a convenience method to invoke both Harness.set_model_name
and Harness.set_model_uuid at once.
This is a convenience method to invoke both :meth:`set_model_name`
and :meth:`set_model_uuid` at once.
Copy link
Member

@jnsgruk jnsgruk Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit that shouldn't block the merge, but applies in a few places and would be good to clean up over time...

I'd prefer to remove the "you" - and stick with the imperative style (similar to commit messages).

Something like:

"""Set the name and UUID of the model this represents.

Cannot be called once :meth:`begin` has been called. Enables the 
value returned by `:attr:`Model.name <ops.Model.name>` and
:attr:`Model.uuid <ops.Model.uuid>` to be controlled.

Convenience method to invoke both :meth:`set_model_name`
and :meth:`set_model_uuid` at once.
"""

Another approach might be s/you/the developer/g but I still think the above is cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'm going to leave it for another PR so this one can avoid too much sprawl. Opened issue #959 to track.

Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor suggestions about how to improve the docstrings, doesn't need a second pass from my side. Looks like a great improvement!

ops/charm.py Show resolved Hide resolved
ops/charm.py Outdated Show resolved Hide resolved
ops/charm.py Show resolved Hide resolved
ops/charm.py Outdated Show resolved Hide resolved
ops/charm.py Show resolved Hide resolved
ops/charm.py Outdated Show resolved Hide resolved
ops/pebble.py Outdated Show resolved Hide resolved
@benhoyt benhoyt merged commit a747847 into canonical:main Jul 4, 2023
19 checks passed
@benhoyt benhoyt deleted the docstring-updates branch July 4, 2023 00:48
benhoyt added a commit that referenced this pull request Jul 4, 2023
One more thing forgotten from #953. This is annoying because it
means that charms that use ops.PebbleReadyEvent annotations
when handling pebble-ready can't access any attributes of the
workload, as it doesn't have a type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants