Skip to content

Improve docstrings language in Metadata API - #1815

Merged
jku merged 4 commits into
theupdateframework:developfrom
ivanayov:metadata_docstrings_imprv
Feb 8, 2022
Merged

jku merged 4 commits into
theupdateframework:developfrom
ivanayov:metadata_docstrings_imprv

Conversation

@ivanayov

@ivanayov ivanayov commented Feb 1, 2022 •

Copy link
Copy Markdown
Collaborator

This change updates some obvious and unnecessary fields docs in the
Metadata API with more despriptive details, as well as unifies
syntax between different classes and methods

Addresses #1600

  • The code follows the Code Style Guidelines
  • [n/a] Tests have been added for the bug fix or new feature
  • [n/a] Docs have been added for the bug fix or new feature

Comment thread tuf/api/metadata.py
not break serialization from and deserialisation into a Metadta
object and thus aligns with the TUF specification implication that
unrecognized attribute-value fields should be supported
snapshot_meta: Meta information for snapshot metadata.

@ivanayov ivanayov Feb 1, 2022 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is one I wondered whether to edit or not. It relates to obvious and unnecessary information, but on the other side it's simple and correct. I wondered what's your opinion about explaining why it's available in the API - do you find such clarification good or rather unnecessary?

@jku jku Feb 2, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(reply to another comment)
Yeah documenting meta in a comprehensive manner requires a lot of specification context so maybe we leave it as is... The MetaFile type does clearly document its content after all.

@coveralls

coveralls commented Feb 1, 2022 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 1811764274

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 98.57%

Totals Coverage Status
Change from base Build 1811698342: 0.2%
Covered Lines: 1091
Relevant Lines: 1103

💛 - Coveralls

@jku jku left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wish this was in multiple commits so we could easily decide to only take some changes now and leave others for discussion... This issue should maybe have been split by change type to make that clearer that things like consistent double-backticks are easier to find a solution to than other issues (like consistent use of article where we need to decide what we want). The changes do conflict with each other so I can see why you did them all at once.

Anyway, I'll review but let's discuss if it makes sense to split this or to continue tweaking this PR.


There's a lot of good changes here, just commenting on potential issues.

I'm not sold on the use of indefinite article everywhere. It's fine in some places but looks quite bad in others:
threshold: A number of keys required to...
length: A length of the target file in bytes
those do not look right

Also the use of indefinite article is not consistent: there are still places that use definite article instead and the commit even adds a few new definite articles (see TargetFile methods for examples). I don't think 100% consistency is required but I don't understand how the article is chosen...

Overall, I think the indefinite article does not work in many places: In my opinion we should not standardize on it. I would maybe suggest a default choice of no article (since it makes docstrings shorter) and diverging from that if the context requires it.

Comment thread tuf/api/metadata.py
@classmethod
def from_dict(cls, metadata: Dict[str, Any]) -> "Metadata[T]":
"""Creates Metadata object from its dict representation.
"""Creates ``Metadata`` object from its dict representation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We say "dict representation" a lot as if it's obvious what that means :)

I don't have a great alternative suggestion, just commenting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be better non-abbreviated, i.e. "dictionary representation"? I think I used dict to keep it on one line.
Or would "json/dict representation" help people better associate it with the format described in the spec?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think "json/dict representation" is good. "dict" vs. "dictionary" is quite similar, while "json representation" should be obvious for everyone.

Comment thread tuf/api/metadata.py Resolved
Comment thread tuf/api/metadata.py Resolved
Comment thread tuf/api/metadata.py Resolved
Comment thread tuf/api/metadata.py Resolved
Comment thread tuf/api/metadata.py
not break serialization from and deserialisation into a Metadta
object and thus aligns with the TUF specification implication that
unrecognized attribute-value fields should be supported
snapshot_meta: Meta information for snapshot metadata.

@jku jku Feb 2, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(reply to another comment)
Yeah documenting meta in a comprehensive manner requires a lot of specification context so maybe we leave it as is... The MetaFile type does clearly document its content after all.

Comment thread tuf/api/metadata.py Resolved
@ivanayov
ivanayov force-pushed the metadata_docstrings_imprv branch from bda6099 to 9cde29a Compare February 2, 2022 17:21
@ivanayov

ivanayov commented Feb 2, 2022 •

Copy link
Copy Markdown
Collaborator Author

@jku Thank you for the review! I've split to several commits, as you advice. It's a bit harder to address feedback, as it should go to a specific commit in a single-file update, but I agree it's a better history at the end.

Comment thread tuf/api/metadata.py Resolved
@ivanayov
ivanayov force-pushed the metadata_docstrings_imprv branch from 9cde29a to 399a6a3 Compare February 2, 2022 19:05
Comment thread tuf/api/metadata.py Resolved
@ivanayov
ivanayov force-pushed the metadata_docstrings_imprv branch from 399a6a3 to a6a13f5 Compare February 3, 2022 14:37
@ivanayov

