Skip to content

Commit

Permalink
🎨 Replace deprecated ABC decorators (#3357)
Browse files Browse the repository at this point in the history
Signed-off-by: ff137 <[email protected]>
Co-authored-by: jamshale <[email protected]>
  • Loading branch information
ff137 and jamshale authored Nov 27, 2024
1 parent eb52b05 commit 27edc6e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
17 changes: 11 additions & 6 deletions acapy_agent/messaging/base_message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Base message."""

from abc import ABC, abstractclassmethod, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from enum import Enum, auto
from typing import TYPE_CHECKING, Optional, Type

Expand All @@ -23,26 +23,31 @@ class BaseMessage(ABC):
the context of the plugin.
"""

@abstractproperty
@property
@abstractmethod
def _type(self) -> str:
"""Return message type."""

@abstractproperty
@property
@abstractmethod
def _id(self) -> str:
"""Return message id."""

@abstractproperty
@property
@abstractmethod
def _thread_id(self) -> Optional[str]:
"""Return message thread id."""

@abstractmethod
def serialize(self, msg_format: DIDCommVersion = DIDCommVersion.v1) -> dict:
"""Return serialized message in format specified."""

@abstractclassmethod
@classmethod
@abstractmethod
def deserialize(cls, value: dict, msg_format: DIDCommVersion = DIDCommVersion.v1):
"""Return message object deserialized from value in format specified."""

@abstractproperty
@property
@abstractmethod
def Handler(self) -> Type["BaseHandler"]:
"""Return reference to handler class."""
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""V2.0 issue-credential base credential format handler."""

import logging
from abc import ABC, abstractclassmethod, abstractmethod
from abc import ABC, abstractmethod
from typing import Mapping, Optional, Tuple

from .....core.error import BaseError
Expand Down Expand Up @@ -60,7 +60,8 @@ def get_format_identifier(self, message_type: str) -> str:
def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment:
"""Get credential format and attachment objects for use in cred ex messages."""

@abstractclassmethod
@classmethod
@abstractmethod
def validate_fields(cls, message_type: str, attachment_data: dict) -> None:
"""Validate attachment data for specific message type and format."""

Expand Down
5 changes: 3 additions & 2 deletions acapy_agent/protocols/present_proof/v2_0/formats/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""present-proof-v2 format handler - supports ANONCREDS, DIF and INDY."""

import logging
from abc import ABC, abstractclassmethod, abstractmethod
from abc import ABC, abstractmethod
from typing import Optional, Tuple

from .....core.error import BaseError
Expand Down Expand Up @@ -56,7 +56,8 @@ def get_format_identifier(self, message_type: str) -> str:
def get_format_data(self, message_type: str, data: dict) -> PresFormatAttachment:
"""Get presentation format and attach objects for use in pres_ex messages."""

@abstractclassmethod
@classmethod
@abstractmethod
def validate_fields(cls, message_type: str, attachment_data: dict) -> None:
"""Validate attachment data for specific message type and format."""

Expand Down
8 changes: 5 additions & 3 deletions acapy_agent/vc/ld_proofs/crypto/key_pair.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Base key pair class."""

from abc import ABC, abstractmethod, abstractproperty
from abc import ABC, abstractmethod
from typing import List, Optional, Union


Expand All @@ -15,15 +15,17 @@ async def sign(self, message: Union[List[bytes], bytes]) -> bytes:
async def verify(self, message: Union[List[bytes], bytes], signature: bytes) -> bool:
"""Verify message(s) against signature using key pair."""

@abstractproperty
@property
@abstractmethod
def has_public_key(self) -> bool:
"""Whether key pair has a public key.
Public key is required for verification, but can be set dynamically
in the verification process.
"""

@abstractproperty
@property
@abstractmethod
def public_key(self) -> Optional[bytes]:
"""Getter for the public key bytes.
Expand Down

0 comments on commit 27edc6e

Please sign in to comment.