Skip to content

Commit

Permalink
🎨 apply ruff format
Browse files Browse the repository at this point in the history
Signed-off-by: ff137 <ff137@proton.me>
  • Loading branch information
ff137 committed Sep 16, 2024
1 parent 561a6dd commit 43da209
Show file tree
Hide file tree
Showing 57 changed files with 197 additions and 47 deletions.
4 changes: 3 additions & 1 deletion aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ async def _on_record_event(self, profile: Profile, event: Event):
if webhook_topic:
await self.send_webhook(profile, webhook_topic, event.payload)

async def send_webhook(self, profile: Profile, topic: str, payload: Optional[dict] = None):
async def send_webhook(
self, profile: Profile, topic: str, payload: Optional[dict] = None
):
"""Add a webhook to the queue, to send to all registered targets."""
wallet_id = profile.settings.get("wallet.id")
webhook_urls = profile.settings.get("admin.webhook_urls")
Expand Down
5 changes: 4 additions & 1 deletion aries_cloudagent/anoncreds/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ async def _get_credential(self, credential_id: str) -> Credential:
raise AnonCredsHolderError("Error loading requested credential") from err

async def credential_revoked(
self, credential_id: str, timestamp_from: Optional[int] = None, timestamp_to: Optional[int] = None
self,
credential_id: str,
timestamp_from: Optional[int] = None,
timestamp_to: Optional[int] = None,
) -> bool:
"""Check ledger for revocation status of credential by credential id.
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/askar/profile_anon.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def bind_providers(self):
BaseLedger, ClassProvider(IndyVdrLedger, self.ledger_pool, ref(self))
)

def session(self, context: Optional[InjectionContext] = None) -> "AskarAnoncredsProfileSession":
def session(
self, context: Optional[InjectionContext] = None
) -> "AskarAnoncredsProfileSession":
"""Start a new interactive session with no transaction support requested."""
return AskarAnoncredsProfileSession(self, False, context=context)

Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/cache/in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ async def get(self, key: Text):
self._remove_expired_cache_items()
return self._cache.get(key)["value"] if self._cache.get(key) else None

async def set(self, keys: Union[Text, Sequence[Text]], value: Any, ttl: Optional[int] = None):
async def set(
self, keys: Union[Text, Sequence[Text]], value: Any, ttl: Optional[int] = None
):
"""Add an item to the cache with an optional ttl.
Overwrites existing cache entries.
Expand Down
10 changes: 8 additions & 2 deletions aries_cloudagent/connections/models/conn_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ async def retrieve_by_did_peer_4(

@classmethod
async def retrieve_by_invitation_key(
cls, session: ProfileSession, invitation_key: str, their_role: Optional[str] = None
cls,
session: ProfileSession,
invitation_key: str,
their_role: Optional[str] = None,
) -> "ConnRecord":
"""Retrieve a connection record by invitation key.
Expand All @@ -354,7 +357,10 @@ async def retrieve_by_invitation_key(

@classmethod
async def retrieve_by_invitation_msg_id(
cls, session: ProfileSession, invitation_msg_id: str, their_role: Optional[str] = None
cls,
session: ProfileSession,
invitation_msg_id: str,
their_role: Optional[str] = None,
) -> Optional["ConnRecord"]:
"""Retrieve a connection record by invitation_msg_id.
Expand Down
10 changes: 8 additions & 2 deletions aries_cloudagent/core/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ async def setup(self):
)

def put_task(
self, coro: Coroutine, complete: Optional[Callable] = None, ident: Optional[str] = None
self,
coro: Coroutine,
complete: Optional[Callable] = None,
ident: Optional[str] = None,
) -> PendingTask:
"""Run a task in the task queue, potentially blocking other handlers."""
return self.task_queue.put(coro, complete, ident)