ivanayov commented Feb 3, 2022

Copy link
Copy Markdown
Collaborator Author

Python setup failed on windows.

@jku
jku self-requested a review February 7, 2022 10:22

@jku jku left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for the nice commits: I was expecting to suggest moving some commits to a later PR... but I think I actually agree with all of these, they seem to be clear improvements. Only thing that is a required fix is a rebase (merge is not currently clean)

There are things to improve in the docs but this is a big PR already and there's no need to fix everything at once, just leaving some comments:

  • I noticed some docstring errors and left comments: none of them seem to be your fault so feel free to either fix here or leave to next PR
  • The unrecognised_fields docstring feels about the right amount of detail to me -- maybe we 'd like to explain general concept in one place somewhere but individual docstrings look ok
  • Many arguments still explain "what" the argument is, not "why" it is: as an example we document signer argument with securesystemslib.signer.Signer implementation which does not explain why signer is an argument (what is it used for).

... but all of these can be handled in future improvements. I've re-run the tests after setup-python fixed itself: they look good.

Comment thread tuf/api/metadata.py Resolved
Comment thread tuf/api/metadata.py Resolved
Comment thread tuf/api/metadata.py Resolved
@lukpueh

lukpueh commented Feb 7, 2022

Copy link
Copy Markdown
Member

Thanks for working on this, @ivanayov and for reviewing, @jku! Let me know if you want more eyes.

Comment thread tuf/api/metadata.py Resolved
@ivanayov
ivanayov force-pushed the metadata_docstrings_imprv branch 2 times, most recently from a2893bd to 8b54971 Compare February 7, 2022 17:44
@ivanayov

ivanayov commented Feb 7, 2022 •

Copy link
Copy Markdown
Collaborator Author

Thank you @jku ! I addressed your comments here, as they are related to the changes anyway.
Changed

signer: ``securesystemslib.signer.Signer`` implementation

to

signer: ``securesystemslib.signer.Signer`` implementation containing a
signature and a keyid of the key that signature was generated with.

The other changes are just the fixes that you proposed + moving some of the existing changes to the right commit (I was a bit lazy to do that before addressing the comments 😁).

There are still some

data: Metadata content.
...
filename: Path to write the file to.
etc.

but I think there's enough context around them and adding explanations could make the docs too verbose and might rather confuse the user by creating expectations of some deeper meaning behind. Do you think that those should be better explained? @lukpueh do you have some preference, too?

@jku jku left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you. I think I would like to leave the signer argument improvements for later: It is significantly more difficult to explain "why" than "what" -- and this PR is long enough.

In practice:

signer: ``securesystemslib.signer.Signer`` implementation containing a
signature and a keyid of the key that signature was generated with.

this is slightly incorrect (signer does not contain a signature, it produces signatures) and still doesn't explain why there is a signer argument. Could you just leave the original description in and then we can continue tweaking these later?

@ivanayov
ivanayov force-pushed the metadata_docstrings_imprv branch from 8b54971 to 4a6ed8c Compare February 8, 2022 10:33
This change unifies quotes to double backtick across docs in the
Metadata API in order to provide better visualisation

Signed-off-by: Ivana Atanasova <[email protected]>
This change unifies wording across docs in the Metadata API, like
Args vs. Arguments and same repetitive descriptions written
differently in different classes/methods

Signed-off-by: Ivana Atanasova <[email protected]>
This change unifies as mush as the context allows and improves the
use of definite vs. indefinite vs. no article across docs in the
Metadata API. It sticks to no article in most cases for simplisity
and readability, but leaves definite article where it's strictly
necessary

Signed-off-by: Ivana Atanasova <[email protected]>
@lukpueh

lukpueh commented Feb 8, 2022

Copy link
Copy Markdown
Member

There are still some

data: Metadata content.
...
filename: Path to write the file to.
etc.

but I think there's enough context around them and adding explanations could make the docs too verbose and might rather confuse the user by creating expectations of some deeper meaning behind. Do you think that those should be better explained? @lukpueh do you have some preference, too?

I think both are okay. Especially the latter is actually adds useful information not provided by the arg name alone.

This change updates some obvious and unnecessary fields docs in the
Metadata API with more despriptive details

Signed-off-by: Ivana Atanasova <[email protected]>
@ivanayov
ivanayov force-pushed the metadata_docstrings_imprv branch from 4a6ed8c to 9169fcb Compare February 8, 2022 10:43
@ivanayov

ivanayov commented Feb 8, 2022

Copy link
Copy Markdown
Collaborator Author

@jku I removed the change.

@jku

jku commented Feb 8, 2022

Copy link
Copy Markdown
Member

Thanks!

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.

5 participants