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

WIP: Fix implementation of abstract base classes (ABCs) to use Python3 syntax #465

Closed
wants to merge 2 commits into from

Conversation

joshuagl
Copy link
Collaborator

Fixes: #463

Description of the changes being introduced by the pull request:

Update the Signer and StorageBackendInterface bases classes to be abstract base classes. Due to the removal of the __metaclass__ attribute in Python 3 the current implementations are standard classes which can be instantiated.

The correct way to specify a metaclass in Python 3 is the metaclasss keyword argument: https://peps.python.org/pep-3115/

NOTE: this is marked as draft because I have not yet tested any securesystemslib dependents with this change.

Please verify and check that the pull request fulfils 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

The __metaclass__ attribute was removed in Python3 and the correct way
to specify a metaclass in Python 3 is the metaclasss keyword argument:
https://peps.python.org/pep-3115/

Signed-off-by: Joshua Lock <[email protected]>
The __metaclass__ attribute was removed in Python3 and the correct way
to specify a metaclass in Python 3 is the metaclasss keyword argument:
https://peps.python.org/pep-3115/

Signed-off-by: Joshua Lock <[email protected]>
Copy link
Collaborator

@jku jku left a comment

Choose a reason for hiding this comment

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

Looks correct to me

@lukpueh
Copy link
Member

lukpueh commented Nov 29, 2022

Before we fix our usage of abc, I'm curious to hear what you think about using Protocol (see #463 (comment)).

@joshuagl
Copy link
Collaborator Author

#456 resolves this issue for Signer by using the Python3 syntax to specify a metaclass. For StorageBackendInterface I think it makes sense to use a typing.Protocol, modulo Jussi's observation in #463 (comment) about implementations not declaring what they implement.

I'll close this PR and open a new one addressing only StorageBackendInterface

@joshuagl joshuagl closed this Nov 29, 2022
@joshuagl joshuagl deleted the joshuagl/abc branch November 29, 2022 16:53
@jku
Copy link
Collaborator

jku commented Nov 29, 2022

#456 resolves this issue for Signer by using the Python3 syntax to specify a metaclass

I think I actually only fixed Key (that is moved from pythontuf). But let's fix signer afterwards...

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.

Signer uses python2 "__metaclass__"
3 participants