def run_task(
self, coro: Coroutine, complete: Optional[Callable] = None, ident: Optional[str] = None
self,
coro: Coroutine,
complete: Optional[Callable] = None,
ident: Optional[str] = None,
) -> asyncio.Task:
"""Run a task in the task queue, potentially blocking other handlers."""
return self.task_queue.run(coro, complete, ident)
Expand Down
6 changes: 5 additions & 1 deletion aries_cloudagent/indy/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ async def create_schema(
"""

def make_credential_definition_id(
self, origin_did: str, schema: dict, signature_type: Optional[str] = None, tag: Optional[str] = None
self,
origin_did: str,
schema: dict,
signature_type: Optional[str] = None,
tag: Optional[str] = None,
) -> str:
"""Derive the ID for a credential definition."""
signature_type = signature_type or DEFAULT_SIGNATURE_TYPE
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/indy/models/cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class Meta:

schema_class = "IndyAttrValueSchema"

def __init__(self, raw: Optional[str] = None, encoded: Optional[str] = None, **kwargs):
def __init__(
self, raw: Optional[str] = None, encoded: Optional[str] = None, **kwargs
):
"""Initialize indy (credential) attribute value."""
super().__init__(**kwargs)
self.raw = raw
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/indy/models/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ class Meta:

schema_class = "IndyRevRegEntrySchema"

def __init__(self, ver: Optional[str] = None, value: Optional[IndyRevRegEntryValue] = None):
def __init__(
self, ver: Optional[str] = None, value: Optional[IndyRevRegEntryValue] = None
):
"""Initialize."""

self.ver = ver
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/messaging/decorators/attach_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def build_protected(verkey: str):
)
self.jws_ = AttachDecoratorDataJWS.deserialize(jws)

async def verify(self, wallet: BaseWallet, signer_verkey: Optional[str] = None) -> bool:
async def verify(
self, wallet: BaseWallet, signer_verkey: Optional[str] = None
) -> bool:
"""Verify the signature(s).
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ class SimpleModel(BaseModel):
class Meta:
schema_class = "SimpleModelSchema"

def __init__(self, *, value: Optional[str] = None, handled_decorator: Optional[str] = None, **kwargs):
def __init__(
self,
*,
value: Optional[str] = None,
handled_decorator: Optional[str] = None,
**kwargs,
):
super().__init__(**kwargs)
self.handled_decorator = handled_decorator
self.value = value
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/multitenant/single_wallet_askar_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class SingleWalletAskarMultitenantManager(BaseMultitenantManager):

DEFAULT_MULTITENANT_WALLET_NAME = "multitenant_sub_wallet"

def __init__(self, profile: Profile, multitenant_profile: Optional[AskarProfile] = None):
def __init__(
self, profile: Profile, multitenant_profile: Optional[AskarProfile] = None
):
"""Initialize askar profile multitenant Manager.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class Meta:
message_type = PERFORM
schema_class = "PerformSchema"

def __init__(self, *, name: Optional[str] = None, params: Mapping[str, str] = None, **kwargs):
def __init__(
self, *, name: Optional[str] = None, params: Mapping[str, str] = None, **kwargs
):
"""Initialize a Perform object.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ class Meta:
message_type = PROBLEM_REPORT
schema_class = "ConnectionProblemReportSchema"

def __init__(self, *, problem_code: Optional[str] = None, explain: Optional[str] = None, **kwargs):
def __init__(
self,
*,
problem_code: Optional[str] = None,
explain: Optional[str] = None,
**kwargs,
):
"""Initialize a ProblemReport message instance.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Meta:

schema_class = "ConnectionDetailSchema"

def __init__(self, *, did: Optional[str] = None, did_doc: Optional[DIDDoc] = None, **kwargs):
def __init__(
self, *, did: Optional[str] = None, did_doc: Optional[DIDDoc] = None, **kwargs
):
"""Initialize a ConnectionDetail instance.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ async def request_denied(self, record: MediationRecord, deny: MediationDeny):
await record.save(session, reason="Mediation request denied.")

async def prepare_keylist_query(
self, filter_: Optional[dict] = None, paginate_limit: int = -1, paginate_offset: int = 0
self,
filter_: Optional[dict] = None,
paginate_limit: int = -1,
paginate_offset: int = 0,
) -> KeylistQuery:
"""Prepare keylist query message.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Represents a transaction resend message."""

from typing import Optional

from marshmallow import EXCLUDE, fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class Meta:
schema_class = "ForwardInvitationSchema"

def __init__(
self, *, invitation: Optional[ConnectionInvitation] = None, message: Optional[str] = None, **kwargs
self,
*,
invitation: Optional[ConnectionInvitation] = None,
message: Optional[str] = None,
**kwargs,
):
"""Initialize invitation object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ class Meta:
schema_class = "InvitationSchema"

def __init__(
self, *, invitation: Optional[ConnectionInvitation] = None, message: Optional[str] = None, **kwargs
self,
*,
invitation: Optional[ConnectionInvitation] = None,
message: Optional[str] = None,
**kwargs,
):
"""Initialize invitation object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Represents an request for an invitation from the introduction service."""

from typing import Optional

from marshmallow import EXCLUDE, fields
Expand All @@ -21,7 +22,9 @@ class Meta:
message_type = INVITATION_REQUEST
schema_class = "InvitationRequestSchema"

def __init__(self, *, responder: Optional[str] = None, message: Optional[str] = None, **kwargs):
def __init__(
self, *, responder: Optional[str] = None, message: Optional[str] = None, **kwargs
):
"""Initialize invitation request object.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class Meta:

schema_class = "CredAttrSpecSchema"

def __init__(self, *, name: str, value: str, mime_type: Optional[str] = None, **kwargs):
def __init__(
self, *, name: str, value: str, mime_type: Optional[str] = None, **kwargs
):
"""Initialize attribute preview object.
Args:
Expand Down Expand Up @@ -106,7 +108,11 @@ class Meta:
message_type = CREDENTIAL_PREVIEW

def __init__(
self, *, _type: Optional[str] = None, attributes: Sequence[CredAttrSpec] = None, **kwargs
self,
*,
_type: Optional[str] = None,
attributes: Sequence[CredAttrSpec] = None,
**kwargs,
):
"""Initialize credential preview object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
indy compatible, attachment is a valid verifiable credential
"""

import datetime
import json
import logging
Expand Down
5 changes: 4 additions & 1 deletion aries_cloudagent/protocols/issue_credential/v2_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ async def receive_offer(
return cred_ex_record

async def create_request(
self, cred_ex_record: V20CredExRecord, holder_did: str, comment: Optional[str] = None
self,
cred_ex_record: V20CredExRecord,
holder_did: str,
comment: Optional[str] = None,
) -> Tuple[V20CredExRecord, V20CredRequest]:
"""Create a credential request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class Meta:

schema_class = "V20CredAttrSpecSchema"

def __init__(self, *, name: str, value: str, mime_type: Optional[str] = None, **kwargs):
def __init__(
self, *, name: str, value: str, mime_type: Optional[str] = None, **kwargs
):
"""Initialize attribute preview object.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def __init__(
auto_remove: bool = True,
error_msg: Optional[str] = None,
trace: bool = False, # backward compat: BaseRecord.from_storage()
cred_id_stored: Optional[str] = None, # backward compat: BaseRecord.from_storage()
cred_id_stored: Optional[
str
] = None, # backward compat: BaseRecord.from_storage()
conn_id: Optional[str] = None, # backward compat: BaseRecord.from_storage()
by_format: Optional[Mapping] = None, # backward compat: BaseRecord.from_storage()
**kwargs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Linked data proof specific credential exchange information with non-secrets storage."""

from typing import Any, Optional, Sequence

from marshmallow import EXCLUDE, fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Represents an explicit RFC 15 ack message, adopted into present-proof protocol."""

from typing import Optional

from marshmallow import EXCLUDE, fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ class Meta:
message_type = PRESENTATION_ACK
schema_class = "PresentationAckSchema"

def __init__(self, status: Optional[str] = None, verification_result: Optional[str] = None, **kwargs):
def __init__(
self,
status: Optional[str] = None,
verification_result: Optional[str] = None,
**kwargs,
):
"""Initialize an explicit ack message instance.
Args:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A presentation request content message."""

from typing import Optional, Sequence

from marshmallow import EXCLUDE, fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""V2.0 present-proof indy presentation-exchange format handler."""

import json
import logging
from typing import Mapping, Optional, Tuple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""present-proof-v2 format handler - supports DIF and INDY."""

import logging
from abc import ABC, abstractclassmethod, abstractmethod
from typing import Optional, Tuple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A (proof) presentation content message."""

from typing import Optional, Sequence

from marshmallow import EXCLUDE, ValidationError, fields, validates_schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class Meta:
message_type = PRES_20_ACK
schema_class = "V20PresAckSchema"

def __init__(self, status: Optional[str] = None, verification_result: Optional[str] = None, **kwargs):
def __init__(
self,
status: Optional[str] = None,
verification_result: Optional[str] = None,
**kwargs,
):
"""Initialize an explicit ack message instance.
Args:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Revoke message."""

from typing import Optional

from marshmallow import fields, validate
Expand Down
Loading

0 comments on commit 43da209

Please sign in to comment.