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

ngclient: use Metadata.verify_delegate #1509

Merged

Conversation

sechkova
Copy link
Contributor

Fixes #1413

Description of the changes being introduced by the pull request:

Replace the helper verify_with_threshold() with
the newly implemented method Metadata.verify_delegate.

Please verify and check that the pull request fulfills the following
requirements
:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

Copy link
Collaborator

@MVrachev MVrachev left a comment

Choose a reason for hiding this comment

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

LGTM!
Love those prs where we are simplifying the codebase!

Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

The switch to Metadata.verify_delegate look great, but I'm confused as to why we have added extra typing annotations that were not required before?

@@ -408,7 +360,7 @@ def update_delegated_targets(
if self.snapshot is None:
raise RuntimeError("Cannot load targets before snapshot")

delegator = self.get(delegator_name)
delegator: Optional[Metadata] = self.get(delegator_name)
Copy link
Member

Choose a reason for hiding this comment

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

Are we annotating this as Optional so that mypy can understand that None is a valid value for delegator? Why wasn't this required before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, mypy was not complaining about this. I did it to help the code editor figure it out. I can separate it in another commit or explain it in the commit message if it looks weird in between the other changes.

Copy link
Member

Choose a reason for hiding this comment

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

It does look a bit out of place in this commit, though it's not an objectionable change by itself.

Replace the helper verify_with_threshold() with
the newly implemented method Metadata.verify_delegate.

Add an aditional type annotation helping the IDE.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

Thanks for the clean up!

@joshuagl joshuagl merged commit 98cc149 into theupdateframework:develop Jul 28, 2021
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.

ngclient: Use Metadata APIs verify_with_threshold() when possible
3 participants