From 4a8f825a0dc77027f8c8970a575e81bb93719ac5 Mon Sep 17 00:00:00 2001 From: ff137 Date: Mon, 16 Sep 2024 11:21:06 +0300 Subject: [PATCH 1/3] :art: add optional typing to method parameters with default value None Signed-off-by: ff137 --- aries_cloudagent/admin/server.py | 6 +- .../admin/tests/test_admin_server.py | 3 +- aries_cloudagent/anoncreds/base.py | 2 +- .../anoncreds/default/legacy_indy/registry.py | 8 +- aries_cloudagent/anoncreds/holder.py | 26 ++-- aries_cloudagent/anoncreds/util.py | 3 +- aries_cloudagent/askar/profile.py | 24 ++-- aries_cloudagent/askar/profile_anon.py | 24 ++-- aries_cloudagent/askar/store.py | 3 +- aries_cloudagent/cache/base.py | 2 +- aries_cloudagent/cache/in_memory.py | 4 +- aries_cloudagent/commands/upgrade.py | 2 +- aries_cloudagent/config/argparse.py | 6 +- aries_cloudagent/config/logging.py | 9 +- aries_cloudagent/config/plugin_settings.py | 2 +- aries_cloudagent/config/util.py | 6 +- .../connections/models/conn_record.py | 8 +- .../connections/models/diddoc/diddoc.py | 4 +- .../connections/models/diddoc/publickey.py | 5 +- .../connections/models/diddoc/util.py | 5 +- aries_cloudagent/core/conductor.py | 18 +-- aries_cloudagent/core/dispatcher.py | 12 +- aries_cloudagent/core/error.py | 3 +- aries_cloudagent/core/event_bus.py | 2 +- aries_cloudagent/core/in_memory/profile.py | 20 +-- aries_cloudagent/core/plugin_registry.py | 4 +- aries_cloudagent/core/profile.py | 10 +- .../core/tests/test_dispatcher.py | 3 +- aries_cloudagent/core/tests/test_profile.py | 5 +- aries_cloudagent/indy/credx/holder.py | 14 +-- aries_cloudagent/indy/credx/issuer.py | 10 +- aries_cloudagent/indy/holder.py | 14 +-- aries_cloudagent/indy/issuer.py | 12 +- aries_cloudagent/indy/models/cred.py | 18 +-- aries_cloudagent/indy/models/cred_abstract.py | 14 +-- aries_cloudagent/indy/models/cred_precis.py | 14 +-- aries_cloudagent/indy/models/cred_request.py | 12 +- .../indy/models/non_rev_interval.py | 5 +- aries_cloudagent/indy/models/pres_preview.py | 24 ++-- aries_cloudagent/indy/models/proof.py | 62 +++++----- aries_cloudagent/indy/models/proof_request.py | 14 +-- aries_cloudagent/indy/models/revocation.py | 34 ++--- aries_cloudagent/indy/models/xform.py | 4 +- aries_cloudagent/indy/util.py | 3 +- aries_cloudagent/ledger/base.py | 50 ++++---- aries_cloudagent/ledger/error.py | 4 +- aries_cloudagent/ledger/indy_vdr.py | 54 ++++---- .../multiple_ledger/indy_vdr_manager.py | 2 +- .../multiple_ledger/ledger_config_schema.py | 10 +- aries_cloudagent/ledger/tests/test_routes.py | 4 +- aries_cloudagent/messaging/agent_message.py | 6 +- .../messaging/decorators/attach_decorator.py | 74 +++++------ aries_cloudagent/messaging/decorators/base.py | 6 +- .../messaging/decorators/default.py | 4 +- .../decorators/localization_decorator.py | 4 +- .../decorators/please_ack_decorator.py | 4 +- .../decorators/signature_decorator.py | 9 +- .../decorators/tests/test_decorator_set.py | 3 +- .../messaging/decorators/timing_decorator.py | 4 +- .../messaging/decorators/trace_decorator.py | 22 ++-- .../decorators/transport_decorator.py | 8 +- aries_cloudagent/messaging/models/base.py | 2 +- .../messaging/models/base_record.py | 20 +-- aries_cloudagent/messaging/responder.py | 22 ++-- .../messaging/tests/test_agent_message.py | 3 +- aries_cloudagent/multitenant/base.py | 6 +- .../single_wallet_askar_manager.py | 2 +- .../protocols/actionmenu/v1_0/base_service.py | 9 +- .../actionmenu/v1_0/driver_service.py | 9 +- .../actionmenu/v1_0/messages/menu.py | 8 +- .../actionmenu/v1_0/messages/perform.py | 4 +- .../actionmenu/v1_0/models/menu_form.py | 8 +- .../actionmenu/v1_0/models/menu_form_param.py | 14 ++- .../actionmenu/v1_0/models/menu_option.py | 12 +- .../v1_0/messages/basicmessage.py | 6 +- .../protocols/connections/v1_0/manager.py | 10 +- .../v1_0/messages/connection_invitation.py | 12 +- .../v1_0/messages/connection_request.py | 8 +- .../v1_0/messages/connection_response.py | 4 +- .../v1_0/messages/problem_report.py | 3 +- .../v1_0/models/connection_detail.py | 4 +- .../coordinate_mediation/v1_0/manager.py | 2 +- .../v1_0/messages/inner/keylist_key.py | 8 +- .../v1_0/messages/inner/keylist_updated.py | 8 +- .../v1_0/messages/keylist.py | 4 +- .../v1_0/messages/keylist_query.py | 6 +- .../v1_0/messages/tests/__init__.py | 3 +- .../protocols/didexchange/v1_0/manager.py | 4 +- .../didexchange/v1_0/messages/response.py | 2 +- .../protocols/discovery/v2_0/manager.py | 8 +- .../discovery/v2_0/models/discovery_record.py | 8 +- .../endorse_transaction/v1_0/manager.py | 19 +-- .../v1_0/messages/cancel_transaction.py | 6 +- .../messages/endorsed_transaction_response.py | 14 ++- .../v1_0/messages/messages_attach.py | 14 +-- .../messages/refused_transaction_response.py | 12 +- .../messages/transaction_acknowledgement.py | 6 +- .../v1_0/messages/transaction_job_to_send.py | 4 +- .../v1_0/messages/transaction_request.py | 14 ++- .../v1_0/messages/transaction_resend.py | 5 +- .../v1_0/models/transaction_record.py | 24 ++-- .../introduction/v0_1/base_service.py | 3 +- .../v0_1/messages/forward_invitation.py | 4 +- .../introduction/v0_1/messages/invitation.py | 4 +- .../v0_1/messages/invitation_request.py | 3 +- .../issue_credential/v1_0/manager.py | 32 ++--- .../v1_0/messages/credential_issue.py | 6 +- .../v1_0/messages/credential_offer.py | 8 +- .../v1_0/messages/credential_proposal.py | 20 +-- .../v1_0/messages/credential_request.py | 6 +- .../v1_0/messages/inner/credential_preview.py | 6 +- .../v1_0/models/credential_exchange.py | 32 ++--- .../protocols/issue_credential/v1_0/routes.py | 9 +- .../issue_credential/v2_0/__init__.py | 4 +- .../v2_0/formats/anoncreds/handler.py | 6 +- .../issue_credential/v2_0/formats/handler.py | 6 +- .../v2_0/formats/indy/handler.py | 4 +- .../v2_0/formats/ld_proof/handler.py | 6 +- .../v2_0/formats/vc_di/handler.py | 7 +- .../v2_0/formats/vc_di/models/cred.py | 4 +- .../v2_0/formats/vc_di/models/cred_offer.py | 14 +-- .../v2_0/formats/vc_di/models/cred_request.py | 20 +-- .../issue_credential/v2_0/manager.py | 20 +-- .../v2_0/messages/cred_format.py | 6 +- .../v2_0/messages/cred_issue.py | 8 +- .../v2_0/messages/cred_offer.py | 10 +- .../v2_0/messages/cred_proposal.py | 8 +- .../v2_0/messages/cred_request.py | 6 +- .../v2_0/messages/inner/cred_preview.py | 6 +- .../v2_0/models/cred_ex_record.py | 28 ++--- .../v2_0/models/detail/indy.py | 14 +-- .../v2_0/models/detail/ld_proof.py | 9 +- .../protocols/issue_credential/v2_0/routes.py | 14 +-- .../notification/v1_0/messages/ack.py | 3 +- .../out_of_band/v1_0/messages/invitation.py | 2 +- .../out_of_band/v1_0/models/invitation.py | 14 +-- .../out_of_band/v1_0/models/oob_record.py | 2 +- .../protocols/present_proof/dif/pres_exch.py | 116 +++++++++--------- .../present_proof/dif/pres_exch_handler.py | 16 +-- .../protocols/present_proof/v1_0/manager.py | 18 +-- .../v1_0/messages/presentation.py | 6 +- .../v1_0/messages/presentation_ack.py | 4 +- .../v1_0/messages/presentation_proposal.py | 8 +- .../v1_0/messages/presentation_request.py | 7 +- .../v1_0/models/presentation_exchange.py | 22 ++-- .../v2_0/formats/anoncreds/handler.py | 7 +- .../present_proof/v2_0/formats/dif/handler.py | 2 +- .../present_proof/v2_0/formats/handler.py | 7 +- .../v2_0/formats/indy/handler.py | 6 +- .../protocols/present_proof/v2_0/manager.py | 14 +-- .../present_proof/v2_0/messages/pres.py | 7 +- .../present_proof/v2_0/messages/pres_ack.py | 4 +- .../v2_0/messages/pres_format.py | 6 +- .../v2_0/messages/pres_proposal.py | 6 +- .../v2_0/messages/pres_request.py | 8 +- .../v2_0/models/pres_exchange.py | 28 ++--- .../protocols/problem_report/v1_0/__init__.py | 4 +- .../protocols/problem_report/v1_0/message.py | 14 +-- .../v1_0/messages/revoke.py | 4 +- .../v1_0/models/rev_notification_record.py | 14 +-- .../v2_0/messages/revoke.py | 5 +- .../v2_0/models/rev_notification_record.py | 14 +-- .../protocols/routing/v1_0/manager.py | 10 +- .../routing/v1_0/messages/forward.py | 4 +- .../routing/v1_0/models/route_record.py | 11 +- .../protocols/trustping/v1_0/messages/ping.py | 3 +- .../trustping/v1_0/messages/ping_response.py | 4 +- aries_cloudagent/resolver/default/indy.py | 2 +- .../resolver/default/tests/test_universal.py | 4 +- aries_cloudagent/revocation/indy.py | 10 +- aries_cloudagent/revocation/manager.py | 22 ++-- aries_cloudagent/revocation/models/indy.py | 5 +- .../models/issuer_cred_rev_record.py | 24 ++-- .../models/issuer_rev_reg_record.py | 36 +++--- .../revocation/models/revocation_registry.py | 22 ++-- .../tests/test_issuer_rev_reg_record.py | 6 +- aries_cloudagent/revocation/util.py | 4 +- .../revocation_anoncreds/manager.py | 16 +-- .../models/issuer_cred_rev_record.py | 24 ++-- aries_cloudagent/storage/askar.py | 22 ++-- aries_cloudagent/storage/base.py | 25 ++-- aries_cloudagent/storage/in_memory.py | 25 ++-- aries_cloudagent/storage/vc_holder/askar.py | 12 +- aries_cloudagent/storage/vc_holder/base.py | 12 +- .../storage/vc_holder/in_memory.py | 15 ++- .../storage/vc_holder/vc_record.py | 8 +- aries_cloudagent/transport/inbound/base.py | 10 +- aries_cloudagent/transport/inbound/manager.py | 11 +- aries_cloudagent/transport/inbound/message.py | 8 +- aries_cloudagent/transport/inbound/receipt.py | 24 ++-- aries_cloudagent/transport/inbound/session.py | 12 +- aries_cloudagent/transport/outbound/base.py | 17 ++- aries_cloudagent/transport/outbound/http.py | 10 +- .../transport/outbound/manager.py | 12 +- .../transport/outbound/message.py | 16 +-- aries_cloudagent/transport/outbound/ws.py | 6 +- aries_cloudagent/transport/queue/base.py | 3 +- aries_cloudagent/transport/queue/basic.py | 3 +- aries_cloudagent/utils/classloader.py | 4 +- aries_cloudagent/utils/http.py | 17 +-- aries_cloudagent/utils/jwe.py | 18 +-- aries_cloudagent/utils/repeat.py | 3 +- aries_cloudagent/utils/stats.py | 8 +- aries_cloudagent/utils/task_queue.py | 35 +++--- aries_cloudagent/utils/tracing.py | 7 +- aries_cloudagent/vc/ld_proofs/check.py | 4 +- aries_cloudagent/vc/ld_proofs/ld_proofs.py | 4 +- aries_cloudagent/vc/ld_proofs/proof_set.py | 4 +- .../purposes/assertion_proof_purpose.py | 3 +- .../suites/bbs_bls_signature_proof_2020.py | 4 +- aries_cloudagent/vc/vc_di/prove.py | 4 +- aries_cloudagent/vc/vc_di/verify.py | 10 +- aries_cloudagent/vc/vc_ld/issue.py | 4 +- aries_cloudagent/vc/vc_ld/manager.py | 2 +- aries_cloudagent/vc/vc_ld/prove.py | 10 +- aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py | 9 +- aries_cloudagent/vc/vc_ld/verify.py | 18 +-- aries_cloudagent/wallet/askar.py | 8 +- aries_cloudagent/wallet/base.py | 12 +- aries_cloudagent/wallet/bbs.py | 4 +- aries_cloudagent/wallet/crypto.py | 8 +- aries_cloudagent/wallet/in_memory.py | 4 +- .../wallet/models/wallet_record.py | 8 +- aries_cloudagent/wallet/routes.py | 14 +-- aries_cloudagent/wallet/sd_jwt.py | 4 +- aries_cloudagent/wallet/util.py | 3 +- 226 files changed, 1278 insertions(+), 1202 deletions(-) diff --git a/aries_cloudagent/admin/server.py b/aries_cloudagent/admin/server.py index 58fa2d9eab..6834f9ec34 100644 --- a/aries_cloudagent/admin/server.py +++ b/aries_cloudagent/admin/server.py @@ -224,8 +224,8 @@ def __init__( outbound_message_router: Coroutine, webhook_router: Callable, conductor_stop: Coroutine, - task_queue: TaskQueue = None, - conductor_stats: Coroutine = None, + task_queue: Optional[TaskQueue] = None, + conductor_stats: Optional[Coroutine] = None, ): """Initialize an AdminServer instance. @@ -652,7 +652,7 @@ 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: 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") diff --git a/aries_cloudagent/admin/tests/test_admin_server.py b/aries_cloudagent/admin/tests/test_admin_server.py index 0772610a0d..c853a3710c 100644 --- a/aries_cloudagent/admin/tests/test_admin_server.py +++ b/aries_cloudagent/admin/tests/test_admin_server.py @@ -1,5 +1,6 @@ import gc import json +from typing import Optional from unittest import IsolatedAsyncioTestCase import pytest @@ -108,7 +109,7 @@ async def test_ready_middleware(self): await test_module.ready_middleware(request, handler) def get_admin_server( - self, settings: dict = None, context: InjectionContext = None + self, settings: Optional[dict] = None, context: Optional[InjectionContext] = None ) -> AdminServer: if not context: context = InjectionContext() diff --git a/aries_cloudagent/anoncreds/base.py b/aries_cloudagent/anoncreds/base.py index 87f0fb15a2..6cb5940bb2 100644 --- a/aries_cloudagent/anoncreds/base.py +++ b/aries_cloudagent/anoncreds/base.py @@ -46,7 +46,7 @@ def __init__( self, message: str, obj_id: str, - obj: T = None, + obj: Optional[T] = None, *args, **kwargs, ): diff --git a/aries_cloudagent/anoncreds/default/legacy_indy/registry.py b/aries_cloudagent/anoncreds/default/legacy_indy/registry.py index 5a2bf02acc..fc1c4229c3 100644 --- a/aries_cloudagent/anoncreds/default/legacy_indy/registry.py +++ b/aries_cloudagent/anoncreds/default/legacy_indy/registry.py @@ -805,7 +805,7 @@ async def _revoc_reg_entry_with_fix( rev_reg_def_type: str, entry: dict, write_ledger: bool, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Send a revocation registry entry to the ledger with fixes if needed.""" multitenant_mgr = profile.inject_or(BaseMultitenantManager) @@ -1078,7 +1078,7 @@ async def fix_ledger_entry( apply_ledger_update: bool, genesis_transactions: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[dict, dict, dict]: """Fix the ledger entry to match wallet-recorded credentials.""" @@ -1209,8 +1209,8 @@ async def txn_submit( self, ledger: BaseLedger, ledger_transaction: str, - sign: bool = None, - taa_accept: bool = None, + sign: Optional[bool] = None, + taa_accept: Optional[bool] = None, sign_did: DIDInfo = sentinel, write_ledger: bool = True, ) -> str: diff --git a/aries_cloudagent/anoncreds/holder.py b/aries_cloudagent/anoncreds/holder.py index 0fb3ac519d..17de18435b 100644 --- a/aries_cloudagent/anoncreds/holder.py +++ b/aries_cloudagent/anoncreds/holder.py @@ -178,9 +178,9 @@ async def store_credential( credential_definition: dict, credential_data: dict, credential_request_metadata: dict, - credential_attr_mime_types: dict = None, - credential_id: str = None, - rev_reg_def: dict = None, + credential_attr_mime_types: Optional[dict] = None, + credential_id: Optional[str] = None, + rev_reg_def: Optional[dict] = None, ) -> str: """Store a credential in the wallet. @@ -226,9 +226,9 @@ async def _finish_store_credential( credential_definition: dict, cred_recvd: Credential, credential_request_metadata: dict, - credential_attr_mime_types: dict = None, - credential_id: str = None, - rev_reg_def: dict = None, + credential_attr_mime_types: Optional[dict] = None, + credential_id: Optional[str] = None, + rev_reg_def: Optional[dict] = None, ) -> str: credential_data = cred_recvd.to_dict() schema_id = cred_recvd.schema_id @@ -288,9 +288,9 @@ async def store_credential_w3c( credential_definition: dict, credential_data: dict, credential_request_metadata: dict, - credential_attr_mime_types: dict = None, - credential_id: str = None, - rev_reg_def: dict = None, + credential_attr_mime_types: Optional[dict] = None, + credential_id: Optional[str] = None, + rev_reg_def: Optional[dict] = None, ) -> str: """Store a credential in the wallet. @@ -515,7 +515,7 @@ 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: int = None, timestamp_to: 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. @@ -565,7 +565,7 @@ async def delete_credential(self, credential_id: str): ) from err # noqa: E501 async def get_mime_type( - self, credential_id: str, attr: str = None + self, credential_id: str, attr: Optional[str] = None ) -> Union[dict, str]: """Get MIME type per attribute (or for all attributes). @@ -595,7 +595,7 @@ async def create_presentation( requested_credentials: dict, schemas: Dict[str, AnonCredsSchema], credential_definitions: Dict[str, CredDef], - rev_states: dict = None, + rev_states: Optional[dict] = None, ) -> str: """Get credentials stored in the wallet. @@ -686,7 +686,7 @@ async def create_presentation_w3c( credentials_w3c_metadata: list, schemas: Dict[str, AnonCredsSchema], credential_definitions: Dict[str, CredDef], - rev_states: dict = None, + rev_states: Optional[dict] = None, ) -> dict: """Get credentials stored in the wallet. diff --git a/aries_cloudagent/anoncreds/util.py b/aries_cloudagent/anoncreds/util.py index b6ba048df0..f1f8c662c1 100644 --- a/aries_cloudagent/anoncreds/util.py +++ b/aries_cloudagent/anoncreds/util.py @@ -4,6 +4,7 @@ from os.path import isdir, join from pathlib import Path from platform import system +from typing import Optional from aiohttp import web @@ -16,7 +17,7 @@ async def generate_pr_nonce() -> str: return str(int.from_bytes(urandom(10), "big")) -def indy_client_dir(subpath: str = None, create: bool = False) -> str: +def indy_client_dir(subpath: Optional[str] = None, create: bool = False) -> str: """Return '/'-terminated subdirectory of indy-client directory. Args: diff --git a/aries_cloudagent/askar/profile.py b/aries_cloudagent/askar/profile.py index f5379bb08e..aeeedb5eca 100644 --- a/aries_cloudagent/askar/profile.py +++ b/aries_cloudagent/askar/profile.py @@ -3,7 +3,7 @@ import asyncio import logging import time -from typing import Any, Mapping +from typing import Any, Mapping, Optional from weakref import ref from aries_askar import AskarError, Session, Store @@ -37,14 +37,14 @@ class AskarProfile(Profile): def __init__( self, opened: AskarOpenStore, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, *, - profile_id: str = None, + profile_id: Optional[str] = None, ): """Create a new AskarProfile instance.""" super().__init__(context=context, name=opened.name, created=opened.created) self.opened = opened - self.ledger_pool: IndyVdrLedgerPool = None + self.ledger_pool: Optional[IndyVdrLedgerPool] = None self.profile_id = profile_id self.init_ledger_pool() self.bind_providers() @@ -178,11 +178,11 @@ def bind_providers(self): ), ) - def session(self, context: InjectionContext = None) -> ProfileSession: + def session(self, context: Optional[InjectionContext] = None) -> ProfileSession: """Start a new interactive session with no transaction support requested.""" return AskarProfileSession(self, False, context=context) - def transaction(self, context: InjectionContext = None) -> ProfileSession: + def transaction(self, context: Optional[InjectionContext] = None) -> ProfileSession: """Start a new interactive session with commit and rollback support. If the current backend does not support transactions, then commit @@ -205,7 +205,7 @@ def __init__( profile: AskarProfile, is_txn: bool, *, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, settings: Mapping[str, Any] = None, ): """Create a new IndySdkProfileSession instance.""" @@ -215,9 +215,9 @@ def __init__( else: self._opener = self.profile.store.session(profile.profile_id) self._profile = profile - self._handle: Session = None - self._acquire_start: float = None - self._acquire_end: float = None + self._handle: Optional[Session] = None + self._acquire_start: Optional[float] = None + self._acquire_end: Optional[float] = None @property def handle(self) -> Session: @@ -288,7 +288,7 @@ async def _setup(self): ), ) - async def _teardown(self, commit: bool = None): + async def _teardown(self, commit: Optional[bool] = None): """Dispose of the session or transaction connection.""" if commit: try: @@ -338,6 +338,6 @@ async def open( return AskarProfile(opened, context) @classmethod - async def generate_store_key(self, seed: str = None) -> str: + async def generate_store_key(self, seed: Optional[str] = None) -> str: """Generate a raw store key.""" return Store.generate_raw_key(validate_seed(seed)) diff --git a/aries_cloudagent/askar/profile_anon.py b/aries_cloudagent/askar/profile_anon.py index fe17aeb827..437da10f20 100644 --- a/aries_cloudagent/askar/profile_anon.py +++ b/aries_cloudagent/askar/profile_anon.py @@ -3,7 +3,7 @@ import asyncio import logging import time -from typing import Any, Mapping +from typing import Any, Mapping, Optional from weakref import ref from aries_askar import AskarError, Session, Store @@ -39,14 +39,14 @@ class AskarAnoncredsProfile(Profile): def __init__( self, opened: AskarOpenStore, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, *, - profile_id: str = None, + profile_id: Optional[str] = None, ): """Create a new AskarProfile instance.""" super().__init__(context=context, name=opened.name, created=opened.created) self.opened = opened - self.ledger_pool: IndyVdrLedgerPool = None + self.ledger_pool: Optional[IndyVdrLedgerPool] = None self.profile_id = profile_id self.init_ledger_pool() self.bind_providers() @@ -159,12 +159,12 @@ def bind_providers(self): BaseLedger, ClassProvider(IndyVdrLedger, self.ledger_pool, ref(self)) ) - def session(self, context: 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) def transaction( - self, context: InjectionContext = None + self, context: Optional[InjectionContext] = None ) -> "AskarAnoncredsProfileSession": """Start a new interactive session with commit and rollback support. @@ -188,7 +188,7 @@ def __init__( profile: AskarAnoncredsProfile, is_txn: bool, *, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, settings: Mapping[str, Any] = None, ): """Create a new AskarAnoncredsProfileSession instance.""" @@ -198,9 +198,9 @@ def __init__( else: self._opener = self.profile.store.session(profile.profile_id) self._profile = profile - self._handle: Session = None - self._acquire_start: float = None - self._acquire_end: float = None + self._handle: Optional[Session] = None + self._acquire_start: Optional[float] = None + self._acquire_end: Optional[float] = None @property def handle(self) -> Session: @@ -239,7 +239,7 @@ async def _setup(self): ClassProvider("aries_cloudagent.storage.askar.AskarStorage", ref(self)), ) - async def _teardown(self, commit: bool = None): + async def _teardown(self, commit: Optional[bool] = None): """Dispose of the session or transaction connection.""" if commit: try: @@ -289,6 +289,6 @@ async def open( return AskarAnoncredsProfile(opened, context) @classmethod - async def generate_store_key(self, seed: str = None) -> str: + async def generate_store_key(self, seed: Optional[str] = None) -> str: """Generate a raw store key.""" return Store.generate_raw_key(validate_seed(seed)) diff --git a/aries_cloudagent/askar/store.py b/aries_cloudagent/askar/store.py index 82fb6ee996..898f42ca5e 100644 --- a/aries_cloudagent/askar/store.py +++ b/aries_cloudagent/askar/store.py @@ -3,6 +3,7 @@ import json import logging import urllib +from typing import Optional from aries_askar import AskarError, AskarErrorCode, Store @@ -24,7 +25,7 @@ class AskarStoreConfig: KEY_DERIVATION_ARGON2I_INT = "kdf:argon2i:int" KEY_DERIVATION_ARGON2I_MOD = "kdf:argon2i:mod" - def __init__(self, config: dict = None): + def __init__(self, config: Optional[dict] = None): """Initialize a `AskarWallet` instance. Args: diff --git a/aries_cloudagent/cache/base.py b/aries_cloudagent/cache/base.py index 1a1ae68797..a4916b1c51 100644 --- a/aries_cloudagent/cache/base.py +++ b/aries_cloudagent/cache/base.py @@ -84,7 +84,7 @@ class CacheKeyLock: def __init__(self, cache: BaseCache, key: Text): """Initialize the key lock.""" self.cache = cache - self.exception: BaseException = None + self.exception: Optional[BaseException] = None self.key = key self.released = False self._future: asyncio.Future = asyncio.get_event_loop().create_future() diff --git a/aries_cloudagent/cache/in_memory.py b/aries_cloudagent/cache/in_memory.py index 5be9b41e35..e6de5fed71 100644 --- a/aries_cloudagent/cache/in_memory.py +++ b/aries_cloudagent/cache/in_memory.py @@ -1,7 +1,7 @@ """Basic in-memory cache implementation.""" import time -from typing import Any, Sequence, Text, Union +from typing import Any, Optional, Sequence, Text, Union from .base import BaseCache @@ -38,7 +38,7 @@ 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: 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. diff --git a/aries_cloudagent/commands/upgrade.py b/aries_cloudagent/commands/upgrade.py index 58e4f58698..30724597cf 100644 --- a/aries_cloudagent/commands/upgrade.py +++ b/aries_cloudagent/commands/upgrade.py @@ -56,7 +56,7 @@ class UpgradeError(BaseError): class VersionUpgradeConfig: """Handle ACA-Py version upgrade config.""" - def __init__(self, config_path: str = None): + def __init__(self, config_path: Optional[str] = None): """Initialize config for use during upgrade process.""" self.function_map_config = UPGRADE_EXISTING_RECORDS_FUNCTION_MAPPING self.upgrade_configs = {} diff --git a/aries_cloudagent/config/argparse.py b/aries_cloudagent/config/argparse.py index 717169e5d0..b321eaad96 100644 --- a/aries_cloudagent/config/argparse.py +++ b/aries_cloudagent/config/argparse.py @@ -5,7 +5,7 @@ from functools import reduce from itertools import chain from os import environ -from typing import Type +from typing import Optional, Type import deepmerge import yaml @@ -55,14 +55,14 @@ def __call__(self, group_cls: ArgumentGroup): return group_cls @classmethod - def get_registered(cls, category: str = None): + def get_registered(cls, category: Optional[str] = None): """Fetch the set of registered classes in a category.""" return ( grp for (cats, grp) in cls._registered if category is None or category in cats ) -def create_argument_parser(*, prog: str = None): +def create_argument_parser(*, prog: Optional[str] = None): """Create am instance of an arg parser, force yaml format for external config.""" return ArgumentParser(config_file_parser_class=YAMLConfigFileParser, prog=prog) diff --git a/aries_cloudagent/config/logging.py b/aries_cloudagent/config/logging.py index 695b680dd2..0069782bd4 100644 --- a/aries_cloudagent/config/logging.py +++ b/aries_cloudagent/config/logging.py @@ -19,6 +19,7 @@ ) from logging.handlers import BaseRotatingHandler from random import randint +from typing import Optional import yaml from portalocker import LOCK_EX, lock, unlock @@ -57,7 +58,7 @@ def filter(self, record): return True -def load_resource(path: str, encoding: str = None): +def load_resource(path: str, encoding: Optional[str] = None): """Open a resource file located in a python package or the local filesystem. Args: @@ -148,9 +149,9 @@ class LoggingConfigurator: @classmethod def configure( cls, - log_config_path: str = None, - log_level: str = None, - log_file: str = None, + log_config_path: Optional[str] = None, + log_level: Optional[str] = None, + log_file: Optional[str] = None, multitenant: bool = False, ): """Configure logger. diff --git a/aries_cloudagent/config/plugin_settings.py b/aries_cloudagent/config/plugin_settings.py index a2830e87eb..006df02de8 100644 --- a/aries_cloudagent/config/plugin_settings.py +++ b/aries_cloudagent/config/plugin_settings.py @@ -61,7 +61,7 @@ def to_dict(self) -> dict: setting_dict[k] = self[k] return setting_dict - def get_value(self, *var_names: str, default: Any = None): + def get_value(self, *var_names: str, default: Optional[Any] = None): """Fetch a setting. Args: diff --git a/aries_cloudagent/config/util.py b/aries_cloudagent/config/util.py index 931bc8036b..df75496a7f 100644 --- a/aries_cloudagent/config/util.py +++ b/aries_cloudagent/config/util.py @@ -2,7 +2,7 @@ import os import re -from typing import Any, Mapping +from typing import Any, Mapping, Optional from configargparse import ArgumentTypeError @@ -27,7 +27,7 @@ def common_config(settings: Mapping[str, Any]): class BoundedInt: """Argument value parser for a bounded integer.""" - def __init__(self, min: int = None, max: int = None): + def __init__(self, min: Optional[int] = None, max: Optional[int] = None): """Initialize the ByteBoundedIntSize parser.""" self.min_val = min self.max_val = max @@ -56,7 +56,7 @@ def __repr__(self): class ByteSize: """Argument value parser for byte sizes.""" - def __init__(self, min: int = 0, max: int = None): + def __init__(self, min: int = 0, max: Optional[int] = None): """Initialize the ByteSize parser.""" self.min_size = min self.max_size = max diff --git a/aries_cloudagent/connections/models/conn_record.py b/aries_cloudagent/connections/models/conn_record.py index 9bdc81651c..3bd1a8c103 100644 --- a/aries_cloudagent/connections/models/conn_record.py +++ b/aries_cloudagent/connections/models/conn_record.py @@ -331,7 +331,7 @@ async def retrieve_by_did_peer_4( @classmethod async def retrieve_by_invitation_key( - cls, session: ProfileSession, invitation_key: str, their_role: str = None + cls, session: ProfileSession, invitation_key: str, their_role: Optional[str] = None ) -> "ConnRecord": """Retrieve a connection record by invitation key. @@ -354,7 +354,7 @@ async def retrieve_by_invitation_key( @classmethod async def retrieve_by_invitation_msg_id( - cls, session: ProfileSession, invitation_msg_id: str, their_role: str = None + cls, session: ProfileSession, invitation_msg_id: str, their_role: Optional[str] = None ) -> Optional["ConnRecord"]: """Retrieve a connection record by invitation_msg_id. @@ -396,7 +396,7 @@ async def find_existing_connection( @classmethod async def retrieve_by_request_id( - cls, session: ProfileSession, request_id: str, their_role: str = None + cls, session: ProfileSession, request_id: str, their_role: Optional[str] = None ) -> "ConnRecord": """Retrieve a connection record from our previous request ID. @@ -565,7 +565,7 @@ async def abandon(self, session: ProfileSession, *, reason: Optional[str] = None await self.save(session, reason=reason) async def metadata_get( - self, session: ProfileSession, key: str, default: Any = None + self, session: ProfileSession, key: str, default: Optional[Any] = None ) -> Any: """Retrieve arbitrary metadata associated with this connection. diff --git a/aries_cloudagent/connections/models/diddoc/diddoc.py b/aries_cloudagent/connections/models/diddoc/diddoc.py index 43fc2d7988..1075db62c4 100644 --- a/aries_cloudagent/connections/models/diddoc/diddoc.py +++ b/aries_cloudagent/connections/models/diddoc/diddoc.py @@ -18,7 +18,7 @@ import json import logging -from typing import List, Sequence, Union +from typing import List, Optional, Sequence, Union from ....did.did_key import DIDKey from .publickey import PublicKey, PublicKeyType @@ -37,7 +37,7 @@ class DIDDoc: CONTEXT = "https://w3id.org/did/v1" - def __init__(self, did: str = None) -> None: + def __init__(self, did: Optional[str] = None) -> None: """Initialize the DIDDoc instance. Retain DID ('id' in DIDDoc context); initialize verification keys diff --git a/aries_cloudagent/connections/models/diddoc/publickey.py b/aries_cloudagent/connections/models/diddoc/publickey.py index 1a8c5687a4..c247a9de04 100644 --- a/aries_cloudagent/connections/models/diddoc/publickey.py +++ b/aries_cloudagent/connections/models/diddoc/publickey.py @@ -18,6 +18,7 @@ from collections import namedtuple from enum import Enum +from typing import Optional from .util import canon_did, canon_ref @@ -100,8 +101,8 @@ def __init__( did: str, ident: str, value: str, - pk_type: PublicKeyType = None, - controller: str = None, + pk_type: Optional[PublicKeyType] = None, + controller: Optional[str] = None, authn: bool = False, ) -> None: """Retain key specification particulars. diff --git a/aries_cloudagent/connections/models/diddoc/util.py b/aries_cloudagent/connections/models/diddoc/util.py index 0301c3e19a..6a7fc9671e 100644 --- a/aries_cloudagent/connections/models/diddoc/util.py +++ b/aries_cloudagent/connections/models/diddoc/util.py @@ -16,12 +16,13 @@ limitations under the License. """ +from typing import Optional from urllib.parse import urlparse from base58 import b58decode -def resource(ref: str, delimiter: str = None) -> str: +def resource(ref: str, delimiter: Optional[str] = None) -> str: """Extract the resource for an identifier. Given a (URI) reference, return up to its delimiter (exclusively), or all of it if @@ -59,7 +60,7 @@ def canon_did(uri: str) -> str: ) -def canon_ref(did: str, ref: str, delimiter: str = None): +def canon_ref(did: str, ref: str, delimiter: Optional[str] = None): """Given a reference in a DID document, return it in its canonical form of a URI. Args: diff --git a/aries_cloudagent/core/conductor.py b/aries_cloudagent/core/conductor.py index 8706e55cda..b81d29636b 100644 --- a/aries_cloudagent/core/conductor.py +++ b/aries_cloudagent/core/conductor.py @@ -109,11 +109,11 @@ def __init__(self, context_builder: ContextBuilder) -> None: """ self.admin_server = None self.context_builder = context_builder - self.dispatcher: Dispatcher = None - self.inbound_transport_manager: InboundTransportManager = None - self.outbound_transport_manager: OutboundTransportManager = None - self.root_profile: Profile = None - self.setup_public_did: DIDInfo = None + self.dispatcher: Optional[Dispatcher] = None + self.inbound_transport_manager: Optional[InboundTransportManager] = None + self.outbound_transport_manager: Optional[OutboundTransportManager] = None + self.root_profile: Optional[Profile] = None + self.setup_public_did: Optional[DIDInfo] = None force_agent_anoncreds = False @@ -653,7 +653,7 @@ async def outbound_message_router( self, profile: Profile, outbound: OutboundMessage, - inbound: InboundMessage = None, + inbound: Optional[InboundMessage] = None, ) -> OutboundSendStatus: """Route an outbound message. @@ -672,7 +672,7 @@ async def _outbound_message_router( self, profile: Profile, outbound: OutboundMessage, - inbound: InboundMessage = None, + inbound: Optional[InboundMessage] = None, ) -> OutboundSendStatus: """Route an outbound message. @@ -768,8 +768,8 @@ def webhook_router( topic: str, payload: dict, endpoint: str, - max_attempts: int = None, - metadata: dict = None, + max_attempts: Optional[int] = None, + metadata: Optional[dict] = None, ): """Route a webhook through the outbound transport manager. diff --git a/aries_cloudagent/core/dispatcher.py b/aries_cloudagent/core/dispatcher.py index 517869307e..e69b4eb137 100644 --- a/aries_cloudagent/core/dispatcher.py +++ b/aries_cloudagent/core/dispatcher.py @@ -9,7 +9,7 @@ import os import warnings import weakref -from typing import Callable, Coroutine, Union +from typing import Callable, Coroutine, Optional, Union from aiohttp.web import HTTPException @@ -49,9 +49,9 @@ class Dispatcher: def __init__(self, profile: Profile): """Initialize an instance of Dispatcher.""" - self.collector: Collector = None + self.collector: Optional[Collector] = None self.profile = profile - self.task_queue: TaskQueue = None + self.task_queue: Optional[TaskQueue] = None self.logger: logging.Logger = logging.getLogger(__name__) async def setup(self): @@ -63,13 +63,13 @@ async def setup(self): ) def put_task( - self, coro: Coroutine, complete: Callable = None, ident: 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: Callable = None, ident: 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) @@ -95,7 +95,7 @@ def queue_message( profile: Profile, inbound_message: InboundMessage, send_outbound: Coroutine, - complete: Callable = None, + complete: Optional[Callable] = None, ) -> PendingTask: """Add a message to the processing queue for handling. diff --git a/aries_cloudagent/core/error.py b/aries_cloudagent/core/error.py index 0f2fc88074..f4deeccf17 100644 --- a/aries_cloudagent/core/error.py +++ b/aries_cloudagent/core/error.py @@ -1,12 +1,13 @@ """Common exception classes.""" import re +from typing import Optional class BaseError(Exception): """Generic exception class which other exceptions should inherit from.""" - def __init__(self, *args, error_code: str = None, **kwargs): + def __init__(self, *args, error_code: Optional[str] = None, **kwargs): """Initialize a BaseError instance.""" super().__init__(*args, **kwargs) self.error_code = error_code if error_code else None diff --git a/aries_cloudagent/core/event_bus.py b/aries_cloudagent/core/event_bus.py index 01fb319db4..af49a29064 100644 --- a/aries_cloudagent/core/event_bus.py +++ b/aries_cloudagent/core/event_bus.py @@ -28,7 +28,7 @@ class Event: """A simple event object.""" - def __init__(self, topic: str, payload: Any = None): + def __init__(self, topic: str, payload: Optional[Any] = None): """Create a new event.""" self._topic = topic self._payload = payload diff --git a/aries_cloudagent/core/in_memory/profile.py b/aries_cloudagent/core/in_memory/profile.py index 50c2e1fb39..1a9532102c 100644 --- a/aries_cloudagent/core/in_memory/profile.py +++ b/aries_cloudagent/core/in_memory/profile.py @@ -1,7 +1,7 @@ """Manage in-memory profile interaction.""" from collections import OrderedDict -from typing import Any, Mapping, Type +from typing import Any, Mapping, Optional, Type from weakref import ref from aries_askar import Session @@ -30,9 +30,9 @@ class InMemoryProfile(Profile): def __init__( self, *, - context: InjectionContext = None, - name: str = None, - profile_class: Any = None, + context: Optional[InjectionContext] = None, + name: Optional[str] = None, + profile_class: Optional[Any] = None, ): """Create a new InMemoryProfile instance.""" super().__init__(context=context, name=name, created=True) @@ -62,11 +62,11 @@ def bind_providers(self): ), ) - def session(self, context: InjectionContext = None) -> "ProfileSession": + def session(self, context: Optional[InjectionContext] = None) -> "ProfileSession": """Start a new interactive session with no transaction support requested.""" return InMemoryProfileSession(self, context=context) - def transaction(self, context: InjectionContext = None) -> "ProfileSession": + def transaction(self, context: Optional[InjectionContext] = None) -> "ProfileSession": """Start a new interactive session with commit and rollback support. If the current backend does not support transactions, then commit @@ -79,7 +79,7 @@ def test_profile( cls, settings: Mapping[str, Any] = None, bind: Mapping[Type, Any] = None, - profile_class: Any = None, + profile_class: Optional[Any] = None, ) -> "InMemoryProfile": """Used in tests to create a standard InMemoryProfile.""" profile = InMemoryProfile( @@ -100,7 +100,7 @@ def test_session( cls, settings: Mapping[str, Any] = None, bind: Mapping[Type, Any] = None, - profile_class: Any = None, + profile_class: Optional[Any] = None, ) -> "InMemoryProfileSession": """Used in tests to quickly create InMemoryProfileSession.""" if profile_class is not None: @@ -126,7 +126,7 @@ def __init__( self, profile: Profile, *, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, settings: Mapping[str, Any] = None, ): """Create a new InMemoryProfileSession instance.""" @@ -136,7 +136,7 @@ async def _setup(self): """Create the session or transaction connection, if needed.""" await super()._setup() self._init_context() - self._handle: Session = None + self._handle: Optional[Session] = None def _init_context(self): """Initialize the session context.""" diff --git a/aries_cloudagent/core/plugin_registry.py b/aries_cloudagent/core/plugin_registry.py index 27ca46eff3..b3fa709386 100644 --- a/aries_cloudagent/core/plugin_registry.py +++ b/aries_cloudagent/core/plugin_registry.py @@ -3,7 +3,7 @@ import logging from collections import OrderedDict from types import ModuleType -from typing import Iterable, Sequence +from typing import Iterable, Optional, Sequence from ..config.injection_context import InjectionContext from ..core.event_bus import EventBus @@ -215,7 +215,7 @@ async def load_protocol_version( self, context: InjectionContext, mod: ModuleType, - version_definition: dict = None, + version_definition: Optional[dict] = None, ): """Load a particular protocol version.""" protocol_registry = context.inject(ProtocolRegistry) diff --git a/aries_cloudagent/core/profile.py b/aries_cloudagent/core/profile.py index f5d66f5241..c861f594ac 100644 --- a/aries_cloudagent/core/profile.py +++ b/aries_cloudagent/core/profile.py @@ -20,7 +20,7 @@ class Profile(ABC): """Base abstraction for handling identity-related state.""" - BACKEND_NAME: str = None + BACKEND_NAME: Optional[str] = None DEFAULT_NAME: str = "default" def __init__( @@ -64,11 +64,11 @@ def settings(self) -> BaseSettings: return self._context.settings @abstractmethod - def session(self, context: InjectionContext = None) -> "ProfileSession": + def session(self, context: Optional[InjectionContext] = None) -> "ProfileSession": """Start a new interactive session with no transaction support requested.""" @abstractmethod - def transaction(self, context: InjectionContext = None) -> "ProfileSession": + def transaction(self, context: Optional[InjectionContext] = None) -> "ProfileSession": """Start a new interactive session with commit and rollback support. If the current backend does not support transactions, then commit @@ -157,7 +157,7 @@ def __init__( self, profile: Profile, *, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, settings: Mapping[str, Any] = None, ): """Initialize a base profile session.""" @@ -173,7 +173,7 @@ def __init__( async def _setup(self): """Create the underlying session or transaction.""" - async def _teardown(self, commit: bool = None): + async def _teardown(self, commit: Optional[bool] = None): """Dispose of the underlying session or transaction.""" def __await__(self): diff --git a/aries_cloudagent/core/tests/test_dispatcher.py b/aries_cloudagent/core/tests/test_dispatcher.py index c53eec0bb6..5885b67a94 100644 --- a/aries_cloudagent/core/tests/test_dispatcher.py +++ b/aries_cloudagent/core/tests/test_dispatcher.py @@ -1,4 +1,5 @@ import json +from typing import Optional from unittest import IsolatedAsyncioTestCase import pytest @@ -50,7 +51,7 @@ async def send( self, context: InjectionContext, message: OutboundMessage, - inbound: InboundMessage = None, + inbound: Optional[InboundMessage] = None, ): self.messages.append((context, message, inbound)) diff --git a/aries_cloudagent/core/tests/test_profile.py b/aries_cloudagent/core/tests/test_profile.py index c6284a8547..b275486db2 100644 --- a/aries_cloudagent/core/tests/test_profile.py +++ b/aries_cloudagent/core/tests/test_profile.py @@ -1,3 +1,4 @@ +from typing import Optional from unittest import IsolatedAsyncioTestCase from ...config.base import InjectionError @@ -7,10 +8,10 @@ class MockProfile(Profile): - def session(self, context: InjectionContext = None) -> ProfileSession: + def session(self, context: Optional[InjectionContext] = None) -> ProfileSession: """Start a new interactive session with no transaction support requested.""" - def transaction(self, context: InjectionContext = None) -> ProfileSession: + def transaction(self, context: Optional[InjectionContext] = None) -> ProfileSession: """ Start a new interactive session with commit and rollback support. diff --git a/aries_cloudagent/indy/credx/holder.py b/aries_cloudagent/indy/credx/holder.py index b09f01ca86..27ba7837e2 100644 --- a/aries_cloudagent/indy/credx/holder.py +++ b/aries_cloudagent/indy/credx/holder.py @@ -150,9 +150,9 @@ async def store_credential( credential_definition: dict, credential_data: dict, credential_request_metadata: dict, - credential_attr_mime_types: dict = None, - credential_id: str = None, - rev_reg_def: dict = None, + credential_attr_mime_types: Optional[dict] = None, + credential_id: Optional[str] = None, + rev_reg_def: Optional[dict] = None, ) -> str: """Store a credential in the wallet. @@ -375,8 +375,8 @@ async def credential_revoked( self, ledger: BaseLedger, credential_id: str, - timestamp_from: int = None, - timestamp_to: int = None, + timestamp_from: Optional[int] = None, + timestamp_to: Optional[int] = None, ) -> bool: """Check ledger for revocation status of credential by cred id. @@ -425,7 +425,7 @@ async def delete_credential(self, credential_id: str): raise IndyHolderError("Error deleting credential") from err async def get_mime_type( - self, credential_id: str, attr: str = None + self, credential_id: str, attr: Optional[str] = None ) -> Union[dict, str]: """Get MIME type per attribute (or for all attributes). @@ -455,7 +455,7 @@ async def create_presentation( requested_credentials: dict, schemas: dict, credential_definitions: dict, - rev_states: dict = None, + rev_states: Optional[dict] = None, ) -> str: """Get credentials stored in the wallet. diff --git a/aries_cloudagent/indy/credx/issuer.py b/aries_cloudagent/indy/credx/issuer.py index fc419e72c2..8cd857df9e 100644 --- a/aries_cloudagent/indy/credx/issuer.py +++ b/aries_cloudagent/indy/credx/issuer.py @@ -2,7 +2,7 @@ import asyncio import logging -from typing import Sequence, Tuple +from typing import Optional, Sequence, Tuple from aries_askar import AskarError from indy_credx import ( @@ -112,8 +112,8 @@ async def create_and_store_credential_definition( self, origin_did: str, schema: dict, - signature_type: str = None, - tag: str = None, + signature_type: Optional[str] = None, + tag: Optional[str] = None, support_revocation: bool = False, ) -> Tuple[str, str]: """Create a new credential definition and store it in the wallet. @@ -220,8 +220,8 @@ async def create_credential( credential_offer: dict, credential_request: dict, credential_values: dict, - revoc_reg_id: str = None, - tails_file_path: str = None, + revoc_reg_id: Optional[str] = None, + tails_file_path: Optional[str] = None, ) -> Tuple[str, str]: """Create a credential. diff --git a/aries_cloudagent/indy/holder.py b/aries_cloudagent/indy/holder.py index db1150c4dd..a8e0fe4886 100644 --- a/aries_cloudagent/indy/holder.py +++ b/aries_cloudagent/indy/holder.py @@ -1,7 +1,7 @@ """Base Indy Holder class.""" from abc import ABC, ABCMeta, abstractmethod -from typing import Tuple, Union +from typing import Optional, Tuple, Union from ..core.error import BaseError from ..ledger.base import BaseLedger @@ -40,8 +40,8 @@ async def credential_revoked( self, ledger: BaseLedger, credential_id: str, - timestamp_from: int = None, - timestamp_to: int = None, + timestamp_from: Optional[int] = None, + timestamp_to: Optional[int] = None, ) -> bool: """Check ledger for revocation status of credential by cred id. @@ -68,7 +68,7 @@ async def delete_credential(self, credential_id: str): @abstractmethod async def get_mime_type( - self, credential_id: str, attr: str = None + self, credential_id: str, attr: Optional[str] = None ) -> Union[dict, str]: """Get MIME type per attribute (or for all attributes). @@ -88,7 +88,7 @@ async def create_presentation( requested_credentials: dict, schemas: dict, credential_definitions: dict, - rev_states: dict = None, + rev_states: Optional[dict] = None, ) -> str: """Get credentials stored in the wallet. @@ -123,8 +123,8 @@ async def store_credential( credential_data: dict, credential_request_metadata: dict, credential_attr_mime_types=None, - credential_id: str = None, - rev_reg_def: dict = None, + credential_id: Optional[str] = None, + rev_reg_def: Optional[dict] = None, ): """Store a credential in the wallet. diff --git a/aries_cloudagent/indy/issuer.py b/aries_cloudagent/indy/issuer.py index 2fa531fec6..9ef0f8c52b 100644 --- a/aries_cloudagent/indy/issuer.py +++ b/aries_cloudagent/indy/issuer.py @@ -1,7 +1,7 @@ """Base Indy Issuer class.""" from abc import ABC, ABCMeta, abstractmethod -from typing import Sequence, Tuple +from typing import Optional, Sequence, Tuple from ..core.error import BaseError @@ -57,7 +57,7 @@ async def create_schema( """ def make_credential_definition_id( - self, origin_did: str, schema: dict, signature_type: str = None, tag: 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 @@ -79,8 +79,8 @@ async def create_and_store_credential_definition( self, origin_did: str, schema: dict, - signature_type: str = None, - tag: str = None, + signature_type: Optional[str] = None, + tag: Optional[str] = None, support_revocation: bool = False, ) -> Tuple[str, str]: """Create a new credential definition and store it in the wallet. @@ -118,8 +118,8 @@ async def create_credential( credential_offer: dict, credential_request: dict, credential_values: dict, - revoc_reg_id: str = None, - tails_file_path: str = None, + revoc_reg_id: Optional[str] = None, + tails_file_path: Optional[str] = None, ) -> Tuple[str, str]: """Create a credential. diff --git a/aries_cloudagent/indy/models/cred.py b/aries_cloudagent/indy/models/cred.py index 8875b8b436..477eb6c73c 100644 --- a/aries_cloudagent/indy/models/cred.py +++ b/aries_cloudagent/indy/models/cred.py @@ -1,6 +1,6 @@ """Credential artifacts.""" -from typing import Mapping +from typing import Mapping, Optional from marshmallow import EXCLUDE, ValidationError, fields @@ -25,7 +25,7 @@ class Meta: schema_class = "IndyAttrValueSchema" - def __init__(self, raw: str = None, encoded: 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 @@ -93,14 +93,14 @@ class Meta: def __init__( self, - schema_id: str = None, - cred_def_id: str = None, - rev_reg_id: str = None, + schema_id: Optional[str] = None, + cred_def_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, values: Mapping[str, IndyAttrValue] = None, - signature: Mapping = None, - signature_correctness_proof: Mapping = None, - rev_reg: Mapping = None, - witness: Mapping = None, + signature: Optional[Mapping] = None, + signature_correctness_proof: Optional[Mapping] = None, + rev_reg: Optional[Mapping] = None, + witness: Optional[Mapping] = None, ): """Initialize indy credential.""" self.schema_id = schema_id diff --git a/aries_cloudagent/indy/models/cred_abstract.py b/aries_cloudagent/indy/models/cred_abstract.py index dd3eaacee6..93ead3b69e 100644 --- a/aries_cloudagent/indy/models/cred_abstract.py +++ b/aries_cloudagent/indy/models/cred_abstract.py @@ -1,6 +1,6 @@ """Cred abstract artifacts to attach to RFC 453 messages.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -25,8 +25,8 @@ class Meta: def __init__( self, - c: str = None, - xz_cap: str = None, + c: Optional[str] = None, + xz_cap: Optional[str] = None, xr_cap: Sequence[Sequence[str]] = None, **kwargs, ): @@ -92,10 +92,10 @@ class Meta: def __init__( self, - schema_id: str = None, - cred_def_id: str = None, - nonce: str = None, - key_correctness_proof: str = None, + schema_id: Optional[str] = None, + cred_def_id: Optional[str] = None, + nonce: Optional[str] = None, + key_correctness_proof: Optional[str] = None, **kwargs, ): """Initialize indy cred abstract object. diff --git a/aries_cloudagent/indy/models/cred_precis.py b/aries_cloudagent/indy/models/cred_precis.py index ab2f0f3e8c..26b8e587ea 100644 --- a/aries_cloudagent/indy/models/cred_precis.py +++ b/aries_cloudagent/indy/models/cred_precis.py @@ -1,6 +1,6 @@ """Admin routes for presentations.""" -from typing import Mapping +from typing import Mapping, Optional from marshmallow import EXCLUDE, fields @@ -30,12 +30,12 @@ class Meta: def __init__( self, - referent: str = None, - attrs: Mapping = None, - schema_id: str = None, - cred_def_id: str = None, - rev_reg_id: str = None, - cred_rev_id: str = None, + referent: Optional[str] = None, + attrs: Optional[Mapping] = None, + schema_id: Optional[str] = None, + cred_def_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + cred_rev_id: Optional[str] = None, ): """Initialize indy cred info.""" self.referent = referent diff --git a/aries_cloudagent/indy/models/cred_request.py b/aries_cloudagent/indy/models/cred_request.py index f43bbf89d2..a2913fad64 100644 --- a/aries_cloudagent/indy/models/cred_request.py +++ b/aries_cloudagent/indy/models/cred_request.py @@ -1,6 +1,6 @@ """Cred request artifacts to attach to RFC 453 messages.""" -from typing import Mapping +from typing import Mapping, Optional from marshmallow import EXCLUDE, fields @@ -24,11 +24,11 @@ class Meta: def __init__( self, - prover_did: str = None, - cred_def_id: str = None, - blinded_ms: Mapping = None, - blinded_ms_correctness_proof: Mapping = None, - nonce: str = None, + prover_did: Optional[str] = None, + cred_def_id: Optional[str] = None, + blinded_ms: Optional[Mapping] = None, + blinded_ms_correctness_proof: Optional[Mapping] = None, + nonce: Optional[str] = None, **kwargs, ): """Initialize indy credential request.""" diff --git a/aries_cloudagent/indy/models/non_rev_interval.py b/aries_cloudagent/indy/models/non_rev_interval.py index 3951f20a5a..58392c4384 100644 --- a/aries_cloudagent/indy/models/non_rev_interval.py +++ b/aries_cloudagent/indy/models/non_rev_interval.py @@ -1,6 +1,7 @@ """Indy non-revocation interval.""" from time import time +from typing import Optional from marshmallow import EXCLUDE, fields @@ -16,7 +17,7 @@ class Meta: schema_class = "IndyNonRevocationIntervalSchema" - def __init__(self, fro: int = None, to: int = None, **kwargs): + def __init__(self, fro: Optional[int] = None, to: Optional[int] = None, **kwargs): """Initialize non-revocation interval. Args: @@ -29,7 +30,7 @@ def __init__(self, fro: int = None, to: int = None, **kwargs): self.fro = fro self.to = to - def covers(self, timestamp: int = None) -> bool: + def covers(self, timestamp: Optional[int] = None) -> bool: """Whether input timestamp (default now) lies within non-revocation interval. Args: diff --git a/aries_cloudagent/indy/models/pres_preview.py b/aries_cloudagent/indy/models/pres_preview.py index 44ad053061..496c1e93cd 100644 --- a/aries_cloudagent/indy/models/pres_preview.py +++ b/aries_cloudagent/indy/models/pres_preview.py @@ -2,7 +2,7 @@ from enum import Enum from time import time -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from marshmallow import EXCLUDE, fields @@ -41,7 +41,7 @@ def __init__( self, name: str, *, - cred_def_id: str = None, + cred_def_id: Optional[str] = None, predicate: str, threshold: int, **kwargs, @@ -129,10 +129,10 @@ class Posture(Enum): def __init__( self, name: str, - cred_def_id: str = None, - mime_type: str = None, - value: str = None, - referent: str = None, + cred_def_id: Optional[str] = None, + mime_type: Optional[str] = None, + value: Optional[str] = None, + referent: Optional[str] = None, **kwargs, ): """Initialize attribute specification object. @@ -156,7 +156,7 @@ def __init__( self.referent = referent @staticmethod - def list_plain(plain: dict, cred_def_id: str, referent: str = None): + def list_plain(plain: dict, cred_def_id: str, referent: Optional[str] = None): """Return a list of `IndyPresAttrSpec` on input cred def id. Args: @@ -269,7 +269,7 @@ class Meta: def __init__( self, *, - _type: str = None, + _type: Optional[str] = None, attributes: Sequence[IndyPresAttrSpec] = None, predicates: Sequence[IndyPresPredSpec] = None, **kwargs, @@ -315,10 +315,10 @@ def has_attr_spec(self, cred_def_id: str, name: str, value: str) -> bool: async def indy_proof_request( self, - profile: Profile = None, - name: str = None, - version: str = None, - nonce: str = None, + profile: Optional[Profile] = None, + name: Optional[str] = None, + version: Optional[str] = None, + nonce: Optional[str] = None, non_revoc_intervals: Mapping[str, IndyNonRevocationInterval] = None, ) -> dict: """Return indy proof request corresponding to presentation preview. diff --git a/aries_cloudagent/indy/models/proof.py b/aries_cloudagent/indy/models/proof.py index e74fcd8738..f0222863f4 100644 --- a/aries_cloudagent/indy/models/proof.py +++ b/aries_cloudagent/indy/models/proof.py @@ -1,6 +1,6 @@ """Marshmallow bindings for indy proofs.""" -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from marshmallow import EXCLUDE, fields, validate @@ -38,11 +38,11 @@ class Meta: def __init__( self, revealed_attrs: Mapping[str, str] = None, - a_prime: str = None, - e: str = None, - v: str = None, + a_prime: Optional[str] = None, + e: Optional[str] = None, + v: Optional[str] = None, m: Mapping[str, str] = None, - m2: str = None, + m2: Optional[str] = None, **kwargs, ): """Initialize equality proof object.""" @@ -100,9 +100,9 @@ class Meta: def __init__( self, - attr_name: str = None, - p_type: str = None, - value: int = None, + attr_name: Optional[str] = None, + p_type: Optional[str] = None, + value: Optional[int] = None, **kwargs, ): """Initialize indy GE proof predicate.""" @@ -143,10 +143,10 @@ def __init__( self, u: Mapping[str, str] = None, r: Mapping[str, str] = None, - mj: str = None, - alpha: str = None, + mj: Optional[str] = None, + alpha: Optional[str] = None, t: Mapping[str, str] = None, - predicate: IndyGEProofPred = None, + predicate: Optional[IndyGEProofPred] = None, **kwargs, ): """Initialize GE proof object.""" @@ -205,7 +205,7 @@ class Meta: def __init__( self, - eq_proof: IndyEQProof = None, + eq_proof: Optional[IndyEQProof] = None, ge_proofs: Sequence[IndyGEProof] = None, **kwargs, ): @@ -247,8 +247,8 @@ class Meta: def __init__( self, - x_list: Mapping = None, - c_list: Mapping = None, + x_list: Optional[Mapping] = None, + c_list: Optional[Mapping] = None, **kwargs, ): """Initialize indy non-revocation proof.""" @@ -280,8 +280,8 @@ class Meta: def __init__( self, - primary_proof: IndyPrimaryProof = None, - non_revoc_proof: IndyNonRevocProof = None, + primary_proof: Optional[IndyPrimaryProof] = None, + non_revoc_proof: Optional[IndyNonRevocProof] = None, **kwargs, ): """Initialize proof.proof.proofs constituent proof.""" @@ -319,7 +319,7 @@ class Meta: def __init__( self, - c_hash: str = None, + c_hash: Optional[str] = None, c_list: Sequence[Sequence[int]] = None, **kwargs, ): @@ -356,7 +356,7 @@ class Meta: def __init__( self, proofs: Sequence[IndyProofProofProofsProof] = None, - aggregated_proof: IndyProofProofAggregatedProof = None, + aggregated_proof: Optional[IndyProofProofAggregatedProof] = None, **kwargs, ): """Initialize indy proof.proof content.""" @@ -395,8 +395,8 @@ class Meta: def __init__( self, - raw: str = None, - encoded: str = None, + raw: Optional[str] = None, + encoded: Optional[str] = None, **kwargs, ): """Initialize raw and encoded attribute values.""" @@ -431,7 +431,7 @@ class Meta: def __init__( self, - sub_proof_index: int = None, + sub_proof_index: Optional[int] = None, **kwargs, ): """Initialize indy proof requested proof revealed attr.""" @@ -463,7 +463,7 @@ class Meta: def __init__( self, - sub_proof_index: int = None, + sub_proof_index: Optional[int] = None, values: Mapping[str, RawEncoded] = None, **kwargs, ): @@ -504,7 +504,7 @@ class Meta: def __init__( self, - sub_proof_index: int = None, + sub_proof_index: Optional[int] = None, **kwargs, ): """Initialize indy proof requested proof predicate.""" @@ -541,8 +541,8 @@ def __init__( str, IndyProofRequestedProofRevealedAttrGroup, ] = None, - self_attested_attrs: Mapping = None, - unrevealed_attrs: Mapping = None, + self_attested_attrs: Optional[Mapping] = None, + unrevealed_attrs: Optional[Mapping] = None, predicates: Mapping[str, IndyProofRequestedProofPredicate] = None, **kwargs, ): @@ -597,10 +597,10 @@ class Meta: def __init__( self, - schema_id: str = None, - cred_def_id: str = None, - rev_reg_id: str = None, - timestamp: int = None, + schema_id: Optional[str] = None, + cred_def_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + timestamp: Optional[int] = None, **kwargs, ): """Initialize indy proof identifier.""" @@ -663,8 +663,8 @@ class Meta: def __init__( self, - proof: IndyProofProof = None, - requested_proof: IndyProofRequestedProof = None, + proof: Optional[IndyProofProof] = None, + requested_proof: Optional[IndyProofRequestedProof] = None, identifiers: Sequence[IndyProofIdentifier] = None, **kwargs, ): diff --git a/aries_cloudagent/indy/models/proof_request.py b/aries_cloudagent/indy/models/proof_request.py index a94e34c1e8..1c87ecf454 100644 --- a/aries_cloudagent/indy/models/proof_request.py +++ b/aries_cloudagent/indy/models/proof_request.py @@ -1,6 +1,6 @@ """Utilities to deal with indy.""" -from typing import Mapping +from typing import Mapping, Optional from marshmallow import ( EXCLUDE, @@ -198,12 +198,12 @@ class Meta: def __init__( self, - nonce: str = None, - name: str = None, - version: str = None, - requested_attributes: Mapping = None, - requested_predicates: Mapping = None, - non_revoked: Mapping = None, + nonce: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + requested_attributes: Optional[Mapping] = None, + requested_predicates: Optional[Mapping] = None, + non_revoked: Optional[Mapping] = None, **kwargs, ): """Initialize indy cred abstract object. diff --git a/aries_cloudagent/indy/models/revocation.py b/aries_cloudagent/indy/models/revocation.py index ec699ea776..528b8d073a 100644 --- a/aries_cloudagent/indy/models/revocation.py +++ b/aries_cloudagent/indy/models/revocation.py @@ -1,6 +1,6 @@ """Revocation artifacts.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields, validate @@ -27,7 +27,7 @@ class Meta: schema_class = "IndyRevRegDefValuePublicKeysAccumKeySchema" - def __init__(self, z: str = None): + def __init__(self, z: Optional[str] = None): """Initialize.""" self.z = z @@ -58,7 +58,7 @@ class Meta: schema_class = "IndyRevRegDefValuePublicKeysSchema" - def __init__(self, accum_key: IndyRevRegDefValuePublicKeysAccumKey = None): + def __init__(self, accum_key: Optional[IndyRevRegDefValuePublicKeysAccumKey] = None): """Initialize.""" self.accum_key = accum_key @@ -88,11 +88,11 @@ class Meta: def __init__( self, - issuance_type: str = None, - max_cred_num: int = None, - public_keys: IndyRevRegDefValuePublicKeys = None, - tails_hash: str = None, - tails_location: str = None, + issuance_type: Optional[str] = None, + max_cred_num: Optional[int] = None, + public_keys: Optional[IndyRevRegDefValuePublicKeys] = None, + tails_hash: Optional[str] = None, + tails_location: Optional[str] = None, ): """Initialize.""" self.issuance_type = issuance_type @@ -153,12 +153,12 @@ class Meta: def __init__( self, - ver: str = None, - id_: str = None, - revoc_def_type: str = None, - tag: str = None, - cred_def_id: str = None, - value: IndyRevRegDefValue = None, + ver: Optional[str] = None, + id_: Optional[str] = None, + revoc_def_type: Optional[str] = None, + tag: Optional[str] = None, + cred_def_id: Optional[str] = None, + value: Optional[IndyRevRegDefValue] = None, ): """Initialize.""" @@ -227,8 +227,8 @@ class Meta: def __init__( self, - prev_accum: str = None, - accum: str = None, + prev_accum: Optional[str] = None, + accum: Optional[str] = None, revoked: Sequence[int] = None, ): """Initialize.""" @@ -275,7 +275,7 @@ class Meta: schema_class = "IndyRevRegEntrySchema" - def __init__(self, ver: str = None, value: IndyRevRegEntryValue = None): + def __init__(self, ver: Optional[str] = None, value: Optional[IndyRevRegEntryValue] = None): """Initialize.""" self.ver = ver diff --git a/aries_cloudagent/indy/models/xform.py b/aries_cloudagent/indy/models/xform.py index b3870baa6d..6e80794889 100644 --- a/aries_cloudagent/indy/models/xform.py +++ b/aries_cloudagent/indy/models/xform.py @@ -1,12 +1,14 @@ """Utilities to deal with indy.""" +from typing import Optional + from ...indy.holder import IndyHolder from .pres_preview import IndyPresPreview async def indy_proof_req_preview2indy_requested_creds( indy_proof_req: dict, - preview: IndyPresPreview = None, + preview: Optional[IndyPresPreview] = None, *, holder: IndyHolder, ): diff --git a/aries_cloudagent/indy/util.py b/aries_cloudagent/indy/util.py index 096c39c413..c42b83fab7 100644 --- a/aries_cloudagent/indy/util.py +++ b/aries_cloudagent/indy/util.py @@ -4,6 +4,7 @@ from os.path import isdir, join from pathlib import Path from platform import system +from typing import Optional async def generate_pr_nonce() -> str: @@ -12,7 +13,7 @@ async def generate_pr_nonce() -> str: return str(int.from_bytes(urandom(10), "big")) -def indy_client_dir(subpath: str = None, create: bool = False) -> str: +def indy_client_dir(subpath: Optional[str] = None, create: bool = False) -> str: """Return '/'-terminated subdirectory of indy-client directory. Args: diff --git a/aries_cloudagent/ledger/base.py b/aries_cloudagent/ledger/base.py index 48d61e2c25..bba161ef24 100644 --- a/aries_cloudagent/ledger/base.py +++ b/aries_cloudagent/ledger/base.py @@ -6,7 +6,7 @@ from abc import ABC, ABCMeta, abstractmethod from enum import Enum from hashlib import sha256 -from typing import List, Sequence, Tuple, Union +from typing import List, Optional, Sequence, Tuple, Union from ..indy.issuer import DEFAULT_CRED_DEF_TAG, IndyIssuer, IndyIssuerError from ..messaging.valid import IndyDID @@ -26,7 +26,7 @@ class BaseLedger(ABC, metaclass=ABCMeta): """Base class for ledger.""" - BACKEND_NAME: str = None + BACKEND_NAME: Optional[str] = None async def __aenter__(self) -> "BaseLedger": """Context manager entry. @@ -84,8 +84,8 @@ async def get_all_endpoints_for_did(self, did: str) -> dict: async def _construct_attr_json( self, endpoint: str, - endpoint_type: EndpointType = None, - all_exist_endpoints: dict = None, + endpoint_type: Optional[EndpointType] = None, + all_exist_endpoints: Optional[dict] = None, routing_keys: List[str] = None, ) -> str: """Create attr_json string. @@ -119,7 +119,7 @@ async def update_endpoint_for_did( endpoint: str, endpoint_type: EndpointType = EndpointType.ENDPOINT, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, routing_keys: List[str] = None, ) -> bool: """Check and update the endpoint on the ledger. @@ -138,10 +138,10 @@ async def register_nym( self, did: str, verkey: str, - alias: str = None, - role: str = None, + alias: Optional[str] = None, + role: Optional[str] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[bool, dict]: """Register a nym on the ledger. @@ -167,7 +167,7 @@ def nym_to_did(self, nym: str) -> str: """Format a nym with the ledger's DID prefix.""" @abstractmethod - async def rotate_public_did_keypair(self, next_seed: str = None) -> None: + async def rotate_public_did_keypair(self, next_seed: Optional[str] = None) -> None: """Rotate keypair for public DID: create new key, submit to ledger, update wallet. Args: @@ -193,7 +193,7 @@ async def fetch_txn_author_agreement(self): @abstractmethod async def accept_txn_author_agreement( - self, taa_record: dict, mechanism: str, accept_time: int = None + self, taa_record: dict, mechanism: str, accept_time: Optional[int] = None ): """Save a new record recording the acceptance of the TAA.""" @@ -212,7 +212,7 @@ def taa_digest(self, version: str, text: str): async def txn_endorse( self, request_json: str, - endorse_did: DIDInfo = None, + endorse_did: Optional[DIDInfo] = None, ) -> str: """Endorse (sign) the provided transaction.""" @@ -221,7 +221,7 @@ async def txn_submit( self, request_json: str, sign: bool, - taa_accept: bool = None, + taa_accept: Optional[bool] = None, sign_did: DIDInfo = sentinel, write_ledger: bool = True, ) -> str: @@ -280,7 +280,7 @@ async def create_and_send_schema( schema_version: str, attribute_names: Sequence[str], write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[str, dict]: """Send schema to ledger. @@ -382,7 +382,7 @@ async def _create_schema_request( public_info: DIDInfo, schema_json: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a schema.""" @@ -392,7 +392,7 @@ async def _create_revoc_reg_def_request( public_info: DIDInfo, revoc_reg_def: dict, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a revocation registry definition.""" @@ -404,9 +404,9 @@ async def get_revoc_reg_def(self, revoc_reg_id: str) -> dict: async def send_revoc_reg_def( self, revoc_reg_def: dict, - issuer_did: str = None, + issuer_did: Optional[str] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Publish a revocation registry definition to the ledger.""" @@ -416,9 +416,9 @@ async def send_revoc_reg_entry( revoc_reg_id: str, revoc_def_type: str, revoc_reg_entry: dict, - issuer_did: str = None, + issuer_did: Optional[str] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Publish a revocation registry entry to the ledger.""" @@ -426,11 +426,11 @@ async def create_and_send_credential_definition( self, issuer: IndyIssuer, schema_id: str, - signature_type: str = None, - tag: str = None, + signature_type: Optional[str] = None, + tag: Optional[str] = None, support_revocation: bool = False, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[str, dict, bool]: """Send credential definition to ledger and store relevant key matter in wallet. @@ -544,7 +544,7 @@ async def _create_credential_definition_request( public_info: DIDInfo, credential_definition_json: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a credential definition.""" @@ -599,7 +599,7 @@ async def send_schema_anoncreds( schema_id: str, schema_def: dict, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[str, dict]: """Send schema to the ledger. @@ -718,7 +718,7 @@ async def send_credential_definition_anoncreds( cred_def_id: str, cred_def: dict, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[str, dict, bool]: """Send credential definition to ledger and store relevant key matter in wallet. diff --git a/aries_cloudagent/ledger/error.py b/aries_cloudagent/ledger/error.py index bea5777f4d..0acf355ff3 100644 --- a/aries_cloudagent/ledger/error.py +++ b/aries_cloudagent/ledger/error.py @@ -1,6 +1,6 @@ """Ledger related errors.""" -from typing import Generic, TypeVar +from typing import Generic, Optional, TypeVar from ..core.error import BaseError @@ -35,7 +35,7 @@ def __init__( self, message: str, obj_id: str, - obj: T = None, + obj: Optional[T] = None, *args, **kwargs, ): diff --git a/aries_cloudagent/ledger/indy_vdr.py b/aries_cloudagent/ledger/indy_vdr.py index 80845a69a5..2d169524dc 100644 --- a/aries_cloudagent/ledger/indy_vdr.py +++ b/aries_cloudagent/ledger/indy_vdr.py @@ -71,11 +71,11 @@ def __init__( name: str, *, keepalive: int = 0, - cache: BaseCache = None, + cache: Optional[BaseCache] = None, cache_duration: int = 600, - genesis_transactions: str = None, + genesis_transactions: Optional[str] = None, read_only: bool = False, - socks_proxy: str = None, + socks_proxy: Optional[str] = None, ): """Initialize an IndyLedger instance. @@ -94,13 +94,13 @@ def __init__( self.close_task: asyncio.Future = None self.cache = cache self.cache_duration: int = cache_duration - self.handle: Pool = None + self.handle: Optional[Pool] = None self.name = name - self.cfg_path_cache: Path = None - self.genesis_hash_cache: str = None + self.cfg_path_cache: Optional[Path] = None + self.genesis_hash_cache: Optional[str] = None self.genesis_txns_cache = genesis_transactions self.init_config = bool(genesis_transactions) - self.taa_cache: str = None + self.taa_cache: Optional[str] = None self.read_only: bool = read_only self.socks_proxy: str = socks_proxy @@ -307,8 +307,8 @@ async def __aexit__(self, exc_type, exc, tb): async def _submit( self, request: Union[str, Request], - sign: bool = None, - taa_accept: bool = None, + sign: Optional[bool] = None, + taa_accept: Optional[bool] = None, sign_did: DIDInfo = sentinel, write_ledger: bool = True, ) -> dict: @@ -375,7 +375,7 @@ async def _create_schema_request( public_info: DIDInfo, schema_json: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a schema.""" try: @@ -393,7 +393,7 @@ async def _create_revoc_reg_def_request( public_info: DIDInfo, revoc_reg_def_json: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a revocation registry definition.""" try: @@ -415,7 +415,7 @@ async def _create_revoc_reg_entry_request( revoc_def_type: str, revoc_reg_entry_json: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a revocation registry definition.""" try: @@ -531,7 +531,7 @@ async def _create_credential_definition_request( public_info: DIDInfo, credential_definition_json: str, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ): """Create the ledger request for publishing a credential definition.""" try: @@ -674,7 +674,7 @@ async def get_all_endpoints_for_did(self, did: str) -> dict: return endpoints async def get_endpoint_for_did( - self, did: str, endpoint_type: EndpointType = None + self, did: str, endpoint_type: Optional[EndpointType] = None ) -> str: """Fetch the endpoint for a ledger DID. @@ -709,9 +709,9 @@ async def update_endpoint_for_did( self, did: str, endpoint: str, - endpoint_type: EndpointType = None, + endpoint_type: Optional[EndpointType] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, routing_keys: List[str] = None, ) -> bool: """Check and update the endpoint on the ledger. @@ -777,10 +777,10 @@ async def register_nym( self, did: str, verkey: str, - alias: str = None, - role: str = None, + alias: Optional[str] = None, + role: Optional[str] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> Tuple[bool, dict]: """Register a nym on the ledger. @@ -868,7 +868,7 @@ async def submit_get_nym_request(self, request_json: str) -> str: response_json = await self._submit(request_json) return response_json - async def rotate_public_did_keypair(self, next_seed: str = None) -> None: + async def rotate_public_did_keypair(self, next_seed: Optional[str] = None) -> None: """Rotate keypair for public DID: create new key, submit to ledger, update wallet. Args: @@ -962,7 +962,7 @@ def taa_rough_timestamp(self) -> int: ) async def accept_txn_author_agreement( - self, taa_record: dict, mechanism: str, accept_time: int = None + self, taa_record: dict, mechanism: str, accept_time: Optional[int] = None ): """Save a new record recording the acceptance of the TAA.""" if not accept_time: @@ -1127,9 +1127,9 @@ async def get_revoc_reg_delta( async def send_revoc_reg_def( self, revoc_reg_def: dict, - issuer_did: str = None, + issuer_did: Optional[str] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Publish a revocation registry definition to the ledger.""" # NOTE - issuer DID could be extracted from the revoc_reg_def ID @@ -1207,9 +1207,9 @@ async def send_revoc_reg_entry( revoc_reg_id: str, revoc_def_type: str, revoc_reg_entry: dict, - issuer_did: str = None, + issuer_did: Optional[str] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Publish a revocation registry entry to the ledger.""" async with self.profile.session() as session: @@ -1288,7 +1288,7 @@ async def get_wallet_public_did(self) -> DIDInfo: async def txn_endorse( self, request_json: str, - endorse_did: DIDInfo = None, + endorse_did: Optional[DIDInfo] = None, ) -> str: """Endorse (sign) the provided transaction.""" try: @@ -1315,7 +1315,7 @@ async def txn_submit( self, request_json: str, sign: bool, - taa_accept: bool = None, + taa_accept: Optional[bool] = None, sign_did: DIDInfo = sentinel, write_ledger: bool = True, ) -> str: diff --git a/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py b/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py index 1d39ad58f1..7664a620fc 100644 --- a/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py +++ b/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py @@ -33,7 +33,7 @@ def __init__( non_production_ledgers: Optional[OrderedDict] = None, writable_ledgers: Optional[set] = None, endorser_map: Optional[dict] = None, - cache_ttl: int = None, + cache_ttl: Optional[int] = None, ): """Initialize MultiIndyLedgerManager. diff --git a/aries_cloudagent/ledger/multiple_ledger/ledger_config_schema.py b/aries_cloudagent/ledger/multiple_ledger/ledger_config_schema.py index 1f45f9e312..d2a300a7c8 100644 --- a/aries_cloudagent/ledger/multiple_ledger/ledger_config_schema.py +++ b/aries_cloudagent/ledger/multiple_ledger/ledger_config_schema.py @@ -1,5 +1,7 @@ """Schema for configuring multiple ledgers.""" +from typing import Optional + from marshmallow import EXCLUDE, fields, pre_load from uuid_utils import uuid4 @@ -18,11 +20,11 @@ class Meta: def __init__( self, *, - id: str = None, + id: Optional[str] = None, is_production: str = True, - genesis_transactions: str = None, - genesis_file: str = None, - genesis_url: str = None, + genesis_transactions: Optional[str] = None, + genesis_file: Optional[str] = None, + genesis_url: Optional[str] = None, ): """Initialize LedgerConfigInstance.""" self.id = id diff --git a/aries_cloudagent/ledger/tests/test_routes.py b/aries_cloudagent/ledger/tests/test_routes.py index 38cf897776..e840e7cfa5 100644 --- a/aries_cloudagent/ledger/tests/test_routes.py +++ b/aries_cloudagent/ledger/tests/test_routes.py @@ -1,4 +1,4 @@ -from typing import Tuple +from typing import Optional, Tuple from unittest import IsolatedAsyncioTestCase from aries_cloudagent.tests import mock @@ -279,7 +279,7 @@ async def test_register_nym(self): test_module.web, "json_response", mock.Mock() ) as json_response: success: bool = True - txn: dict = None + txn: Optional[dict] = None self.ledger.register_nym.return_value: Tuple[bool, dict] = (success, txn) result = await test_module.register_ledger_nym(self.request) json_response.assert_called_once_with({"success": success}) diff --git a/aries_cloudagent/messaging/agent_message.py b/aries_cloudagent/messaging/agent_message.py index 7dc62f49dd..4a9a346a0f 100644 --- a/aries_cloudagent/messaging/agent_message.py +++ b/aries_cloudagent/messaging/agent_message.py @@ -55,10 +55,10 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, _type: Optional[Text] = None, _version: Optional[Text] = None, - _decorators: BaseDecoratorSet = None, + _decorators: Optional[BaseDecoratorSet] = None, ): """Initialize base agent message object. @@ -225,7 +225,7 @@ async def sign_field( # TODO migrate to signed-attachment per RFC 17 return sig async def verify_signed_field( # TODO migrate to signed-attachment per RFC 17 - self, field_name: str, wallet: BaseWallet, signer_verkey: str = None + self, field_name: str, wallet: BaseWallet, signer_verkey: Optional[str] = None ) -> str: """Verify a specific field signature. diff --git a/aries_cloudagent/messaging/decorators/attach_decorator.py b/aries_cloudagent/messaging/decorators/attach_decorator.py index 4aa1689e3c..49a40173d7 100644 --- a/aries_cloudagent/messaging/decorators/attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/attach_decorator.py @@ -5,7 +5,7 @@ import copy import json -from typing import Any, Mapping, Sequence, Tuple, Union +from typing import Any, Mapping, Optional, Sequence, Tuple, Union from marshmallow import EXCLUDE, fields, pre_load from uuid_utils import uuid4 @@ -89,7 +89,7 @@ def __init__( self, *, header: AttachDecoratorDataJWSHeader, - protected: str = None, + protected: Optional[str] = None, signature: str, ): """Initialize flattened single-JWS to include in attach decorator data.""" @@ -149,9 +149,9 @@ class Meta: def __init__( self, *, - header: AttachDecoratorDataJWSHeader = None, - protected: str = None, - signature: str = None, + header: Optional[AttachDecoratorDataJWSHeader] = None, + protected: Optional[str] = None, + signature: Optional[str] = None, signatures: Sequence[AttachDecoratorData1JWS] = None, ): """Initialize JWS to include in attach decorator multi-sig data.""" @@ -238,10 +238,10 @@ class Meta: def __init__( self, *, - jws_: AttachDecoratorDataJWS = None, - sha256_: str = None, + jws_: Optional[AttachDecoratorDataJWS] = None, + sha256_: Optional[str] = None, links_: Union[Sequence[str], str] = None, - base64_: str = None, + base64_: Optional[str] = None, json_: Union[Sequence[dict], dict] = None, ): """Initialize decorator data. @@ -424,7 +424,7 @@ def build_protected(verkey: str): ) self.jws_ = AttachDecoratorDataJWS.deserialize(jws) - async def verify(self, wallet: BaseWallet, signer_verkey: str = None) -> bool: + async def verify(self, wallet: BaseWallet, signer_verkey: Optional[str] = None) -> bool: """Verify the signature(s). Args: @@ -543,12 +543,12 @@ class Meta: def __init__( self, *, - ident: str = None, - description: str = None, - filename: str = None, - mime_type: str = None, - lastmod_time: str = None, - byte_count: int = None, + ident: Optional[str] = None, + description: Optional[str] = None, + filename: Optional[str] = None, + mime_type: Optional[str] = None, + lastmod_time: Optional[str] = None, + byte_count: Optional[int] = None, data: AttachDecoratorData, **kwargs, ): @@ -603,11 +603,11 @@ def data_base64_string( cls, content: str, *, - ident: str = None, - description: str = None, - filename: str = None, - lastmod_time: str = None, - byte_count: int = None, + ident: Optional[str] = None, + description: Optional[str] = None, + filename: Optional[str] = None, + lastmod_time: Optional[str] = None, + byte_count: Optional[int] = None, ): """Create `AttachDecorator` instance on base64-encoded string data. @@ -637,11 +637,11 @@ def data_base64( cls, mapping: Mapping, *, - ident: str = None, - description: str = None, - filename: str = None, - lastmod_time: str = None, - byte_count: int = None, + ident: Optional[str] = None, + description: Optional[str] = None, + filename: Optional[str] = None, + lastmod_time: Optional[str] = None, + byte_count: Optional[int] = None, ): """Create `AttachDecorator` instance on base64-encoded data from input mapping. @@ -672,11 +672,11 @@ def data_json( cls, mapping: Union[Sequence[dict], dict], *, - ident: str = None, - description: str = None, - filename: str = None, - lastmod_time: str = None, - byte_count: int = None, + ident: Optional[str] = None, + description: Optional[str] = None, + filename: Optional[str] = None, + lastmod_time: Optional[str] = None, + byte_count: Optional[int] = None, ): """Create `AttachDecorator` instance on json-encoded data from input mapping. @@ -706,14 +706,14 @@ def data_json( def data_links( cls, links: Union[str, Sequence[str]], - sha256: str = None, + sha256: Optional[str] = None, *, - ident: str = None, - mime_type: str = None, - description: str = None, - filename: str = None, - lastmod_time: str = None, - byte_count: int = None, + ident: Optional[str] = None, + mime_type: Optional[str] = None, + description: Optional[str] = None, + filename: Optional[str] = None, + lastmod_time: Optional[str] = None, + byte_count: Optional[int] = None, ): """Create `AttachDecorator` instance on json-encoded data from input mapping. diff --git a/aries_cloudagent/messaging/decorators/base.py b/aries_cloudagent/messaging/decorators/base.py index 0044163190..bafa331da0 100644 --- a/aries_cloudagent/messaging/decorators/base.py +++ b/aries_cloudagent/messaging/decorators/base.py @@ -1,7 +1,7 @@ """Classes for managing a collection of decorators.""" from collections import OrderedDict -from typing import Mapping, Sequence, Type +from typing import Mapping, Optional, Sequence, Type from marshmallow import Schema from marshmallow.fields import Field @@ -19,7 +19,7 @@ class DecoratorError(BaseError): class BaseDecoratorSet(OrderedDict): """Collection of decorators.""" - def __init__(self, models: dict = None): + def __init__(self, models: Optional[dict] = None): """Initialize a decorator set.""" self._fields = OrderedDict() self._models: Mapping[str, Type[BaseModel]] = models.copy() if models else {} @@ -134,7 +134,7 @@ def extract_decorators( remain[key] = value return remain - def to_dict(self, prefix: str = None) -> OrderedDict: + def to_dict(self, prefix: Optional[str] = None) -> OrderedDict: """Convert to a dictionary (serialize). Raises: diff --git a/aries_cloudagent/messaging/decorators/default.py b/aries_cloudagent/messaging/decorators/default.py index 5761fc263b..956ba820dc 100644 --- a/aries_cloudagent/messaging/decorators/default.py +++ b/aries_cloudagent/messaging/decorators/default.py @@ -1,5 +1,7 @@ """Default decorator set implementation.""" +from typing import Optional + from .base import BaseDecoratorSet from .localization_decorator import LocalizationDecorator from .service_decorator import ServiceDecorator @@ -23,6 +25,6 @@ class DecoratorSet(BaseDecoratorSet): """Default decorator set implementation.""" - def __init__(self, models: dict = None): + def __init__(self, models: Optional[dict] = None): """Initialize the decorator set.""" super().__init__(DEFAULT_MODELS if models is None else models) diff --git a/aries_cloudagent/messaging/decorators/localization_decorator.py b/aries_cloudagent/messaging/decorators/localization_decorator.py index 38815b20ce..e139ba77b8 100644 --- a/aries_cloudagent/messaging/decorators/localization_decorator.py +++ b/aries_cloudagent/messaging/decorators/localization_decorator.py @@ -1,6 +1,6 @@ """The localization decorator (~l10n) for message localization information.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -18,7 +18,7 @@ class Meta: def __init__( self, *, - locale: str = None, + locale: Optional[str] = None, localizable: Sequence[str] = None, catalogs: Sequence[str] = None, ): diff --git a/aries_cloudagent/messaging/decorators/please_ack_decorator.py b/aries_cloudagent/messaging/decorators/please_ack_decorator.py index 578e2613b8..6189e2c8cd 100644 --- a/aries_cloudagent/messaging/decorators/please_ack_decorator.py +++ b/aries_cloudagent/messaging/decorators/please_ack_decorator.py @@ -1,6 +1,6 @@ """The please-ack decorator to request acknowledgement.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -18,7 +18,7 @@ class Meta: def __init__( self, - message_id: str = None, + message_id: Optional[str] = None, on: Sequence[str] = None, ): """Initialize a PleaseAckDecorator instance. diff --git a/aries_cloudagent/messaging/decorators/signature_decorator.py b/aries_cloudagent/messaging/decorators/signature_decorator.py index 11b86290ea..22ec1b38c1 100644 --- a/aries_cloudagent/messaging/decorators/signature_decorator.py +++ b/aries_cloudagent/messaging/decorators/signature_decorator.py @@ -3,6 +3,7 @@ import json import struct import time +from typing import Optional from marshmallow import EXCLUDE, fields @@ -32,10 +33,10 @@ class Meta: def __init__( self, *, - signature_type: str = None, - signature: str = None, - sig_data: str = None, - signer: str = None, + signature_type: Optional[str] = None, + signature: Optional[str] = None, + sig_data: Optional[str] = None, + signer: Optional[str] = None, ): """Initialize a FieldSignature instance. diff --git a/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py b/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py index 80e7543270..be9610b09e 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py +++ b/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py @@ -1,3 +1,4 @@ +from typing import Optional from unittest import TestCase from marshmallow import EXCLUDE, fields @@ -11,7 +12,7 @@ class SimpleModel(BaseModel): class Meta: schema_class = "SimpleModelSchema" - def __init__(self, *, value: str = None, handled_decorator: 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 diff --git a/aries_cloudagent/messaging/decorators/timing_decorator.py b/aries_cloudagent/messaging/decorators/timing_decorator.py index 0cb1b0300c..7ad8fc8c86 100644 --- a/aries_cloudagent/messaging/decorators/timing_decorator.py +++ b/aries_cloudagent/messaging/decorators/timing_decorator.py @@ -5,7 +5,7 @@ """ from datetime import datetime -from typing import Union +from typing import Optional, Union from marshmallow import EXCLUDE, fields @@ -29,7 +29,7 @@ def __init__( out_time: Union[str, datetime] = None, stale_time: Union[str, datetime] = None, expires_time: Union[str, datetime] = None, - delay_milli: int = None, + delay_milli: Optional[int] = None, wait_until_time: Union[str, datetime] = None, ): """Initialize a TimingDecorator instance. diff --git a/aries_cloudagent/messaging/decorators/trace_decorator.py b/aries_cloudagent/messaging/decorators/trace_decorator.py index 5a242f892e..caf4234ac9 100644 --- a/aries_cloudagent/messaging/decorators/trace_decorator.py +++ b/aries_cloudagent/messaging/decorators/trace_decorator.py @@ -4,7 +4,7 @@ to record information on message processing events. """ -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -26,14 +26,14 @@ class Meta: def __init__( self, *, - msg_id: str = None, - thread_id: str = None, - traced_type: str = None, - timestamp: str = None, - str_time: str = None, - handler: str = None, - elapsed_milli: int = None, - outcome: str = None, + msg_id: Optional[str] = None, + thread_id: Optional[str] = None, + traced_type: Optional[str] = None, + timestamp: Optional[str] = None, + str_time: Optional[str] = None, + handler: Optional[str] = None, + elapsed_milli: Optional[int] = None, + outcome: Optional[str] = None, ): """Initialize a TraceReport instance. @@ -149,9 +149,9 @@ class Meta: def __init__( self, *, - target: str = None, + target: Optional[str] = None, full_thread: bool = True, - trace_reports: Sequence = None, + trace_reports: Optional[Sequence] = None, ): """Initialize a TraceDecorator instance. diff --git a/aries_cloudagent/messaging/decorators/transport_decorator.py b/aries_cloudagent/messaging/decorators/transport_decorator.py index cd35226473..90dcdffc41 100644 --- a/aries_cloudagent/messaging/decorators/transport_decorator.py +++ b/aries_cloudagent/messaging/decorators/transport_decorator.py @@ -3,6 +3,8 @@ This decorator allows changes to agent response behaviour and queue status updates. """ +from typing import Optional + from marshmallow import EXCLUDE, fields, validate from ..models.base import BaseModel, BaseModelSchema @@ -20,9 +22,9 @@ class Meta: def __init__( self, *, - return_route: str = None, - return_route_thread: str = None, - queued_message_count: int = None, + return_route: Optional[str] = None, + return_route_thread: Optional[str] = None, + queued_message_count: Optional[int] = None, ): """Initialize a TransportDecorator instance. diff --git a/aries_cloudagent/messaging/models/base.py b/aries_cloudagent/messaging/models/base.py index 3e654833f4..d9b17231a3 100644 --- a/aries_cloudagent/messaging/models/base.py +++ b/aries_cloudagent/messaging/models/base.py @@ -288,7 +288,7 @@ def from_json( raise BaseModelError(f"{cls.__name__} JSON parsing failed") from e return cls.deserialize(parsed, unknown=unknown) - def to_json(self, unknown: str = None) -> str: + def to_json(self, unknown: Optional[str] = None) -> str: """Create a JSON representation of the model instance. Returns: diff --git a/aries_cloudagent/messaging/models/base_record.py b/aries_cloudagent/messaging/models/base_record.py index c7ee98c84c..a89894dfc6 100644 --- a/aries_cloudagent/messaging/models/base_record.py +++ b/aries_cloudagent/messaging/models/base_record.py @@ -243,7 +243,7 @@ async def retrieve_by_tag_filter( cls: Type[RecordType], session: ProfileSession, tag_filter: dict, - post_filter: dict = None, + post_filter: Optional[dict] = None, *, for_update=False, ) -> RecordType: @@ -289,12 +289,12 @@ async def retrieve_by_tag_filter( async def query( cls: Type[RecordType], session: ProfileSession, - tag_filter: dict = None, + tag_filter: Optional[dict] = None, *, limit: Optional[int] = None, offset: Optional[int] = None, - post_filter_positive: dict = None, - post_filter_negative: dict = None, + post_filter_positive: Optional[dict] = None, + post_filter_negative: Optional[dict] = None, alt: bool = False, ) -> Sequence[RecordType]: """Query stored records. @@ -371,10 +371,10 @@ async def save( self, session: ProfileSession, *, - reason: str = None, + reason: Optional[str] = None, log_params: Mapping[str, Any] = None, log_override: bool = False, - event: bool = None, + event: Optional[bool] = None, ) -> str: """Persist the record to storage. @@ -422,7 +422,7 @@ async def post_save( session: ProfileSession, new_record: bool, last_state: Optional[str], - event: bool = None, + event: Optional[bool] = None, ): """Perform post-save actions. @@ -453,7 +453,7 @@ async def delete_record(self, session: ProfileSession): await self.emit_event(session, self.serialize()) await storage.delete_record(self.storage_record) - async def emit_event(self, session: ProfileSession, payload: Any = None): + async def emit_event(self, session: ProfileSession, payload: Optional[Any] = None): """Emit an event. Args: @@ -478,8 +478,8 @@ async def emit_event(self, session: ProfileSession, payload: Any = None): def log_state( cls, msg: str, - params: dict = None, - settings: BaseSettings = None, + params: Optional[dict] = None, + settings: Optional[BaseSettings] = None, override: bool = False, ): """Print a message with increased visibility (for testing).""" diff --git a/aries_cloudagent/messaging/responder.py b/aries_cloudagent/messaging/responder.py index b71daee7fa..98a2bb6425 100644 --- a/aries_cloudagent/messaging/responder.py +++ b/aries_cloudagent/messaging/responder.py @@ -42,9 +42,9 @@ class BaseResponder(ABC): def __init__( self, *, - connection_id: str = None, - reply_session_id: str = None, - reply_to_verkey: str = None, + connection_id: Optional[str] = None, + reply_session_id: Optional[str] = None, + reply_to_verkey: Optional[str] = None, ): """Initialize a base responder.""" self.connection_id = connection_id @@ -55,12 +55,12 @@ async def create_outbound( self, message: Union[BaseMessage, str, bytes], *, - connection_id: str = None, - reply_session_id: str = None, - reply_thread_id: str = None, - reply_to_verkey: str = None, - reply_from_verkey: str = None, - target: ConnectionTarget = None, + connection_id: Optional[str] = None, + reply_session_id: Optional[str] = None, + reply_thread_id: Optional[str] = None, + reply_to_verkey: Optional[str] = None, + reply_from_verkey: Optional[str] = None, + target: Optional[ConnectionTarget] = None, target_list: Sequence[ConnectionTarget] = None, to_session_only: bool = False, ) -> OutboundMessage: @@ -111,8 +111,8 @@ async def send_reply( self, message: Union[BaseMessage, str, bytes], *, - connection_id: str = None, - target: ConnectionTarget = None, + connection_id: Optional[str] = None, + target: Optional[ConnectionTarget] = None, target_list: Sequence[ConnectionTarget] = None, ) -> OutboundSendStatus: """Send a reply to an incoming message. diff --git a/aries_cloudagent/messaging/tests/test_agent_message.py b/aries_cloudagent/messaging/tests/test_agent_message.py index bfb12fe510..e4b0b8a7a2 100644 --- a/aries_cloudagent/messaging/tests/test_agent_message.py +++ b/aries_cloudagent/messaging/tests/test_agent_message.py @@ -1,3 +1,4 @@ +from typing import Optional from unittest import IsolatedAsyncioTestCase from marshmallow import EXCLUDE, fields @@ -21,7 +22,7 @@ class Meta: schema_class = "SignedAgentMessageSchema" message_type = "doc/protocol/1.0/signed-agent-message" - def __init__(self, value: str = None, **kwargs): + def __init__(self, value: Optional[str] = None, **kwargs): super().__init__(**kwargs) self.value = value diff --git a/aries_cloudagent/multitenant/base.py b/aries_cloudagent/multitenant/base.py index fd0ef9f4c4..be0d27892e 100644 --- a/aries_cloudagent/multitenant/base.py +++ b/aries_cloudagent/multitenant/base.py @@ -233,7 +233,7 @@ async def update_wallet( return wallet_record - async def remove_wallet(self, wallet_id: str, wallet_key: str = None): + async def remove_wallet(self, wallet_id: str, wallet_key: Optional[str] = None): """Remove the wallet with specified wallet id. Args: @@ -283,7 +283,7 @@ async def remove_wallet_profile(self, profile: Profile): """ async def create_auth_token( - self, wallet_record: WalletRecord, wallet_key: str = None + self, wallet_record: WalletRecord, wallet_key: Optional[str] = None ) -> str: """Create JWT auth token for specified wallet record. @@ -419,7 +419,7 @@ async def get_profile_for_key( return await self.get_wallet_profile(context, wallet) async def get_wallets_by_message( - self, message_body, wire_format: BaseWireFormat = None + self, message_body, wire_format: Optional[BaseWireFormat] = None ) -> List[WalletRecord]: """Get the wallet records associated with the message boy. diff --git a/aries_cloudagent/multitenant/single_wallet_askar_manager.py b/aries_cloudagent/multitenant/single_wallet_askar_manager.py index aeb513403f..92340d0326 100644 --- a/aries_cloudagent/multitenant/single_wallet_askar_manager.py +++ b/aries_cloudagent/multitenant/single_wallet_askar_manager.py @@ -16,7 +16,7 @@ class SingleWalletAskarMultitenantManager(BaseMultitenantManager): DEFAULT_MULTITENANT_WALLET_NAME = "multitenant_sub_wallet" - def __init__(self, profile: Profile, multitenant_profile: AskarProfile = None): + def __init__(self, profile: Profile, multitenant_profile: Optional[AskarProfile] = None): """Initialize askar profile multitenant Manager. Args: diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/base_service.py b/aries_cloudagent/protocols/actionmenu/v1_0/base_service.py index ab9d3a1867..fd8d85287b 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/base_service.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/base_service.py @@ -1,6 +1,7 @@ """Base action menu service classes.""" from abc import ABC, abstractmethod +from typing import Optional from ....config.injection_context import InjectionContext from ....connections.models.conn_record import ConnRecord @@ -30,8 +31,8 @@ async def get_instance(context: InjectionContext): async def get_active_menu( self, profile: Profile, - connection: ConnRecord = None, - thread_id: str = None, + connection: Optional[ConnRecord] = None, + thread_id: Optional[str] = None, ) -> Menu: """Render the current menu. @@ -47,8 +48,8 @@ async def perform_menu_action( profile: Profile, action_name: str, action_params: dict, - connection: ConnRecord = None, - thread_id: str = None, + connection: Optional[ConnRecord] = None, + thread_id: Optional[str] = None, ) -> AgentMessage: """Perform an action defined by the active menu. diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/driver_service.py b/aries_cloudagent/protocols/actionmenu/v1_0/driver_service.py index 21b36fba69..96163d9a3f 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/driver_service.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/driver_service.py @@ -1,6 +1,7 @@ """Driver-based action menu service classes.""" import logging +from typing import Optional from ....connections.models.conn_record import ConnRecord from ....core.profile import Profile @@ -17,8 +18,8 @@ class DriverMenuService(BaseMenuService): async def get_active_menu( self, profile: Profile, - connection: ConnRecord = None, - thread_id: str = None, + connection: Optional[ConnRecord] = None, + thread_id: Optional[str] = None, ) -> Menu: """Render the current menu. @@ -41,8 +42,8 @@ async def perform_menu_action( profile: Profile, action_name: str, action_params: dict, - connection: ConnRecord = None, - thread_id: str = None, + connection: Optional[ConnRecord] = None, + thread_id: Optional[str] = None, ) -> AgentMessage: """Perform an action defined by the active menu. diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py b/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py index 4474a78bc8..0c0b73b7ad 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py @@ -1,6 +1,6 @@ """Represents an action menu.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -24,9 +24,9 @@ class Meta: def __init__( self, *, - title: str = None, - description: str = None, - errormsg: str = None, + title: Optional[str] = None, + description: Optional[str] = None, + errormsg: Optional[str] = None, options: Sequence[MenuOption] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py index aaf93c707c..e385e95c7d 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py @@ -1,6 +1,6 @@ """Represents a request to perform a menu action.""" -from typing import Mapping +from typing import Mapping, Optional from marshmallow import EXCLUDE, fields @@ -20,7 +20,7 @@ class Meta: message_type = PERFORM schema_class = "PerformSchema" - def __init__(self, *, name: 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: diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py index 8856226da8..699c0631a9 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form.py @@ -1,6 +1,6 @@ """Record used to represent the form associated with an action menu option.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -19,10 +19,10 @@ class Meta: def __init__( self, *, - title: str = None, - description: str = None, + title: Optional[str] = None, + description: Optional[str] = None, params: Sequence[MenuFormParam] = None, - submit_label: str = None, + submit_label: Optional[str] = None, ): """Initialize a MenuForm instance. diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py index 9455e5a656..62e167041c 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_form_param.py @@ -1,5 +1,7 @@ """Record used to represent a parameter in a menu form.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.models.base import BaseModel, BaseModelSchema @@ -16,12 +18,12 @@ class Meta: def __init__( self, *, - name: str = None, - title: str = None, - default: str = None, - description: str = None, - input_type: str = None, - required: bool = None, + name: Optional[str] = None, + title: Optional[str] = None, + default: Optional[str] = None, + description: Optional[str] = None, + input_type: Optional[str] = None, + required: Optional[bool] = None, ): """Initialize a MenuFormParam instance. diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py index 12b154854b..b30fac72b6 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/models/menu_option.py @@ -1,5 +1,7 @@ """Record used to represent individual menu options in an action menu.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.models.base import BaseModel, BaseModelSchema @@ -17,11 +19,11 @@ class Meta: def __init__( self, *, - name: str = None, - title: str = None, - description: str = None, - disabled: bool = None, - form: MenuForm = None, + name: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + disabled: Optional[bool] = None, + form: Optional[MenuForm] = None, ): """Initialize a MenuOption instance. diff --git a/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py b/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py index 581abbace3..840be506b9 100644 --- a/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py +++ b/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py @@ -1,7 +1,7 @@ """Basic message.""" from datetime import datetime -from typing import Union +from typing import Optional, Union from marshmallow import EXCLUDE, fields @@ -30,8 +30,8 @@ def __init__( self, *, sent_time: Union[str, datetime] = None, - content: str = None, - localization: str = None, + content: Optional[str] = None, + localization: Optional[str] = None, **kwargs, ): """Initialize basic message object. diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index 5b7b272e2c..9d7c0bf86d 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -352,9 +352,9 @@ async def receive_invitation( async def create_request( self, connection: ConnRecord, - my_label: str = None, - my_endpoint: str = None, - mediation_id: str = None, + my_label: Optional[str] = None, + my_endpoint: Optional[str] = None, + mediation_id: Optional[str] = None, ) -> ConnectionRequest: """Create a new connection request for a previously-received invitation. @@ -592,8 +592,8 @@ async def receive_request( async def create_response( self, connection: ConnRecord, - my_endpoint: str = None, - mediation_id: str = None, + my_endpoint: Optional[str] = None, + mediation_id: Optional[str] = None, ) -> ConnectionResponse: """Create a connection response for a received connection request. diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py b/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py index f2bcb36068..9af5dc9783 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py @@ -1,6 +1,6 @@ """Represents an invitation message for establishing connection.""" -from typing import Sequence +from typing import Optional, Sequence from urllib.parse import parse_qs, urljoin, urlparse from marshmallow import EXCLUDE, ValidationError, fields, pre_load, validates_schema @@ -35,12 +35,12 @@ class Meta: def __init__( self, *, - label: str = None, - did: str = None, + label: Optional[str] = None, + did: Optional[str] = None, recipient_keys: Sequence[str] = None, - endpoint: str = None, + endpoint: Optional[str] = None, routing_keys: Sequence[str] = None, - image_url: str = None, + image_url: Optional[str] = None, **kwargs, ): """Initialize connection invitation object. @@ -74,7 +74,7 @@ def __init__( ) self.image_url = image_url - def to_url(self, base_url: str = None) -> str: + def to_url(self, base_url: Optional[str] = None) -> str: """Convert an invitation to URL format for sharing. Returns: diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py b/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py index 70583491f1..d1a6940be5 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py @@ -1,5 +1,7 @@ """Represents a connection request message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -24,9 +26,9 @@ class Meta: def __init__( self, *, - connection: ConnectionDetail = None, - label: str = None, - image_url: str = None, + connection: Optional[ConnectionDetail] = None, + label: Optional[str] = None, + image_url: Optional[str] = None, **kwargs, ): """Initialize connection request object. diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py b/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py index af7470448c..8bf11eae21 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py @@ -1,5 +1,7 @@ """Represents a connection response message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -22,7 +24,7 @@ class Meta: schema_class = "ConnectionResponseSchema" message_type = CONNECTION_RESPONSE - def __init__(self, *, connection: ConnectionDetail = None, **kwargs): + def __init__(self, *, connection: Optional[ConnectionDetail] = None, **kwargs): """Initialize connection response object. Args: diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py b/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py index e6533cb635..49aa7a44d7 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py @@ -2,6 +2,7 @@ import logging from enum import Enum +from typing import Optional from marshmallow import EXCLUDE, ValidationError, validates_schema @@ -38,7 +39,7 @@ class Meta: message_type = PROBLEM_REPORT schema_class = "ConnectionProblemReportSchema" - def __init__(self, *, problem_code: str = None, explain: str = None, **kwargs): + def __init__(self, *, problem_code: Optional[str] = None, explain: Optional[str] = None, **kwargs): """Initialize a ProblemReport message instance. Args: diff --git a/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py b/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py index 1c6a0b97f0..2363fa42b5 100644 --- a/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py +++ b/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py @@ -1,5 +1,7 @@ """An object for containing the connection request/response DID information.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....connections.models.diddoc import DIDDoc @@ -49,7 +51,7 @@ class Meta: schema_class = "ConnectionDetailSchema" - def __init__(self, *, did: str = None, did_doc: DIDDoc = None, **kwargs): + def __init__(self, *, did: Optional[str] = None, did_doc: Optional[DIDDoc] = None, **kwargs): """Initialize a ConnectionDetail instance. Args: diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py index 675c027e32..125e07217f 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py @@ -474,7 +474,7 @@ async def request_denied(self, record: MediationRecord, deny: MediationDeny): await record.save(session, reason="Mediation request denied.") async def prepare_keylist_query( - self, filter_: 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. diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py index 187aa175be..0578cff48d 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py @@ -1,5 +1,7 @@ """Inner structure of keylist message. Represents a single item in keylist.keys.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from ......messaging.models.base import BaseModel, BaseModelSchema @@ -18,9 +20,9 @@ class Meta: def __init__( self, *, - recipient_key: str = None, - action: str = None, - result: str = None, + recipient_key: Optional[str] = None, + action: Optional[str] = None, + result: Optional[str] = None, **kwargs, ): """Initialize a KeylistKey instance. diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py index e268d22377..c0f71f35b5 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py @@ -3,6 +3,8 @@ Represents single item in keylist-update-response.updated list. """ +from typing import Optional + from marshmallow import EXCLUDE, fields from ......messaging.models.base import BaseModel, BaseModelSchema @@ -26,9 +28,9 @@ class Meta: def __init__( self, *, - recipient_key: str = None, - action: str = None, - result: str = None, + recipient_key: Optional[str] = None, + action: Optional[str] = None, + result: Optional[str] = None, **kwargs, ): """Initialize a KeylistUpdated instance. diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py index 8b6472644a..e56484f831 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py @@ -1,6 +1,6 @@ """Response to keylist-query message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import fields @@ -29,7 +29,7 @@ def __init__( self, *, keys: Sequence[str] = None, - pagination: KeylistQueryPaginate = None, + pagination: Optional[KeylistQueryPaginate] = None, **kwargs, ): """Initialize keylist query response object. diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py index 4e7539eaf0..64ed4f1fa1 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py @@ -1,5 +1,7 @@ """keylist-query message used to request list of keys handled by mediator.""" +from typing import Optional + from marshmallow import fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -25,8 +27,8 @@ class Meta: def __init__( self, *, - filter: dict = None, - paginate: KeylistQueryPaginate = None, + filter: Optional[dict] = None, + paginate: Optional[KeylistQueryPaginate] = None, **kwargs, ): """Initialize keylist query object. diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/tests/__init__.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/tests/__init__.py index 96c2acaf4a..dbbeec744a 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/tests/__init__.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/tests/__init__.py @@ -1,5 +1,6 @@ """Helper classes and functions for message tests.""" +from typing import Optional from unittest import mock from ......messaging.agent_message import AgentMessage, AgentMessageSchema @@ -9,7 +10,7 @@ class MessageTest: """Base class for message tests.""" - TYPE: str = None + TYPE: Optional[str] = None CLASS = AgentMessage SCHEMA = AgentMessageSchema VALUES: dict = {} diff --git a/aries_cloudagent/protocols/didexchange/v1_0/manager.py b/aries_cloudagent/protocols/didexchange/v1_0/manager.py index 953e7ec73d..8ac0ceca22 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/manager.py @@ -1178,7 +1178,7 @@ async def verify_diddoc( self, wallet: BaseWallet, attached: AttachDecorator, - invi_key: str = None, + invi_key: Optional[str] = None, ) -> dict: """Verify DIDDoc attachment and return signed data.""" signed_diddoc_bytes = attached.data.signed @@ -1193,7 +1193,7 @@ async def verify_rotate( self, wallet: BaseWallet, attached: AttachDecorator, - invi_key: str = None, + invi_key: Optional[str] = None, ) -> str: """Verify a signed DID rotate attachment and return did.""" signed_diddoc_bytes = attached.data.signed diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py index 8d04e26a3b..9d97ed20ca 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py @@ -28,7 +28,7 @@ class Meta: def __init__( self, *, - did: str = None, + did: Optional[str] = None, did_doc_attach: Optional[AttachDecorator] = None, did_rotate_attach: Optional[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/discovery/v2_0/manager.py b/aries_cloudagent/protocols/discovery/v2_0/manager.py index f5d3b118b3..f60d579f09 100644 --- a/aries_cloudagent/protocols/discovery/v2_0/manager.py +++ b/aries_cloudagent/protocols/discovery/v2_0/manager.py @@ -42,7 +42,7 @@ def profile(self) -> Profile: return self._profile async def receive_disclose( - self, disclose_msg: Disclosures, connection_id: str = None + self, disclose_msg: Disclosures, connection_id: Optional[str] = None ) -> V20DiscoveryExchangeRecord: """Receive Disclose message and return updated V20DiscoveryExchangeRecord.""" if disclose_msg._thread: @@ -192,9 +192,9 @@ async def check_if_disclosure_received( async def create_and_send_query( self, - connection_id: str = None, - query_protocol: str = None, - query_goal_code: str = None, + connection_id: Optional[str] = None, + query_protocol: Optional[str] = None, + query_goal_code: Optional[str] = None, ) -> V20DiscoveryExchangeRecord: """Create and send a Query message.""" queries = [] diff --git a/aries_cloudagent/protocols/discovery/v2_0/models/discovery_record.py b/aries_cloudagent/protocols/discovery/v2_0/models/discovery_record.py index 7993534c6d..9787544623 100644 --- a/aries_cloudagent/protocols/discovery/v2_0/models/discovery_record.py +++ b/aries_cloudagent/protocols/discovery/v2_0/models/discovery_record.py @@ -1,7 +1,7 @@ """.""" import logging -from typing import Any, Mapping, Sequence, Union +from typing import Any, Mapping, Optional, Sequence, Union from marshmallow import fields @@ -32,9 +32,9 @@ class Meta: def __init__( self, *, - discovery_exchange_id: str = None, - connection_id: str = None, - thread_id: str = None, + discovery_exchange_id: Optional[str] = None, + connection_id: Optional[str] = None, + thread_id: Optional[str] = None, queries_msg: Union[Sequence, Queries] = None, disclosures: Union[Mapping, Disclosures] = None, **kwargs, diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py index 48971bbac2..51d2a38bb5 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py @@ -3,6 +3,7 @@ import json import logging from asyncio import shield +from typing import Optional from uuid_utils import uuid4 @@ -61,7 +62,7 @@ def profile(self) -> Profile: return self._profile async def create_record( - self, messages_attach: str, connection_id: str, meta_data: dict = None + self, messages_attach: str, connection_id: str, meta_data: Optional[dict] = None ): """Create a new Transaction Record. @@ -109,12 +110,12 @@ async def create_record( async def create_request( self, transaction: TransactionRecord, - signature: str = None, - signed_request: dict = None, - expires_time: str = None, + signature: Optional[str] = None, + signed_request: Optional[dict] = None, + expires_time: Optional[str] = None, endorser_write_txn: bool = False, - author_goal_code: str = None, - signer_goal_code: str = None, + author_goal_code: Optional[str] = None, + signer_goal_code: Optional[str] = None, ): """Create a new Transaction Request. @@ -226,7 +227,7 @@ async def create_endorse_response( self, transaction: TransactionRecord, state: str, - use_endorser_did: str = None, + use_endorser_did: Optional[str] = None, ): """Create a response to endorse a transaction. @@ -792,8 +793,8 @@ async def set_transaction_their_job( async def endorsed_txn_post_processing( self, transaction: TransactionRecord, - ledger_response: dict = None, - connection_record: ConnRecord = None, + ledger_response: Optional[dict] = None, + connection_record: Optional[ConnRecord] = None, ): """Store record in wallet, and kick off any required post-processing. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py index 5785acc2ed..4f2037a43f 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py @@ -1,5 +1,7 @@ """Represents a cancel transaction message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -24,8 +26,8 @@ class Meta: def __init__( self, *, - state: str = None, - thread_id: str = None, + state: Optional[str] = None, + thread_id: Optional[str] = None, **kwargs, ): """Initialize a cancel transaction object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py index 45073967bb..e5acece8bd 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py @@ -1,5 +1,7 @@ """Represents an endorsed transaction message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -25,12 +27,12 @@ class Meta: def __init__( self, *, - transaction_id: str = None, - thread_id: str = None, - signature_response: dict = None, - state: str = None, - endorser_did: str = None, - ledger_response: dict = None, + transaction_id: Optional[str] = None, + thread_id: Optional[str] = None, + signature_response: Optional[dict] = None, + state: Optional[str] = None, + endorser_did: Optional[str] = None, + ledger_response: Optional[dict] = None, **kwargs, ): """Initialize an endorsed transaction response object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py index 19fab4a653..9ffdfb789e 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py @@ -23,14 +23,14 @@ class Meta: def __init__( self, *, - author_did: str = None, - author_verkey: str = None, - endorser_did: str = None, + author_did: Optional[str] = None, + author_verkey: Optional[str] = None, + endorser_did: Optional[str] = None, transaction_message: Optional[dict] = None, - transaction_type: str = None, - mechanism: str = None, - taaDigest: str = None, - time: int = None, + transaction_type: Optional[str] = None, + mechanism: Optional[str] = None, + taaDigest: Optional[str] = None, + time: Optional[int] = None, **kwargs, ): """Initialize the attached message object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py index 0140ecd237..803023d14f 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py @@ -1,5 +1,7 @@ """Represents a refused transaction message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -25,11 +27,11 @@ class Meta: def __init__( self, *, - transaction_id: str = None, - thread_id: str = None, - signature_response: dict = None, - state: str = None, - endorser_did: str = None, + transaction_id: Optional[str] = None, + thread_id: Optional[str] = None, + signature_response: Optional[dict] = None, + state: Optional[str] = None, + endorser_did: Optional[str] = None, **kwargs, ): """Initialize a refused transaction response object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py index 90697d2d08..22c5524cdc 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py @@ -1,5 +1,7 @@ """Represents a transaction acknowledgement message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.valid import UUID4_EXAMPLE @@ -25,8 +27,8 @@ class Meta: def __init__( self, *, - thread_id: str = None, - ledger_response: dict = None, + thread_id: Optional[str] = None, + ledger_response: Optional[dict] = None, **kwargs, ): """Initialize a transaction acknowledgement object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py index 05758c36d1..88cdb2b1a9 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py @@ -1,5 +1,7 @@ """Represents a Transaction Job to send message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -24,7 +26,7 @@ class Meta: def __init__( self, *, - job: str = None, + job: Optional[str] = None, **kwargs, ): """Initialize transaction job to send. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py index 5618a3b56d..4e70c4079a 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py @@ -1,5 +1,7 @@ """Represents a transaction request message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -24,12 +26,12 @@ class Meta: def __init__( self, *, - transaction_id: str = None, - signature_request: dict = None, - timing: dict = None, - transaction_type: str = None, - messages_attach: dict = None, - endorser_write_txn: bool = None, + transaction_id: Optional[str] = None, + signature_request: Optional[dict] = None, + timing: Optional[dict] = None, + transaction_type: Optional[str] = None, + messages_attach: Optional[dict] = None, + endorser_write_txn: Optional[bool] = None, **kwargs, ): """Initialize the transaction request object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py index 929ebdcd2a..82216f3449 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py @@ -1,4 +1,5 @@ """Represents a transaction resend message.""" +from typing import Optional from marshmallow import EXCLUDE, fields @@ -24,8 +25,8 @@ class Meta: def __init__( self, *, - state: str = None, - thread_id: str = None, + state: Optional[str] = None, + thread_id: Optional[str] = None, **kwargs, ): """Initialize a transaction resend object. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/models/transaction_record.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/models/transaction_record.py index e0d4dcd0ec..91ab6b33f8 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/models/transaction_record.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/models/transaction_record.py @@ -62,18 +62,18 @@ class Meta: def __init__( self, *, - transaction_id: str = None, - _type: str = None, - comment: str = None, - signature_request: list = None, - signature_response: list = None, - timing: dict = None, - formats: list = None, - messages_attach: list = None, - thread_id: str = None, - connection_id: str = None, - state: str = None, - endorser_write_txn: bool = None, + transaction_id: Optional[str] = None, + _type: Optional[str] = None, + comment: Optional[str] = None, + signature_request: Optional[list] = None, + signature_response: Optional[list] = None, + timing: Optional[dict] = None, + formats: Optional[list] = None, + messages_attach: Optional[list] = None, + thread_id: Optional[str] = None, + connection_id: Optional[str] = None, + state: Optional[str] = None, + endorser_write_txn: Optional[bool] = None, meta_data: Optional[dict] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/introduction/v0_1/base_service.py b/aries_cloudagent/protocols/introduction/v0_1/base_service.py index 493579ceea..50e8d7aa9b 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/base_service.py +++ b/aries_cloudagent/protocols/introduction/v0_1/base_service.py @@ -1,6 +1,7 @@ """Introduction service base classes.""" from abc import ABC, abstractmethod +from typing import Optional from ....core.error import BaseError from ....core.profile import ProfileSession @@ -34,7 +35,7 @@ async def start_introduction( target_connection_id: str, outbound_handler, session: ProfileSession, - message: str = None, + message: Optional[str] = None, ): """Start the introduction process between two connections. diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py b/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py index 3fd441e6be..d45fc9dd5b 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py @@ -1,5 +1,7 @@ """Represents a forwarded invitation from another agent.""" +from typing import Optional + from marshmallow import fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -25,7 +27,7 @@ class Meta: schema_class = "ForwardInvitationSchema" def __init__( - self, *, invitation: ConnectionInvitation = None, message: str = None, **kwargs + self, *, invitation: Optional[ConnectionInvitation] = None, message: Optional[str] = None, **kwargs ): """Initialize invitation object. diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py index 9f94e0fa7f..433e31df9c 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py @@ -1,5 +1,7 @@ """Represents an invitation returned to the introduction service.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -23,7 +25,7 @@ class Meta: schema_class = "InvitationSchema" def __init__( - self, *, invitation: ConnectionInvitation = None, message: str = None, **kwargs + self, *, invitation: Optional[ConnectionInvitation] = None, message: Optional[str] = None, **kwargs ): """Initialize invitation object. diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py index ec55ebddc3..1ad4ee2527 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py @@ -1,4 +1,5 @@ """Represents an request for an invitation from the introduction service.""" +from typing import Optional from marshmallow import EXCLUDE, fields @@ -20,7 +21,7 @@ class Meta: message_type = INVITATION_REQUEST schema_class = "InvitationRequestSchema" - def __init__(self, *, responder: str = None, message: str = None, **kwargs): + def __init__(self, *, responder: Optional[str] = None, message: Optional[str] = None, **kwargs): """Initialize invitation request object. Args: diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py index 9a0d1265a1..9cbd5b6aec 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py @@ -86,8 +86,8 @@ async def prepare_send( self, connection_id: str, credential_proposal: CredentialProposal, - auto_remove: bool = None, - comment: str = None, + auto_remove: Optional[bool] = None, + comment: Optional[str] = None, ) -> Tuple[V10CredentialExchange, CredentialOffer]: """Set up a new credential exchange for an automated send. @@ -123,16 +123,16 @@ async def create_proposal( self, connection_id: str, *, - auto_offer: bool = None, - auto_remove: bool = None, - comment: str = None, - credential_preview: CredentialPreview = None, - schema_id: str = None, - schema_issuer_did: str = None, - schema_name: str = None, - schema_version: str = None, - cred_def_id: str = None, - issuer_did: str = None, + auto_offer: Optional[bool] = None, + auto_remove: Optional[bool] = None, + comment: Optional[str] = None, + credential_preview: Optional[CredentialPreview] = None, + schema_id: Optional[str] = None, + schema_issuer_did: Optional[str] = None, + schema_name: Optional[str] = None, + schema_version: Optional[str] = None, + cred_def_id: Optional[str] = None, + issuer_did: Optional[str] = None, trace: bool = False, ) -> V10CredentialExchange: """Create a credential proposal. @@ -220,8 +220,8 @@ async def receive_proposal( async def create_offer( self, cred_ex_record: V10CredentialExchange, - counter_proposal: CredentialProposal = None, - comment: str = None, + counter_proposal: Optional[CredentialProposal] = None, + comment: Optional[str] = None, ) -> Tuple[V10CredentialExchange, CredentialOffer]: """Create a credential offer, update credential exchange record. @@ -569,7 +569,7 @@ async def issue_credential( self, cred_ex_record: V10CredentialExchange, *, - comment: str = None, + comment: Optional[str] = None, retries: int = 5, ) -> Tuple[V10CredentialExchange, CredentialIssue]: """Issue a credential. @@ -768,7 +768,7 @@ async def receive_credential( return cred_ex_record async def store_credential( - self, cred_ex_record: V10CredentialExchange, credential_id: str = None + self, cred_ex_record: V10CredentialExchange, credential_id: Optional[str] = None ) -> V10CredentialExchange: """Store a credential in holder wallet; send ack to issuer. diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py index 88438ff030..282ba2e47f 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py @@ -1,6 +1,6 @@ """A credential content message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -28,9 +28,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, credentials_attach: Sequence[AttachDecorator] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py index c50ff498eb..0e032fd063 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py @@ -1,6 +1,6 @@ """A credential offer content message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -29,10 +29,10 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, - credential_preview: CredentialPreview = None, + comment: Optional[str] = None, + credential_preview: Optional[CredentialPreview] = None, offers_attach: Sequence[AttachDecorator] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py index 75bf0b89a6..05416c54b1 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py @@ -1,5 +1,7 @@ """A credential proposal content message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -33,16 +35,16 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, - credential_proposal: CredentialPreview = None, - schema_id: str = None, - schema_issuer_did: str = None, - schema_name: str = None, - schema_version: str = None, - cred_def_id: str = None, - issuer_did: str = None, + comment: Optional[str] = None, + credential_proposal: Optional[CredentialPreview] = None, + schema_id: Optional[str] = None, + schema_issuer_did: Optional[str] = None, + schema_name: Optional[str] = None, + schema_version: Optional[str] = None, + cred_def_id: Optional[str] = None, + issuer_did: Optional[str] = None, **kwargs, ): """Initialize credential proposal object. diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py index b76ed8a7f0..5ae6deccc4 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py @@ -1,6 +1,6 @@ """A credential request content message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -28,9 +28,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, requests_attach: Sequence[AttachDecorator] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py index f7afb52a6b..16b1560f6e 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py @@ -1,6 +1,6 @@ """A credential preview inner object.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -18,7 +18,7 @@ class Meta: schema_class = "CredAttrSpecSchema" - def __init__(self, *, name: str, value: str, mime_type: str = None, **kwargs): + def __init__(self, *, name: str, value: str, mime_type: Optional[str] = None, **kwargs): """Initialize attribute preview object. Args: @@ -106,7 +106,7 @@ class Meta: message_type = CREDENTIAL_PREVIEW def __init__( - self, *, _type: str = None, attributes: Sequence[CredAttrSpec] = None, **kwargs + self, *, _type: Optional[str] = None, attributes: Sequence[CredAttrSpec] = None, **kwargs ): """Initialize credential preview object. diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py b/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py index 9406bd4c82..a73da8c01d 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py @@ -60,31 +60,31 @@ class Meta: def __init__( self, *, - credential_exchange_id: str = None, + credential_exchange_id: Optional[str] = None, connection_id: Optional[str] = None, - thread_id: str = None, - parent_thread_id: str = None, - initiator: str = None, - role: str = None, - state: str = None, - credential_definition_id: str = None, - schema_id: str = None, + thread_id: Optional[str] = None, + parent_thread_id: Optional[str] = None, + initiator: Optional[str] = None, + role: Optional[str] = None, + state: Optional[str] = None, + credential_definition_id: Optional[str] = None, + schema_id: Optional[str] = None, credential_proposal_dict: Union[ Mapping, CredentialProposal ] = None, # aries message: ..._dict for historic compat on all aries msgs credential_offer_dict: Union[Mapping, CredentialOffer] = None, # aries message credential_offer: Union[Mapping, IndyCredAbstract] = None, # indy artifact credential_request: Union[Mapping, IndyCredRequest] = None, # indy artifact - credential_request_metadata: Mapping = None, - credential_id: str = None, + credential_request_metadata: Optional[Mapping] = None, + credential_id: Optional[str] = None, raw_credential: Union[Mapping, IndyCredential] = None, # indy cred as received credential: Union[Mapping, IndyCredInfo] = None, # indy cred as stored - revoc_reg_id: str = None, - revocation_id: str = None, + revoc_reg_id: Optional[str] = None, + revocation_id: Optional[str] = None, auto_offer: bool = False, auto_issue: bool = False, auto_remove: bool = True, - error_msg: str = None, + error_msg: Optional[str] = None, trace: bool = False, # backward-compat: BaseRecord.from_storage() **kwargs, ): @@ -193,8 +193,8 @@ async def save_error_state( self, session: ProfileSession, *, - state: str = None, - reason: str = None, + state: Optional[str] = None, + reason: Optional[str] = None, log_params: Mapping[str, Any] = None, log_override: bool = False, ): @@ -226,7 +226,7 @@ async def save_error_state( LOGGER.exception("Error saving credential exchange error state") # Override - async def emit_event(self, session: ProfileSession, payload: Any = None): + async def emit_event(self, session: ProfileSession, payload: Optional[Any] = None): """Emit an event. Args: diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/routes.py b/aries_cloudagent/protocols/issue_credential/v1_0/routes.py index d77682b55f..725ad02992 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/routes.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/routes.py @@ -1,6 +1,7 @@ """Credential exchange admin routes.""" from json.decoder import JSONDecodeError +from typing import Optional from aiohttp import web from aiohttp_apispec import ( @@ -734,12 +735,12 @@ async def credential_exchange_send_proposal(request: web.BaseRequest): async def _create_free_offer( profile: Profile, cred_def_id: str, - connection_id: str = None, + connection_id: Optional[str] = None, auto_issue: bool = False, auto_remove: bool = False, - preview_spec: dict = None, - comment: str = None, - trace_msg: bool = None, + preview_spec: Optional[dict] = None, + comment: Optional[str] = None, + trace_msg: Optional[bool] = None, ): """Create a credential offer and related exchange record.""" diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py b/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py index c133f312d7..54656d5451 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py @@ -1,4 +1,4 @@ -from typing import Coroutine, Union +from typing import Coroutine, Optional, Union from ....connections.models.conn_record import ConnRecord from ....core.error import BaseError @@ -9,7 +9,7 @@ def problem_report_for_record( record: Union[ConnRecord, V20CredExRecord], desc_en: str, - thread_id: str = None, + thread_id: Optional[str] = None, ) -> V20CredProblemReport: """Create problem report for record. diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py index 4d0794c94c..e72614437a 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py @@ -2,7 +2,7 @@ import json import logging -from typing import Mapping, Tuple +from typing import Mapping, Optional, Tuple from marshmallow import RAISE @@ -241,7 +241,7 @@ async def receive_offer( """Receive indy credential offer.""" async def create_request( - self, cred_ex_record: V20CredExRecord, request_data: Mapping = None + self, cred_ex_record: V20CredExRecord, request_data: Optional[Mapping] = None ) -> CredFormatAttachment: """Create indy credential request.""" if cred_ex_record.state != V20CredExRecord.STATE_OFFER_RECEIVED: @@ -377,7 +377,7 @@ async def receive_credential( """ async def store_credential( - self, cred_ex_record: V20CredExRecord, cred_id: str = None + self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> None: """Store indy credential.""" cred = cred_ex_record.cred_issue.attachment(AnonCredsCredFormatHandler.format) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/handler.py index d280c820c5..cc5cc15f7e 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/handler.py @@ -2,7 +2,7 @@ import logging from abc import ABC, abstractclassmethod, abstractmethod -from typing import Mapping, Tuple +from typing import Mapping, Optional, Tuple from .....core.error import BaseError from .....core.profile import Profile @@ -90,7 +90,7 @@ async def receive_offer( @abstractmethod async def create_request( - self, cred_ex_record: V20CredExRecord, request_data: Mapping = None + self, cred_ex_record: V20CredExRecord, request_data: Optional[Mapping] = None ) -> CredFormatAttachment: """Create format specific credential request attachment data.""" @@ -120,6 +120,6 @@ async def receive_credential( @abstractmethod async def store_credential( - self, cred_ex_record: V20CredExRecord, cred_id: str = None + self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> None: """Store format specific credential from issue credential message.""" diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/indy/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/indy/handler.py index ad3cba25f0..ecadd98539 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/indy/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/indy/handler.py @@ -276,7 +276,7 @@ async def receive_offer( """Receive indy credential offer.""" async def create_request( - self, cred_ex_record: V20CredExRecord, request_data: Mapping = None + self, cred_ex_record: V20CredExRecord, request_data: Optional[Mapping] = None ) -> CredFormatAttachment: """Create indy credential request.""" # Temporary shim while the new anoncreds library integration is in progress @@ -513,7 +513,7 @@ async def receive_credential( """ async def store_credential( - self, cred_ex_record: V20CredExRecord, cred_id: str = None + self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> None: """Store indy credential.""" # Temporary shim while the new anoncreds library integration is in progress diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py index 48f180fdc7..04e7761d49 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py @@ -1,7 +1,7 @@ """V2.0 issue-credential linked data proof credential format handler.""" import logging -from typing import Mapping +from typing import Mapping, Optional from marshmallow import EXCLUDE, INCLUDE from pyld import jsonld @@ -201,7 +201,7 @@ async def receive_offer( """Receive linked data proof credential offer.""" async def create_request( - self, cred_ex_record: V20CredExRecord, request_data: Mapping = None + self, cred_ex_record: V20CredExRecord, request_data: Optional[Mapping] = None ) -> CredFormatAttachment: """Create linked data proof credential request.""" holder_did = request_data.get("holder_did") if request_data else None @@ -365,7 +365,7 @@ async def receive_credential( ) async def store_credential( - self, cred_ex_record: V20CredExRecord, cred_id: str = None + self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> None: """Store linked data proof credential.""" # Get attachment data diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py index 3c6b53f6a3..7836ab4d24 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py @@ -2,11 +2,10 @@ indy compatible, attachment is a valid verifiable credential """ - import datetime import json import logging -from typing import Mapping, Tuple +from typing import Mapping, Optional, Tuple from anoncreds import W3cCredential from marshmallow import RAISE @@ -297,7 +296,7 @@ async def receive_offer( """Receive vcdi credential offer.""" async def create_request( - self, cred_ex_record: V20CredExRecord, request_data: Mapping = None + self, cred_ex_record: V20CredExRecord, request_data: Optional[Mapping] = None ) -> CredFormatAttachment: """Create vcdi credential request.""" if cred_ex_record.state != V20CredExRecord.STATE_OFFER_RECEIVED: @@ -540,7 +539,7 @@ async def receive_credential( """ async def store_credential( - self, cred_ex_record: V20CredExRecord, cred_id: str = None + self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> None: """Store vcdi credential.""" cred = cred_ex_record.cred_issue.attachment(VCDICredFormatHandler.format) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py index 76d4f46882..130d29a73b 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py @@ -1,5 +1,7 @@ """Cred request artifacts to attach to RFC 453 messages.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .......messaging.models.base import BaseModel, BaseModelSchema @@ -15,7 +17,7 @@ class Meta: def __init__( self, - credential: dict = None, + credential: Optional[dict] = None, **kwargs, ): """Initialize vcdi cred abstract object. diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py index 6345a2eeb0..7c278cd82a 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py @@ -1,6 +1,6 @@ """Cred request artifacts to attach to RFC 453 messages.""" -from typing import Sequence, Union +from typing import Optional, Sequence, Union from marshmallow import EXCLUDE, fields @@ -25,9 +25,9 @@ class Meta: def __init__( self, - nonce: str = None, - cred_def_id: str = None, - key_correctness_proof: str = None, + nonce: Optional[str] = None, + cred_def_id: Optional[str] = None, + key_correctness_proof: Optional[str] = None, **kwargs, ): """Initialize values for AnoncredsLinkSecret.""" @@ -83,7 +83,7 @@ def __init__( self, algs_supported: Sequence[str] = None, did_methods_supported: Sequence[str] = None, - nonce: str = None, + nonce: Optional[str] = None, **kwargs, ): """Initialize values for DidcommSignedAttachment.""" @@ -162,8 +162,8 @@ class Meta: def __init__( self, data_model_versions_supported: Sequence[str] = None, - binding_required: str = None, - binding_method: str = None, + binding_required: Optional[str] = None, + binding_method: Optional[str] = None, credential: Union[dict, VerifiableCredential] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_request.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_request.py index 454805d6a3..0c47e51e6e 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_request.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_request.py @@ -1,6 +1,6 @@ """Cred request artifacts to attach to RFC 453 messages.""" -from typing import Mapping, Union +from typing import Mapping, Optional, Union from marshmallow import EXCLUDE, fields @@ -24,11 +24,11 @@ class Meta: def __init__( self, - entropy: str = None, - cred_def_id: str = None, - blinded_ms: Mapping = None, - blinded_ms_correctness_proof: Mapping = None, - nonce: str = None, + entropy: Optional[str] = None, + cred_def_id: Optional[str] = None, + blinded_ms: Optional[Mapping] = None, + blinded_ms_correctness_proof: Optional[Mapping] = None, + nonce: Optional[str] = None, **kwargs, ): """Initialize indy credential request.""" @@ -87,7 +87,7 @@ class Meta: schema_class = "DidcommSignedAttachmentSchema" - def __init__(self, attachment_id: str = None, **kwargs): + def __init__(self, attachment_id: Optional[str] = None, **kwargs): """Initialize DidcommSignedAttachment.""" super().__init__(**kwargs) self.attachment_id = attachment_id @@ -115,8 +115,8 @@ class Meta: def __init__( self, - anoncreds_link_secret: str = None, - didcomm_signed_attachment: str = None, + anoncreds_link_secret: Optional[str] = None, + didcomm_signed_attachment: Optional[str] = None, **kwargs, ): """Initialize binding proof.""" @@ -157,7 +157,7 @@ class Meta: def __init__( self, - data_model_version: str = None, + data_model_version: Optional[str] = None, binding_proof: Union[dict, BindingProof] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py index e67ef37831..1548b4b8b0 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py @@ -52,8 +52,8 @@ async def prepare_send( connection_id: str, cred_proposal: V20CredProposal, verification_method: Optional[str] = None, - auto_remove: bool = None, - replacement_id: str = None, + auto_remove: Optional[bool] = None, + replacement_id: Optional[str] = None, ) -> Tuple[V20CredExRecord, V20CredOffer]: """Set up a new credential exchange record for an automated send. @@ -91,8 +91,8 @@ async def create_proposal( self, connection_id: str, *, - auto_remove: bool = None, - comment: str = None, + auto_remove: Optional[bool] = None, + comment: Optional[str] = None, cred_preview: V20CredPreview, fmt2filter: Mapping[V20CredFormat.Format, Mapping[str, str]], trace: bool = False, @@ -197,9 +197,9 @@ async def receive_proposal( async def create_offer( self, cred_ex_record: V20CredExRecord, - counter_proposal: V20CredProposal = None, - replacement_id: str = None, - comment: str = None, + counter_proposal: Optional[V20CredProposal] = None, + replacement_id: Optional[str] = None, + comment: Optional[str] = None, ) -> Tuple[V20CredExRecord, V20CredOffer]: """Create credential offer, update credential exchange record. @@ -326,7 +326,7 @@ async def receive_offer( return cred_ex_record async def create_request( - self, cred_ex_record: V20CredExRecord, holder_did: str, comment: str = None + self, cred_ex_record: V20CredExRecord, holder_did: str, comment: Optional[str] = None ) -> Tuple[V20CredExRecord, V20CredRequest]: """Create a credential request. @@ -485,7 +485,7 @@ async def issue_credential( self, cred_ex_record: V20CredExRecord, *, - comment: str = None, + comment: Optional[str] = None, ) -> Tuple[V20CredExRecord, V20CredIssue]: """Issue a credential. @@ -612,7 +612,7 @@ async def receive_credential( return cred_ex_record async def store_credential( - self, cred_ex_record: V20CredExRecord, cred_id: str = None + self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> Tuple[V20CredExRecord, V20CredAck]: """Store a credential in holder wallet; send ack to issuer. diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_format.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_format.py index 137e8df070..b6cf38537b 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_format.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_format.py @@ -2,7 +2,7 @@ from collections import namedtuple from enum import Enum -from typing import TYPE_CHECKING, Mapping, Sequence, Type, Union +from typing import TYPE_CHECKING, Mapping, Optional, Sequence, Type, Union from marshmallow import EXCLUDE, fields from uuid_utils import uuid4 @@ -132,8 +132,8 @@ def get_attachment_data( def __init__( self, *, - attach_id: str = None, - format_: str = None, + attach_id: Optional[str] = None, + format_: Optional[str] = None, ): """Initialize issue-credential protocol message attachment format.""" self.attach_id = attach_id or uuid4() diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py index f029b15d23..2773381f8d 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py @@ -1,6 +1,6 @@ """Credential issue message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -28,10 +28,10 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - replacement_id: str = None, - comment: str = None, + replacement_id: Optional[str] = None, + comment: Optional[str] = None, formats: Sequence[V20CredFormat] = None, credentials_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py index 0ca4b3db29..1db5b9e23e 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py @@ -1,6 +1,6 @@ """Credential offer message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -29,11 +29,11 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - replacement_id: str = None, - comment: str = None, - credential_preview: V20CredPreview = None, + replacement_id: Optional[str] = None, + comment: Optional[str] = None, + credential_preview: Optional[V20CredPreview] = None, formats: Sequence[V20CredFormat] = None, offers_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py index 4ad4898241..d91d4f0f6a 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py @@ -1,6 +1,6 @@ """Credential proposal message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -30,10 +30,10 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, - credential_preview: V20CredPreview = None, + comment: Optional[str] = None, + credential_preview: Optional[V20CredPreview] = None, formats: Sequence[V20CredFormat] = None, filters_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py index f403d46f5c..22f7103c0d 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py @@ -1,6 +1,6 @@ """Credential request message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -27,9 +27,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, formats: Sequence[V20CredFormat] = None, requests_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py index a8efb2363f..fb58534a69 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py @@ -1,6 +1,6 @@ """Credential preview inner object.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -18,7 +18,7 @@ class Meta: schema_class = "V20CredAttrSpecSchema" - def __init__(self, *, name: str, value: str, mime_type: str = None, **kwargs): + def __init__(self, *, name: str, value: str, mime_type: Optional[str] = None, **kwargs): """Initialize attribute preview object. Args: @@ -108,7 +108,7 @@ class Meta: def __init__( self, *, - _type: str = None, + _type: Optional[str] = None, attributes: Sequence[V20CredAttrSpec] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py index 7e853f36d4..36dad47fa0 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py @@ -54,14 +54,14 @@ class Meta: def __init__( self, *, - cred_ex_id: str = None, - connection_id: str = None, + cred_ex_id: Optional[str] = None, + connection_id: Optional[str] = None, verification_method: Optional[str] = None, - thread_id: str = None, - parent_thread_id: str = None, - initiator: str = None, - role: str = None, - state: str = None, + thread_id: Optional[str] = None, + parent_thread_id: Optional[str] = None, + initiator: Optional[str] = None, + role: Optional[str] = None, + state: Optional[str] = None, cred_proposal: Union[Mapping, V20CredProposal] = None, # aries message cred_offer: Union[Mapping, V20CredOffer] = None, # aries message cred_request: Union[Mapping, V20CredRequest] = None, # aries message @@ -69,11 +69,11 @@ def __init__( auto_offer: bool = False, auto_issue: bool = False, auto_remove: bool = True, - error_msg: str = None, + error_msg: Optional[str] = None, trace: bool = False, # backward compat: BaseRecord.from_storage() - cred_id_stored: str = None, # backward compat: BaseRecord.from_storage() - conn_id: str = None, # backward compat: BaseRecord.from_storage() - by_format: Mapping = 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, ): """Initialize a new V20CredExRecord.""" @@ -149,8 +149,8 @@ async def save_error_state( self, session: ProfileSession, *, - state: str = None, - reason: str = None, + state: Optional[str] = None, + reason: Optional[str] = None, log_params: Mapping[str, Any] = None, log_override: bool = False, ): @@ -182,7 +182,7 @@ async def save_error_state( LOGGER.exception(err) # Override - async def emit_event(self, session: ProfileSession, payload: Any = None): + async def emit_event(self, session: ProfileSession, payload: Optional[Any] = None): """Emit an event. Args: diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/indy.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/indy.py index e1b2e23344..71e263c9c4 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/indy.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/indy.py @@ -1,6 +1,6 @@ """Indy-specific credential exchange information with non-secrets storage.""" -from typing import Any, Mapping, Sequence +from typing import Any, Mapping, Optional, Sequence from marshmallow import EXCLUDE, fields @@ -31,13 +31,13 @@ class Meta: def __init__( self, - cred_ex_indy_id: str = None, + cred_ex_indy_id: Optional[str] = None, *, - cred_ex_id: str = None, - cred_id_stored: str = None, - cred_request_metadata: Mapping = None, - rev_reg_id: str = None, - cred_rev_id: str = None, + cred_ex_id: Optional[str] = None, + cred_id_stored: Optional[str] = None, + cred_request_metadata: Optional[Mapping] = None, + rev_reg_id: Optional[str] = None, + cred_rev_id: Optional[str] = None, **kwargs, ): """Initialize indy credential exchange record details.""" diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py index a86a49e810..524a9d5c67 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py @@ -1,6 +1,5 @@ """Linked data proof specific credential exchange information with non-secrets storage.""" - -from typing import Any, Sequence +from typing import Any, Optional, Sequence from marshmallow import EXCLUDE, fields @@ -25,10 +24,10 @@ class Meta: def __init__( self, - cred_ex_ld_proof_id: str = None, + cred_ex_ld_proof_id: Optional[str] = None, *, - cred_ex_id: str = None, - cred_id_stored: str = None, + cred_ex_id: Optional[str] = None, + cred_id_stored: Optional[str] = None, **kwargs, ): """Initialize LD Proof credential exchange record details.""" diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/routes.py b/aries_cloudagent/protocols/issue_credential/v2_0/routes.py index 9c5bdc85e0..747ff9db68 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/routes.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/routes.py @@ -2,7 +2,7 @@ import logging from json.decoder import JSONDecodeError -from typing import Mapping +from typing import Mapping, Optional from aiohttp import web from aiohttp_apispec import ( @@ -913,14 +913,14 @@ async def credential_exchange_send_proposal(request: web.BaseRequest): async def _create_free_offer( profile: Profile, - filt_spec: Mapping = None, - connection_id: str = None, + filt_spec: Optional[Mapping] = None, + connection_id: Optional[str] = None, auto_issue: bool = False, auto_remove: bool = False, - replacement_id: str = None, - preview_spec: dict = None, - comment: str = None, - trace_msg: bool = None, + replacement_id: Optional[str] = None, + preview_spec: Optional[dict] = None, + comment: Optional[str] = None, + trace_msg: Optional[bool] = None, ): """Create a credential offer and related exchange record.""" diff --git a/aries_cloudagent/protocols/notification/v1_0/messages/ack.py b/aries_cloudagent/protocols/notification/v1_0/messages/ack.py index c5f3accf78..3732c59653 100644 --- a/aries_cloudagent/protocols/notification/v1_0/messages/ack.py +++ b/aries_cloudagent/protocols/notification/v1_0/messages/ack.py @@ -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 @@ -18,7 +19,7 @@ class Meta: message_type = NOTIF_10_ACK schema_class = "V10AckSchema" - def __init__(self, status: str = None, **kwargs): + def __init__(self, status: Optional[str] = None, **kwargs): """Initialize an explicit ack message instance. Args: diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py b/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py index 6f18750463..534455ea1f 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py @@ -167,7 +167,7 @@ def wrap_message(cls, message: dict) -> AttachDecorator: """Convert an aries message to an attachment decorator.""" return AttachDecorator.data_json(mapping=message, ident="request-0") - def to_url(self, base_url: str = None) -> str: + def to_url(self, base_url: Optional[str] = None) -> str: """Convert an invitation message to URL format for sharing. Returns: diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py b/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py index 66f27e44e2..b3b829867e 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/models/invitation.py @@ -1,6 +1,6 @@ """Record for out of band invitations.""" -from typing import Any, Mapping, Union +from typing import Any, Mapping, Optional, Union from marshmallow import fields @@ -29,13 +29,13 @@ class Meta: def __init__( self, *, - invitation_id: str = None, - state: str = None, - invi_msg_id: str = None, + invitation_id: Optional[str] = None, + state: Optional[str] = None, + invi_msg_id: Optional[str] = None, invitation: Union[InvitationMessage, Mapping] = None, # invitation message - invitation_url: str = None, - oob_id: str = None, - public_did: str = None, # backward-compat: BaseRecord.from_storage() + invitation_url: Optional[str] = None, + oob_id: Optional[str] = None, + public_did: Optional[str] = None, # backward-compat: BaseRecord.from_storage() trace: bool = False, **kwargs, ): diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/models/oob_record.py b/aries_cloudagent/protocols/out_of_band/v1_0/models/oob_record.py index 0a0e7cdf59..1eef17ffe6 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/models/oob_record.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/models/oob_record.py @@ -158,7 +158,7 @@ async def delete_record(self, session: ProfileSession): ) async def metadata_get( - self, session: ProfileSession, key: str, default: Any = None + self, session: ProfileSession, key: str, default: Optional[Any] = None ) -> Any: """Retrieve arbitrary metadata associated with this connection. diff --git a/aries_cloudagent/protocols/present_proof/dif/pres_exch.py b/aries_cloudagent/protocols/present_proof/dif/pres_exch.py index 1b37e2c105..677151954d 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch.py @@ -31,13 +31,13 @@ class Meta: def __init__( self, *, - jwt: Mapping = None, - jwt_vc: Mapping = None, - jwt_vp: Mapping = None, - ldp: Mapping = None, - ldp_vc: Mapping = None, - ldp_vp: Mapping = None, - di_vc: Mapping = None, + jwt: Optional[Mapping] = None, + jwt_vc: Optional[Mapping] = None, + jwt_vp: Optional[Mapping] = None, + ldp: Optional[Mapping] = None, + ldp_vc: Optional[Mapping] = None, + ldp_vp: Optional[Mapping] = None, + di_vc: Optional[Mapping] = None, ): """Initialize format.""" self.jwt = jwt @@ -78,15 +78,15 @@ class Meta: def __init__( self, *, - _name: str = None, - purpose: str = None, - rule: str = None, - count: int = None, - minimum: int = None, - maximum: int = None, - _from: str = None, + _name: Optional[str] = None, + purpose: Optional[str] = None, + rule: Optional[str] = None, + count: Optional[int] = None, + minimum: Optional[int] = None, + maximum: Optional[int] = None, + _from: Optional[str] = None, # Self_reference - from_nested: Sequence = None, + from_nested: Optional[Sequence] = None, ): """Initialize SubmissionRequirement.""" self._name = _name @@ -162,8 +162,8 @@ class Meta: def __init__( self, *, - uri: str = None, - required: bool = None, + uri: Optional[str] = None, + required: Optional[bool] = None, ): """Initialize SchemaInputDescriptor.""" self.uri = uri @@ -250,7 +250,7 @@ def __init__( self, *, field_ids: Sequence[str] = None, - directive: str = None, + directive: Optional[str] = None, ): """Initialize Holder.""" self.field_ids = field_ids @@ -294,16 +294,16 @@ def __init__( self, *, _not: bool = False, - _type: str = None, - fmt: str = None, - pattern: str = None, - minimum: str = None, - maximum: str = None, - min_length: int = None, - max_length: int = None, - exclusive_min: str = None, - exclusive_max: str = None, - const: str = None, + _type: Optional[str] = None, + fmt: Optional[str] = None, + pattern: Optional[str] = None, + minimum: Optional[str] = None, + maximum: Optional[str] = None, + min_length: Optional[int] = None, + max_length: Optional[int] = None, + exclusive_min: Optional[str] = None, + exclusive_max: Optional[str] = None, + const: Optional[str] = None, enums: Sequence[str] = None, ): """Initialize Filter.""" @@ -402,11 +402,11 @@ class Meta: def __init__( self, *, - id: str = None, + id: Optional[str] = None, paths: Sequence[str] = None, - purpose: str = None, - predicate: str = None, - _filter: Filter = None, + purpose: Optional[str] = None, + predicate: Optional[str] = None, + _filter: Optional[Filter] = None, ): """Initialize Field.""" self.paths = paths @@ -451,13 +451,13 @@ class Meta: def __init__( self, *, - subject_issuer: str = None, - limit_disclosure: bool = None, + subject_issuer: Optional[str] = None, + limit_disclosure: Optional[bool] = None, holders: Sequence[DIFHolder] = None, _fields: Sequence[DIFField] = None, - status_active: str = None, - status_suspended: str = None, - status_revoked: str = None, + status_active: Optional[str] = None, + status_suspended: Optional[str] = None, + status_revoked: Optional[str] = None, ): """Initialize Constraints for Input Descriptor.""" self.subject_issuer = subject_issuer @@ -550,13 +550,13 @@ class Meta: def __init__( self, *, - id: str = None, + id: Optional[str] = None, groups: Sequence[str] = None, - name: str = None, - purpose: str = None, - metadata: dict = None, - constraint: Constraints = None, - schemas: SchemasInputDescriptorFilter = None, + name: Optional[str] = None, + purpose: Optional[str] = None, + metadata: Optional[dict] = None, + constraint: Optional[Constraints] = None, + schemas: Optional[SchemasInputDescriptorFilter] = None, ): """Initialize InputDescriptors.""" self.id = id @@ -627,11 +627,11 @@ class Meta: def __init__( self, *, - count: int = None, - maximum: int = None, - minimum: int = None, + count: Optional[int] = None, + maximum: Optional[int] = None, + minimum: Optional[int] = None, input_descriptors: Sequence[InputDescriptors] = None, - nested_req: Sequence = None, + nested_req: Optional[Sequence] = None, ): """Initialize Requirement.""" self.count = count @@ -681,10 +681,10 @@ class Meta: def __init__( self, *, - id: str = None, - name: str = None, - purpose: str = None, - fmt: ClaimFormat = None, + id: Optional[str] = None, + name: Optional[str] = None, + purpose: Optional[str] = None, + fmt: Optional[ClaimFormat] = None, submission_requirements: Sequence[SubmissionRequirements] = None, input_descriptors: Sequence[InputDescriptors] = None, **kwargs, @@ -752,9 +752,9 @@ class Meta: def __init__( self, *, - id: str = None, - fmt: str = None, - path: str = None, + id: Optional[str] = None, + fmt: Optional[str] = None, + path: Optional[str] = None, ): """Initialize InputDescriptorMapping.""" self.id = id @@ -792,8 +792,8 @@ class Meta: def __init__( self, *, - id: str = None, - definition_id: str = None, + id: Optional[str] = None, + definition_id: Optional[str] = None, descriptor_maps: Sequence[InputDescriptorMapping] = None, ): """Initialize InputDescriptorMapping.""" @@ -868,8 +868,8 @@ class Meta: def __init__( self, *, - challenge: str = None, - domain: str = None, + challenge: Optional[str] = None, + domain: Optional[str] = None, ): """Initialize DIFOptions.""" self.challenge = challenge diff --git a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py index 9a4a9f9104..b699a9bb71 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py @@ -96,9 +96,9 @@ class DIFPresExchHandler: def __init__( self, profile: Profile, - pres_signing_did: str = None, - proof_type: str = None, - reveal_doc: dict = None, + pres_signing_did: Optional[str] = None, + proof_type: Optional[str] = None, + reveal_doc: Optional[dict] = None, ): """Initialize PresExchange Handler.""" super().__init__() @@ -1042,7 +1042,7 @@ async def apply_requirements( self, req: Requirement, credentials: Sequence[VCRecord], - records_filter: dict = None, + records_filter: Optional[dict] = None, ) -> dict: """Apply Requirement. @@ -1197,10 +1197,10 @@ async def create_vp( self, credentials: Sequence[VCRecord], pd: PresentationDefinition, - challenge: str = None, - domain: str = None, - records_filter: dict = None, - is_holder_override: bool = None, + challenge: Optional[str] = None, + domain: Optional[str] = None, + records_filter: Optional[dict] = None, + is_holder_override: Optional[bool] = None, ) -> Union[Sequence[dict], dict]: """Create VerifiablePresentation. diff --git a/aries_cloudagent/protocols/present_proof/v1_0/manager.py b/aries_cloudagent/protocols/present_proof/v1_0/manager.py index 8ddf88e12f..b89aad435c 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/manager.py @@ -47,8 +47,8 @@ async def create_exchange_for_proposal( self, connection_id: str, presentation_proposal_message: PresentationProposal, - auto_present: bool = None, - auto_remove: bool = None, + auto_present: Optional[bool] = None, + auto_remove: Optional[bool] = None, ): """Create a presentation exchange record for input presentation proposal. @@ -113,10 +113,10 @@ async def receive_proposal( async def create_bound_request( self, presentation_exchange_record: V10PresentationExchange, - name: str = None, - version: str = None, - nonce: str = None, - comment: str = None, + name: Optional[str] = None, + version: Optional[str] = None, + nonce: Optional[str] = None, + comment: Optional[str] = None, ): """Create a presentation request bound to a proposal. @@ -170,8 +170,8 @@ async def create_exchange_for_request( self, connection_id: str, presentation_request_message: PresentationRequest, - auto_verify: bool = None, - auto_remove: bool = None, + auto_verify: Optional[bool] = None, + auto_remove: Optional[bool] = None, ): """Create a presentation exchange record for input presentation request. @@ -233,7 +233,7 @@ async def create_presentation( self, presentation_exchange_record: V10PresentationExchange, requested_credentials: dict, - comment: str = None, + comment: Optional[str] = None, ): """Create a presentation. diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py index 3458431dbf..9cf84c0190 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py @@ -1,6 +1,6 @@ """A (proof) presentation content message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -26,9 +26,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, presentations_attach: Sequence[AttachDecorator] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py index 6b9c2052a6..695351bb9a 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py @@ -1,5 +1,7 @@ """Represents an explicit RFC 15 ack message, adopted into present-proof protocol.""" +from typing import Optional + from marshmallow import EXCLUDE, fields, validate from ....notification.v1_0.messages.ack import V10Ack, V10AckSchema @@ -20,7 +22,7 @@ class Meta: message_type = PRESENTATION_ACK schema_class = "PresentationAckSchema" - def __init__(self, status: str = None, verification_result: str = None, **kwargs): + def __init__(self, status: Optional[str] = None, verification_result: Optional[str] = None, **kwargs): """Initialize an explicit ack message instance. Args: diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py index 5f0061627e..31b23b04b5 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py @@ -1,5 +1,7 @@ """A presentation proposal content message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....indy.models.pres_preview import IndyPresPreview, IndyPresPreviewSchema @@ -24,10 +26,10 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, - presentation_proposal: IndyPresPreview = None, + comment: Optional[str] = None, + presentation_proposal: Optional[IndyPresPreview] = None, **kwargs, ): """Initialize presentation proposal object. diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py index 4c8b563d5a..97c46e51db 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py @@ -1,6 +1,5 @@ """A presentation request content message.""" - -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, fields @@ -29,9 +28,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, request_presentations_attach: Sequence[AttachDecorator] = None, **kwargs, ): diff --git a/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py b/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py index f6b6bf1060..7732de5997 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py @@ -57,12 +57,12 @@ class Meta: def __init__( self, *, - presentation_exchange_id: str = None, + presentation_exchange_id: Optional[str] = None, connection_id: Optional[str] = None, - thread_id: str = None, - initiator: str = None, - role: str = None, - state: str = None, + thread_id: Optional[str] = None, + initiator: Optional[str] = None, + role: Optional[str] = None, + state: Optional[str] = None, presentation_proposal_dict: Union[ PresentationProposal, Mapping ] = None, # aries message: ..._dict for historic compat on all aries msgs @@ -71,11 +71,11 @@ def __init__( PresentationRequest, Mapping ] = None, # aries message presentation: Union[IndyProof, Mapping] = None, # indy proof - verified: str = None, - verified_msgs: list = None, + verified: Optional[str] = None, + verified_msgs: Optional[list] = None, auto_present: bool = False, auto_verify: bool = False, - error_msg: str = None, + error_msg: Optional[str] = None, trace: bool = False, # backward compat: BaseRecord.from_storage() auto_remove: bool = False, **kwargs, @@ -161,8 +161,8 @@ async def save_error_state( self, session: ProfileSession, *, - state: str = None, - reason: str = None, + state: Optional[str] = None, + reason: Optional[str] = None, log_params: Mapping[str, Any] = None, log_override: bool = False, ): @@ -194,7 +194,7 @@ async def save_error_state( LOGGER.exception(err) # Override - async def emit_event(self, session: ProfileSession, payload: Any = None): + async def emit_event(self, session: ProfileSession, payload: Optional[Any] = None): """Emit an event. Args: diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py index 7c3fb5815a..74529488cd 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py @@ -1,8 +1,7 @@ """V2.0 present-proof indy presentation-exchange format handler.""" - import json import logging -from typing import Mapping, Tuple +from typing import Mapping, Optional, Tuple from marshmallow import RAISE @@ -96,7 +95,7 @@ def get_format_data( async def create_bound_request( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> Tuple[V20PresFormat, AttachDecorator]: """Create a presentation request bound to a proposal. @@ -127,7 +126,7 @@ async def create_bound_request( async def create_pres( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> Tuple[V20PresFormat, AttachDecorator]: """Create a presentation.""" requested_credentials = {} diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py index 569d303705..4d31edadfb 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py @@ -105,7 +105,7 @@ def get_format_data( async def create_bound_request( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> Tuple[V20PresFormat, AttachDecorator]: """Create a presentation request bound to a proposal. diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py index 7d0de6467f..9761b54d24 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py @@ -1,8 +1,7 @@ """present-proof-v2 format handler - supports DIF and INDY.""" - import logging from abc import ABC, abstractclassmethod, abstractmethod -from typing import Tuple +from typing import Optional, Tuple from .....core.error import BaseError from .....core.profile import Profile @@ -64,7 +63,7 @@ def validate_fields(cls, message_type: str, attachment_data: dict) -> None: async def create_bound_request( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> PresFormatAttachment: """Create a presentation request bound to a proposal.""" @@ -72,7 +71,7 @@ async def create_bound_request( async def create_pres( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> PresFormatAttachment: """Create a presentation.""" diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/indy/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/indy/handler.py index 8646c86754..306ed3b1af 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/indy/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/indy/handler.py @@ -2,7 +2,7 @@ import json import logging -from typing import Mapping, Tuple +from typing import Mapping, Optional, Tuple from marshmallow import RAISE @@ -113,7 +113,7 @@ def get_format_data( async def create_bound_request( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> Tuple[V20PresFormat, AttachDecorator]: """Create a presentation request bound to a proposal. @@ -151,7 +151,7 @@ async def create_bound_request( async def create_pres( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, + request_data: Optional[dict] = None, ) -> Tuple[V20PresFormat, AttachDecorator]: """Create a presentation.""" # Temporary shim while the new anoncreds library integration is in progress diff --git a/aries_cloudagent/protocols/present_proof/v2_0/manager.py b/aries_cloudagent/protocols/present_proof/v2_0/manager.py index 040314e232..1786a6fea3 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/manager.py @@ -39,8 +39,8 @@ async def create_exchange_for_proposal( self, connection_id: str, pres_proposal_message: V20PresProposal, - auto_present: bool = None, - auto_remove: bool = None, + auto_present: Optional[bool] = None, + auto_remove: Optional[bool] = None, ): """Create a presentation exchange record for input presentation proposal. @@ -103,8 +103,8 @@ async def receive_pres_proposal( async def create_bound_request( self, pres_ex_record: V20PresExRecord, - request_data: dict = None, - comment: str = None, + request_data: Optional[dict] = None, + comment: Optional[str] = None, ): """Create a presentation request bound to a proposal. @@ -159,8 +159,8 @@ async def create_exchange_for_request( self, connection_id: str, pres_request_message: V20PresRequest, - auto_verify: bool = None, - auto_remove: bool = None, + auto_verify: Optional[bool] = None, + auto_remove: Optional[bool] = None, ): """Create a presentation exchange record for input presentation request. @@ -216,7 +216,7 @@ async def create_pres( pres_ex_record: V20PresExRecord, request_data: Optional[dict] = None, *, - comment: str = None, + comment: Optional[str] = None, ) -> Tuple[V20PresExRecord, V20Pres]: """Create a presentation. diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py index e9dd2ca303..290de5f277 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py @@ -1,6 +1,5 @@ """A (proof) presentation content message.""" - -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -27,9 +26,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, formats: Sequence[V20PresFormat] = None, presentations_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py index c48e2f9bac..859310da79 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py @@ -1,5 +1,7 @@ """Represents an explicit RFC 15 ack message, adopted into present-proof protocol.""" +from typing import Optional + from marshmallow import EXCLUDE, fields, validate from ....notification.v1_0.messages.ack import V10Ack, V10AckSchema @@ -18,7 +20,7 @@ class Meta: message_type = PRES_20_ACK schema_class = "V20PresAckSchema" - def __init__(self, status: str = None, verification_result: str = None, **kwargs): + def __init__(self, status: Optional[str] = None, verification_result: Optional[str] = None, **kwargs): """Initialize an explicit ack message instance. Args: diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_format.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_format.py index 5cbefff1ce..b6760b1ee9 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_format.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_format.py @@ -2,7 +2,7 @@ from collections import namedtuple from enum import Enum -from typing import TYPE_CHECKING, Mapping, Sequence, Type, Union +from typing import TYPE_CHECKING, Mapping, Optional, Sequence, Type, Union from marshmallow import EXCLUDE, fields from uuid_utils import uuid4 @@ -111,8 +111,8 @@ def get_attachment_data( def __init__( self, *, - attach_id: str = None, - format_: str = None, + attach_id: Optional[str] = None, + format_: Optional[str] = None, ): """Initialize present-proof protocol message attachment format.""" self.attach_id = attach_id or uuid4() diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py index 5bdb5885d2..bc8d7d53e4 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py @@ -1,6 +1,6 @@ """A presentation proposal content message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -29,9 +29,9 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, + comment: Optional[str] = None, formats: Sequence[V20PresFormat] = None, proposals_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py index dd9e0cbf08..d9a6e525eb 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py @@ -1,6 +1,6 @@ """A presentation request content message.""" -from typing import Sequence +from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -27,10 +27,10 @@ class Meta: def __init__( self, - _id: str = None, + _id: Optional[str] = None, *, - comment: str = None, - will_confirm: bool = None, + comment: Optional[str] = None, + will_confirm: Optional[bool] = None, formats: Sequence[V20PresFormat] = None, request_presentations_attach: Sequence[AttachDecorator] = None, **kwargs, diff --git a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py index cc0889a210..f0ccd46859 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py @@ -1,7 +1,7 @@ """Presentation exchange record.""" import logging -from typing import Any, Mapping, Union +from typing import Any, Mapping, Optional, Union from marshmallow import Schema, fields, validate @@ -50,22 +50,22 @@ class Meta: def __init__( self, *, - pres_ex_id: str = None, - connection_id: str = None, - thread_id: str = None, - initiator: str = None, - role: str = None, - state: str = None, + pres_ex_id: Optional[str] = None, + connection_id: Optional[str] = None, + thread_id: Optional[str] = None, + initiator: Optional[str] = None, + role: Optional[str] = None, + state: Optional[str] = None, pres_proposal: Union[V20PresProposal, Mapping] = None, # aries message pres_request: Union[V20PresRequest, Mapping] = None, # aries message pres: Union[V20Pres, Mapping] = None, # aries message - verified: str = None, - verified_msgs: list = None, + verified: Optional[str] = None, + verified_msgs: Optional[list] = None, auto_present: bool = False, auto_verify: bool = False, - error_msg: str = None, + error_msg: Optional[str] = None, trace: bool = False, # backward compat: BaseRecord.FromStorage() - by_format: Mapping = None, # backward compat: BaseRecord.FromStorage() + by_format: Optional[Mapping] = None, # backward compat: BaseRecord.FromStorage() auto_remove: bool = False, **kwargs, ): @@ -149,8 +149,8 @@ async def save_error_state( self, session: ProfileSession, *, - state: str = None, - reason: str = None, + state: Optional[str] = None, + reason: Optional[str] = None, log_params: Mapping[str, Any] = None, log_override: bool = False, ): @@ -182,7 +182,7 @@ async def save_error_state( LOGGER.exception(err) # Override - async def emit_event(self, session: ProfileSession, payload: Any = None): + async def emit_event(self, session: ProfileSession, payload: Optional[Any] = None): """Emit an event. Args: diff --git a/aries_cloudagent/protocols/problem_report/v1_0/__init__.py b/aries_cloudagent/protocols/problem_report/v1_0/__init__.py index a7b5c1623b..c5c60e928d 100644 --- a/aries_cloudagent/protocols/problem_report/v1_0/__init__.py +++ b/aries_cloudagent/protocols/problem_report/v1_0/__init__.py @@ -1,4 +1,4 @@ -from typing import Coroutine, Union +from typing import Coroutine, Optional, Union from ....connections.models.conn_record import ConnRecord from ....core.error import BaseError @@ -11,7 +11,7 @@ async def internal_error( http_error_class, record: Union[ConnRecord, BaseRecord], outbound_handler: Coroutine, - code: str = None, + code: Optional[str] = None, ): """Send problem report and raise corresponding HTTP error.""" if record: diff --git a/aries_cloudagent/protocols/problem_report/v1_0/message.py b/aries_cloudagent/protocols/problem_report/v1_0/message.py index 66dc17950d..ffda9ca6d1 100644 --- a/aries_cloudagent/protocols/problem_report/v1_0/message.py +++ b/aries_cloudagent/protocols/problem_report/v1_0/message.py @@ -1,6 +1,6 @@ """Represents a generic problem report message.""" -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validate, validates_schema @@ -26,13 +26,13 @@ def __init__( *, description: Mapping[str, str] = None, problem_items: Sequence[Mapping[str, str]] = None, - who_retries: str = None, + who_retries: Optional[str] = None, fix_hint: Mapping[str, str] = None, - impact: str = None, - where: str = None, - noticed_time: str = None, - tracking_uri: str = None, - escalation_uri: str = None, + impact: Optional[str] = None, + where: Optional[str] = None, + noticed_time: Optional[str] = None, + tracking_uri: Optional[str] = None, + escalation_uri: Optional[str] = None, **kwargs, ): """Initialize a ProblemReport message instance. diff --git a/aries_cloudagent/protocols/revocation_notification/v1_0/messages/revoke.py b/aries_cloudagent/protocols/revocation_notification/v1_0/messages/revoke.py index 1f962ed21a..b961a731dc 100644 --- a/aries_cloudagent/protocols/revocation_notification/v1_0/messages/revoke.py +++ b/aries_cloudagent/protocols/revocation_notification/v1_0/messages/revoke.py @@ -1,5 +1,7 @@ """Revoke message.""" +from typing import Optional + from marshmallow import fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -19,7 +21,7 @@ class Meta: message_type = REVOKE schema_class = "RevokeSchema" - def __init__(self, *, thread_id: str, comment: str = None, **kwargs): + def __init__(self, *, thread_id: str, comment: Optional[str] = None, **kwargs): """Initialize revoke message.""" super().__init__(**kwargs) # TODO support please ack diff --git a/aries_cloudagent/protocols/revocation_notification/v1_0/models/rev_notification_record.py b/aries_cloudagent/protocols/revocation_notification/v1_0/models/rev_notification_record.py index e2a5b66c4d..c09dcbc649 100644 --- a/aries_cloudagent/protocols/revocation_notification/v1_0/models/rev_notification_record.py +++ b/aries_cloudagent/protocols/revocation_notification/v1_0/models/rev_notification_record.py @@ -39,13 +39,13 @@ class Meta: def __init__( self, *, - revocation_notification_id: str = None, - rev_reg_id: str = None, - cred_rev_id: str = None, - connection_id: str = None, - thread_id: str = None, - comment: str = None, - version: str = None, + revocation_notification_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + cred_rev_id: Optional[str] = None, + connection_id: Optional[str] = None, + thread_id: Optional[str] = None, + comment: Optional[str] = None, + version: Optional[str] = None, **kwargs, ): """Construct record.""" diff --git a/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py b/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py index 44aa3cef2c..44fef8d8c0 100644 --- a/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py +++ b/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py @@ -1,4 +1,5 @@ """Revoke message.""" +from typing import Optional from marshmallow import fields, validate @@ -28,8 +29,8 @@ def __init__( *, revocation_format: str, credential_id: str, - please_ack: PleaseAckDecorator = None, - comment: str = None, + please_ack: Optional[PleaseAckDecorator] = None, + comment: Optional[str] = None, **kwargs, ): """Initialize revoke message.""" diff --git a/aries_cloudagent/protocols/revocation_notification/v2_0/models/rev_notification_record.py b/aries_cloudagent/protocols/revocation_notification/v2_0/models/rev_notification_record.py index 2587863c91..17cc4dac25 100644 --- a/aries_cloudagent/protocols/revocation_notification/v2_0/models/rev_notification_record.py +++ b/aries_cloudagent/protocols/revocation_notification/v2_0/models/rev_notification_record.py @@ -39,13 +39,13 @@ class Meta: def __init__( self, *, - revocation_notification_id: str = None, - rev_reg_id: str = None, - cred_rev_id: str = None, - connection_id: str = None, - thread_id: str = None, - comment: str = None, - version: str = None, + revocation_notification_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + cred_rev_id: Optional[str] = None, + connection_id: Optional[str] = None, + thread_id: Optional[str] = None, + comment: Optional[str] = None, + version: Optional[str] = None, **kwargs, ): """Construct record.""" diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index 67b80839fa..facef0711c 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -2,7 +2,7 @@ import asyncio import logging -from typing import Sequence +from typing import Optional, Sequence from ....core.error import BaseError from ....core.profile import Profile @@ -77,7 +77,7 @@ async def get_recipient(self, recip_verkey: str) -> RouteRecord: await asyncio.sleep(RECIP_ROUTE_PAUSE) async def get_routes( - self, client_connection_id: str = None, tag_filter: dict = None + self, client_connection_id: Optional[str] = None, tag_filter: Optional[dict] = None ) -> Sequence[RouteRecord]: """Fetch all routes associated with the current connection. @@ -119,9 +119,9 @@ async def delete_route_record(self, route: RouteRecord): async def create_route_record( self, - client_connection_id: str = None, - recipient_key: str = None, - internal_wallet_id: str = None, + client_connection_id: Optional[str] = None, + recipient_key: Optional[str] = None, + internal_wallet_id: Optional[str] = None, ) -> RouteRecord: """Create and store a new RouteRecord. diff --git a/aries_cloudagent/protocols/routing/v1_0/messages/forward.py b/aries_cloudagent/protocols/routing/v1_0/messages/forward.py index 36afa7da7d..19f0bdc06d 100644 --- a/aries_cloudagent/protocols/routing/v1_0/messages/forward.py +++ b/aries_cloudagent/protocols/routing/v1_0/messages/forward.py @@ -1,7 +1,7 @@ """Represents a forward message.""" import json -from typing import Union +from typing import Optional, Union from marshmallow import EXCLUDE, fields, pre_load @@ -21,7 +21,7 @@ class Meta: message_type = FORWARD schema_class = "ForwardSchema" - def __init__(self, *, to: str = None, msg: Union[dict, str] = None, **kwargs): + def __init__(self, *, to: Optional[str] = None, msg: Union[dict, str] = None, **kwargs): """Initialize forward message object. Args: diff --git a/aries_cloudagent/protocols/routing/v1_0/models/route_record.py b/aries_cloudagent/protocols/routing/v1_0/models/route_record.py index 2adea0d1b9..0f42081107 100644 --- a/aries_cloudagent/protocols/routing/v1_0/models/route_record.py +++ b/aries_cloudagent/protocols/routing/v1_0/models/route_record.py @@ -1,4 +1,5 @@ """An object for containing information on an individual route.""" +from typing import Optional from marshmallow import EXCLUDE, ValidationError, fields, validates_schema @@ -23,11 +24,11 @@ class Meta: def __init__( self, *, - record_id: str = None, - role: str = None, - connection_id: str = None, - wallet_id: str = None, - recipient_key: str = None, + record_id: Optional[str] = None, + role: Optional[str] = None, + connection_id: Optional[str] = None, + wallet_id: Optional[str] = None, + recipient_key: Optional[str] = None, **kwargs, ): """Initialize route record. diff --git a/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py b/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py index 518b684e52..e04b1500eb 100644 --- a/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py +++ b/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py @@ -1,4 +1,5 @@ """Represents a trust ping message.""" +from typing import Optional from marshmallow import EXCLUDE, fields @@ -18,7 +19,7 @@ class Meta: message_type = PING schema_class = "PingSchema" - def __init__(self, *, response_requested: bool = True, comment: str = None, **kwargs): + def __init__(self, *, response_requested: bool = True, comment: Optional[str] = None, **kwargs): """Initialize a Ping message instance. Args: diff --git a/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py b/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py index f8e1a4b608..31e8d31f5b 100644 --- a/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py +++ b/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py @@ -1,5 +1,7 @@ """Represents an response to a trust ping message.""" +from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -18,7 +20,7 @@ class Meta: message_type = PING_RESPONSE schema_class = "PingResponseSchema" - def __init__(self, *, comment: str = None, **kwargs): + def __init__(self, *, comment: Optional[str] = None, **kwargs): """Initialize a PingResponse message instance. Args: diff --git a/aries_cloudagent/resolver/default/indy.py b/aries_cloudagent/resolver/default/indy.py index bbd2fb27bb..8d4aecf9d9 100644 --- a/aries_cloudagent/resolver/default/indy.py +++ b/aries_cloudagent/resolver/default/indy.py @@ -89,7 +89,7 @@ def add_services( self, builder: DIDDocumentBuilder, endpoints: Optional[dict], - recipient_key: VerificationMethod = None, + recipient_key: Optional[VerificationMethod] = None, service_accept: Optional[Sequence[Text]] = None, ): """Add services.""" diff --git a/aries_cloudagent/resolver/default/tests/test_universal.py b/aries_cloudagent/resolver/default/tests/test_universal.py index ab7a353d1b..f6c9979925 100644 --- a/aries_cloudagent/resolver/default/tests/test_universal.py +++ b/aries_cloudagent/resolver/default/tests/test_universal.py @@ -1,7 +1,7 @@ """Test universal resolver with http bindings.""" import re -from typing import Dict, Union +from typing import Dict, Optional, Union import pytest @@ -52,7 +52,7 @@ async def __aexit__(self, err_type, err_value, err_exc): class MockClientSession: """Mock client session.""" - def __init__(self, response: MockResponse = None): + def __init__(self, response: Optional[MockResponse] = None): self.response = response def __call__(self, headers): diff --git a/aries_cloudagent/revocation/indy.py b/aries_cloudagent/revocation/indy.py index abbfc9ea96..2f2e009f47 100644 --- a/aries_cloudagent/revocation/indy.py +++ b/aries_cloudagent/revocation/indy.py @@ -43,11 +43,11 @@ def __init__(self, profile: Profile): async def init_issuer_registry( self, cred_def_id: str, - max_cred_num: int = None, - revoc_def_type: str = None, - tag: str = None, + max_cred_num: Optional[int] = None, + revoc_def_type: Optional[str] = None, + tag: Optional[str] = None, create_pending_rev_reg: bool = False, - endorser_connection_id: str = None, + endorser_connection_id: Optional[str] = None, notify: bool = True, ) -> IssuerRevRegRecord: """Create a new revocation registry record for a credential definition.""" @@ -203,7 +203,7 @@ async def list_issuer_registries(self) -> Sequence[IssuerRevRegRecord]: return await IssuerRevRegRecord.query(session) async def get_issuer_rev_reg_delta( - self, rev_reg_id: str, timestamp_from: int = None, timestamp_to: int = None + self, rev_reg_id: str, timestamp_from: Optional[int] = None, timestamp_to: Optional[int] = None ) -> dict: """Check ledger for revocation status for a given revocation registry. diff --git a/aries_cloudagent/revocation/manager.py b/aries_cloudagent/revocation/manager.py index 00479c3c08..ed0312dd92 100644 --- a/aries_cloudagent/revocation/manager.py +++ b/aries_cloudagent/revocation/manager.py @@ -43,11 +43,11 @@ async def revoke_credential_by_cred_ex_id( cred_ex_id: str, publish: bool = False, notify: bool = False, - notify_version: str = None, - thread_id: str = None, - connection_id: str = None, - endorser_conn_id: str = None, - comment: str = None, + notify_version: Optional[str] = None, + thread_id: Optional[str] = None, + connection_id: Optional[str] = None, + endorser_conn_id: Optional[str] = None, + comment: Optional[str] = None, write_ledger: bool = True, ): """Revoke a credential by its credential exchange identifier at issue. @@ -113,11 +113,11 @@ async def revoke_credential( cred_rev_id: str, publish: bool = False, notify: bool = False, - notify_version: str = None, - thread_id: str = None, - connection_id: str = None, - endorser_conn_id: str = None, - comment: str = None, + notify_version: Optional[str] = None, + thread_id: Optional[str] = None, + connection_id: Optional[str] = None, + endorser_conn_id: Optional[str] = None, + comment: Optional[str] = None, write_ledger: bool = True, ) -> Optional[dict]: """Revoke a credential. @@ -253,7 +253,7 @@ async def publish_pending_revocations( self, rrid2crid: Mapping[Text, Sequence[Text]] = None, write_ledger: bool = True, - connection_id: str = None, + connection_id: Optional[str] = None, ) -> Tuple[Optional[dict], Mapping[Text, Sequence[Text]]]: """Publish pending revocations to the ledger. diff --git a/aries_cloudagent/revocation/models/indy.py b/aries_cloudagent/revocation/models/indy.py index 9504208468..5ce6a206cd 100644 --- a/aries_cloudagent/revocation/models/indy.py +++ b/aries_cloudagent/revocation/models/indy.py @@ -1,6 +1,7 @@ """Indy utilities for revocation.""" from time import time +from typing import Optional from marshmallow import fields @@ -16,7 +17,7 @@ class Meta: schema_class = "NonRevocationIntervalSchema" - def __init__(self, fro: int = None, to: int = None, **kwargs): + def __init__(self, fro: Optional[int] = None, to: Optional[int] = None, **kwargs): """Initialize non-revocation interval. Args: @@ -29,7 +30,7 @@ def __init__(self, fro: int = None, to: int = None, **kwargs): self.fro = fro self.to = to - def covers(self, timestamp: int = None) -> bool: + def covers(self, timestamp: Optional[int] = None) -> bool: """Whether input timestamp (default now) lies within non-revocation interval. Args: diff --git a/aries_cloudagent/revocation/models/issuer_cred_rev_record.py b/aries_cloudagent/revocation/models/issuer_cred_rev_record.py index 0932e239c8..fc4e83f85e 100644 --- a/aries_cloudagent/revocation/models/issuer_cred_rev_record.py +++ b/aries_cloudagent/revocation/models/issuer_cred_rev_record.py @@ -1,6 +1,6 @@ """Issuer credential revocation information.""" -from typing import Any, Sequence +from typing import Any, Optional, Sequence from marshmallow import fields @@ -46,13 +46,13 @@ class Meta: def __init__( self, *, - record_id: str = None, - state: str = None, - cred_ex_id: str = None, - rev_reg_id: str = None, - cred_rev_id: str = None, - cred_def_id: str = None, # Marshmallow formalism: leave None - cred_ex_version: str = None, + record_id: Optional[str] = None, + state: Optional[str] = None, + cred_ex_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + cred_rev_id: Optional[str] = None, + cred_def_id: Optional[str] = None, # Marshmallow formalism: leave None + cred_ex_version: Optional[str] = None, **kwargs, ): """Initialize a new IssuerCredRevRecord.""" @@ -73,9 +73,9 @@ async def query_by_ids( cls, session: ProfileSession, *, - cred_def_id: str = None, - rev_reg_id: str = None, - state: str = None, + cred_def_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + state: Optional[str] = None, ) -> Sequence["IssuerCredRevRecord"]: """Retrieve issuer cred rev records by cred def id and/or rev reg id. @@ -119,7 +119,7 @@ async def retrieve_by_cred_ex_id( """Retrieve an issuer cred rev record by rev reg id and cred rev id.""" return await cls.retrieve_by_tag_filter(session, {"cred_ex_id": cred_ex_id}) - async def set_state(self, session: ProfileSession, state: str = None): + async def set_state(self, session: ProfileSession, state: Optional[str] = None): """Change the issuer cred rev record state (default issued).""" self.state = state or IssuerCredRevRecord.STATE_ISSUED await self.save(session, reason=f"Marked {self.state}") diff --git a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py index c7e28774ec..c0206c044a 100644 --- a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py @@ -7,7 +7,7 @@ from os.path import join from pathlib import Path from shutil import move -from typing import Any, Mapping, Sequence, Tuple, Union +from typing import Any, Mapping, Optional, Sequence, Tuple, Union from urllib.parse import urlparse from marshmallow import fields, validate @@ -91,20 +91,20 @@ class Meta: def __init__( self, *, - record_id: str = None, - state: str = None, - cred_def_id: str = None, - error_msg: str = None, - issuer_did: str = None, - max_cred_num: int = None, - revoc_def_type: str = None, - revoc_reg_id: str = None, + record_id: Optional[str] = None, + state: Optional[str] = None, + cred_def_id: Optional[str] = None, + error_msg: Optional[str] = None, + issuer_did: Optional[str] = None, + max_cred_num: Optional[int] = None, + revoc_def_type: Optional[str] = None, + revoc_reg_id: Optional[str] = None, revoc_reg_def: Union[IndyRevRegDef, Mapping] = None, revoc_reg_entry: Union[IndyRevRegEntry, Mapping] = None, - tag: str = None, - tails_hash: str = None, - tails_local_path: str = None, - tails_public_uri: str = None, + tag: Optional[str] = None, + tails_hash: Optional[str] = None, + tails_local_path: Optional[str] = None, + tails_public_uri: Optional[str] = None, pending_pub: Sequence[str] = None, **kwargs, ): @@ -250,7 +250,7 @@ async def send_def( self, profile: Profile, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Send the revocation registry definition to the ledger.""" if not (self.revoc_reg_def and self.issuer_did): @@ -284,7 +284,7 @@ async def send_entry( self, profile: Profile, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, ) -> dict: """Send a registry entry to the ledger.""" if not ( @@ -521,8 +521,8 @@ async def query_by_cred_def_id( cls, session: ProfileSession, cred_def_id: str, - state: str = None, - negative_state: str = None, + state: Optional[str] = None, + negative_state: Optional[str] = None, limit=None, ) -> Sequence["IssuerRevRegRecord"]: """Retrieve issuer revocation registry records by credential definition ID. @@ -580,7 +580,7 @@ async def retrieve_by_revoc_reg_id( session, tag_filter, for_update=for_update ) - async def set_state(self, session: ProfileSession, state: str = None): + async def set_state(self, session: ProfileSession, state: Optional[str] = None): """Change the registry state (default full).""" self.state = state or IssuerRevRegRecord.STATE_FULL await self.save( diff --git a/aries_cloudagent/revocation/models/revocation_registry.py b/aries_cloudagent/revocation/models/revocation_registry.py index 05528c445a..f2d4e262b8 100644 --- a/aries_cloudagent/revocation/models/revocation_registry.py +++ b/aries_cloudagent/revocation/models/revocation_registry.py @@ -1,5 +1,4 @@ """Classes for managing a revocation registry.""" - import hashlib import http import logging @@ -7,6 +6,7 @@ import re from os.path import join from pathlib import Path +from typing import Optional import base58 from requests import Session @@ -26,17 +26,17 @@ class RevocationRegistry: def __init__( self, - registry_id: str = None, + registry_id: Optional[str] = None, *, - cred_def_id: str = None, - issuer_did: str = None, - max_creds: int = None, - reg_def_type: str = None, - tag: str = None, - tails_local_path: str = None, - tails_public_uri: str = None, - tails_hash: str = None, - reg_def: dict = None, + cred_def_id: Optional[str] = None, + issuer_did: Optional[str] = None, + max_creds: Optional[int] = None, + reg_def_type: Optional[str] = None, + tag: Optional[str] = None, + tails_local_path: Optional[str] = None, + tails_public_uri: Optional[str] = None, + tails_hash: Optional[str] = None, + reg_def: Optional[dict] = None, ): """Initialize the revocation registry instance.""" self._cred_def_id = cred_def_id diff --git a/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py index 9343f91801..9dc6ce1287 100644 --- a/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py @@ -1,7 +1,7 @@ import importlib import json from os.path import join -from typing import Any, Mapping, Type +from typing import Any, Mapping, Optional, Type from unittest import IsolatedAsyncioTestCase from aries_cloudagent.tests import mock @@ -120,7 +120,7 @@ async def test_fix_ledger_entry(self): } class TestProfile(InMemoryProfile): - def session(self, context: InjectionContext = None) -> "ProfileSession": + def session(self, context: Optional[InjectionContext] = None) -> "ProfileSession": return TestProfileSession(self, context=context) @classmethod @@ -159,7 +159,7 @@ def __init__( self, profile: Profile, *, - context: InjectionContext = None, + context: Optional[InjectionContext] = None, settings: Mapping[str, Any] = None, ): super().__init__(profile=profile, context=context, settings=settings) diff --git a/aries_cloudagent/revocation/util.py b/aries_cloudagent/revocation/util.py index cc8c55209e..62853d267a 100644 --- a/aries_cloudagent/revocation/util.py +++ b/aries_cloudagent/revocation/util.py @@ -1,7 +1,7 @@ """Revocation utilities.""" import re -from typing import Sequence +from typing import Optional, Sequence from ..core.profile import Profile @@ -19,7 +19,7 @@ async def notify_revocation_reg_init_event( profile: Profile, issuer_rev_id: str, create_pending_rev_reg: bool = False, - endorser_connection_id: str = None, + endorser_connection_id: Optional[str] = None, ): """Send notification for a revocation registry init event.""" meta_data = { diff --git a/aries_cloudagent/revocation_anoncreds/manager.py b/aries_cloudagent/revocation_anoncreds/manager.py index c7adfe4a49..edbdb1ab78 100644 --- a/aries_cloudagent/revocation_anoncreds/manager.py +++ b/aries_cloudagent/revocation_anoncreds/manager.py @@ -40,10 +40,10 @@ async def revoke_credential_by_cred_ex_id( cred_ex_id: str, publish: bool = False, notify: bool = False, - notify_version: str = None, - thread_id: str = None, - connection_id: str = None, - comment: str = None, + notify_version: Optional[str] = None, + thread_id: Optional[str] = None, + connection_id: Optional[str] = None, + comment: Optional[str] = None, options: Optional[dict] = None, ): """Revoke a credential by its credential exchange identifier at issue. @@ -105,10 +105,10 @@ async def revoke_credential( cred_rev_id: str, publish: bool = False, notify: bool = False, - notify_version: str = None, - thread_id: str = None, - connection_id: str = None, - comment: str = None, + notify_version: Optional[str] = None, + thread_id: Optional[str] = None, + connection_id: Optional[str] = None, + comment: Optional[str] = None, options: Optional[dict] = None, ): """Revoke a credential. diff --git a/aries_cloudagent/revocation_anoncreds/models/issuer_cred_rev_record.py b/aries_cloudagent/revocation_anoncreds/models/issuer_cred_rev_record.py index 8d8a9d0639..84a9dcc81b 100644 --- a/aries_cloudagent/revocation_anoncreds/models/issuer_cred_rev_record.py +++ b/aries_cloudagent/revocation_anoncreds/models/issuer_cred_rev_record.py @@ -1,6 +1,6 @@ """Issuer credential revocation information.""" -from typing import Any, Sequence +from typing import Any, Optional, Sequence from marshmallow import fields @@ -38,13 +38,13 @@ class Meta: def __init__( self, *, - record_id: str = None, - state: str = None, - cred_ex_id: str = None, - rev_reg_id: str = None, - cred_rev_id: str = None, - cred_def_id: str = None, # Marshmallow formalism: leave None - cred_ex_version: str = None, + record_id: Optional[str] = None, + state: Optional[str] = None, + cred_ex_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + cred_rev_id: Optional[str] = None, + cred_def_id: Optional[str] = None, # Marshmallow formalism: leave None + cred_ex_version: Optional[str] = None, **kwargs, ): """Initialize a new IssuerCredRevRecord.""" @@ -65,9 +65,9 @@ async def query_by_ids( cls, session: ProfileSession, *, - cred_def_id: str = None, - rev_reg_id: str = None, - state: str = None, + cred_def_id: Optional[str] = None, + rev_reg_id: Optional[str] = None, + state: Optional[str] = None, ) -> Sequence["IssuerCredRevRecord"]: """Retrieve issuer cred rev records by cred def id and/or rev reg id. @@ -111,7 +111,7 @@ async def retrieve_by_cred_ex_id( """Retrieve an issuer cred rev record by rev reg id and cred rev id.""" return await cls.retrieve_by_tag_filter(session, {"cred_ex_id": cred_ex_id}) - async def set_state(self, session: ProfileSession, state: str = None): + async def set_state(self, session: ProfileSession, state: Optional[str] = None): """Change the issuer cred rev record state (default issued).""" self.state = state or IssuerCredRevRecord.STATE_ISSUED await self.save(session, reason=f"Marked {self.state}") diff --git a/aries_cloudagent/storage/askar.py b/aries_cloudagent/storage/askar.py index 03061cca32..a3480c2ef6 100644 --- a/aries_cloudagent/storage/askar.py +++ b/aries_cloudagent/storage/askar.py @@ -57,7 +57,7 @@ async def add_record(self, record: StorageRecord): raise StorageError("Error when adding storage record") from err async def get_record( - self, record_type: str, record_id: str, options: Mapping = None + self, record_type: str, record_id: str, options: Optional[Mapping] = None ) -> StorageRecord: """Fetch a record from the store by type and ID. @@ -140,7 +140,7 @@ async def delete_record(self, record: StorageRecord): raise StorageError("Error when removing storage record") from err async def find_record( - self, type_filter: str, tag_query: Mapping, options: Mapping = None + self, type_filter: str, tag_query: Mapping, options: Optional[Mapping] = None ) -> StorageRecord: """Find a record using a unique tag filter. @@ -171,7 +171,7 @@ async def find_record( async def find_paginated_records( self, type_filter: str, - tag_query: Mapping = None, + tag_query: Optional[Mapping] = None, limit: int = DEFAULT_PAGE_SIZE, offset: int = 0, ) -> Sequence[StorageRecord]: @@ -205,8 +205,8 @@ async def find_paginated_records( async def find_all_records( self, type_filter: str, - tag_query: Mapping = None, - options: Mapping = None, + tag_query: Optional[Mapping] = None, + options: Optional[Mapping] = None, ): """Retrieve all records matching a particular type filter and tag query.""" for_update = bool(options and options.get("forUpdate")) @@ -227,7 +227,7 @@ async def find_all_records( async def delete_all_records( self, type_filter: str, - tag_query: Mapping = None, + tag_query: Optional[Mapping] = None, ): """Remove all records matching a particular type filter and tag query.""" await self._session.handle.remove_all(type_filter, tag_query) @@ -247,9 +247,9 @@ def __init__(self, profile: AskarProfile): def search_records( self, type_filter: str, - tag_query: Mapping = None, - page_size: int = None, - options: Mapping = None, + tag_query: Optional[Mapping] = None, + page_size: Optional[int] = None, + options: Optional[Mapping] = None, ) -> "AskarStorageSearchSession": """Search stored records. @@ -276,8 +276,8 @@ def __init__( profile: AskarProfile, type_filter: str, tag_query: Mapping, - page_size: int = None, - options: Mapping = None, + page_size: Optional[int] = None, + options: Optional[Mapping] = None, ): """Initialize a `AskarStorageSearchSession` instance. diff --git a/aries_cloudagent/storage/base.py b/aries_cloudagent/storage/base.py index 2035e071e0..bc9c61f319 100644 --- a/aries_cloudagent/storage/base.py +++ b/aries_cloudagent/storage/base.py @@ -1,7 +1,6 @@ """Abstract base classes for non-secrets storage.""" - from abc import ABC, abstractmethod -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from .error import StorageDuplicateError, StorageError, StorageNotFoundError from .record import StorageRecord @@ -36,7 +35,7 @@ async def add_record(self, record: StorageRecord): @abstractmethod async def get_record( - self, record_type: str, record_id: str, options: Mapping = None + self, record_type: str, record_id: str, options: Optional[Mapping] = None ) -> StorageRecord: """Fetch a record from the store by type and ID. @@ -71,7 +70,7 @@ async def delete_record(self, record: StorageRecord): """ async def find_record( - self, type_filter: str, tag_query: Mapping = None, options: Mapping = None + self, type_filter: str, tag_query: Optional[Mapping] = None, options: Optional[Mapping] = None ) -> StorageRecord: """Find a record using a unique tag filter. @@ -93,7 +92,7 @@ async def find_record( async def find_paginated_records( self, type_filter: str, - tag_query: Mapping = None, + tag_query: Optional[Mapping] = None, limit: int = DEFAULT_PAGE_SIZE, offset: int = 0, ) -> Sequence[StorageRecord]: @@ -110,8 +109,8 @@ async def find_paginated_records( async def find_all_records( self, type_filter: str, - tag_query: Mapping = None, - options: Mapping = None, + tag_query: Optional[Mapping] = None, + options: Optional[Mapping] = None, ) -> Sequence[StorageRecord]: """Retrieve all records matching a particular type filter and tag query. @@ -125,7 +124,7 @@ async def find_all_records( async def delete_all_records( self, type_filter: str, - tag_query: Mapping = None, + tag_query: Optional[Mapping] = None, ) -> None: """Remove all records matching a particular type filter and tag query. @@ -142,9 +141,9 @@ class BaseStorageSearch(ABC): def search_records( self, type_filter: str, - tag_query: Mapping = None, - page_size: int = None, - options: Mapping = None, + tag_query: Optional[Mapping] = None, + page_size: Optional[int] = None, + options: Optional[Mapping] = None, ) -> "BaseStorageSearchSession": """Create a new record query. @@ -168,7 +167,7 @@ class BaseStorageSearchSession(ABC): """Abstract stored records search session interface.""" @abstractmethod - async def fetch(self, max_count: int = None) -> Sequence[StorageRecord]: + async def fetch(self, max_count: Optional[int] = None) -> Sequence[StorageRecord]: """Fetch the next list of results from the store. Args: @@ -195,7 +194,7 @@ def __repr__(self) -> str: class IterSearch: """A generic record search async iterator.""" - def __init__(self, search: BaseStorageSearchSession, page_size: int = None): + def __init__(self, search: BaseStorageSearchSession, page_size: Optional[int] = None): """Instantiate a new `IterSearch` instance.""" self._buffer = None self._page_size = page_size diff --git a/aries_cloudagent/storage/in_memory.py b/aries_cloudagent/storage/in_memory.py index f8d1f8f844..198cc6bc24 100644 --- a/aries_cloudagent/storage/in_memory.py +++ b/aries_cloudagent/storage/in_memory.py @@ -1,6 +1,5 @@ """Basic in-memory storage implementation (non-wallet).""" - -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from ..core.in_memory import InMemoryProfile from .base import ( @@ -43,7 +42,7 @@ async def add_record(self, record: StorageRecord): self.profile.records[record.id] = record async def get_record( - self, record_type: str, record_id: str, options: Mapping = None + self, record_type: str, record_id: str, options: Optional[Mapping] = None ) -> StorageRecord: """Fetch a record from the store by type and ID. @@ -100,7 +99,7 @@ async def delete_record(self, record: StorageRecord): async def find_paginated_records( self, type_filter: str, - tag_query: Mapping = None, + tag_query: Optional[Mapping] = None, limit: int = DEFAULT_PAGE_SIZE, offset: int = 0, ) -> Sequence[StorageRecord]: @@ -130,8 +129,8 @@ async def find_paginated_records( async def find_all_records( self, type_filter: str, - tag_query: Mapping = None, - options: Mapping = None, + tag_query: Optional[Mapping] = None, + options: Optional[Mapping] = None, ): """Retrieve all records matching a particular type filter and tag query.""" results = [] @@ -143,7 +142,7 @@ async def find_all_records( async def delete_all_records( self, type_filter: str, - tag_query: Mapping = None, + tag_query: Optional[Mapping] = None, ): """Remove all records matching a particular type filter and tag query.""" ids = [] @@ -156,9 +155,9 @@ async def delete_all_records( def search_records( self, type_filter: str, - tag_query: Mapping = None, - page_size: int = None, - options: Mapping = None, + tag_query: Optional[Mapping] = None, + page_size: Optional[int] = None, + options: Optional[Mapping] = None, ) -> "InMemoryStorageSearch": """Search stored records. @@ -262,8 +261,8 @@ def __init__( profile: InMemoryProfile, type_filter: str, tag_query: Mapping, - page_size: int = None, - options: Mapping = None, + page_size: Optional[int] = None, + options: Optional[Mapping] = None, ): """Initialize a `InMemoryStorageSearch` instance. @@ -282,7 +281,7 @@ def __init__( self.type_filter = type_filter self._done = False - async def fetch(self, max_count: int = None) -> Sequence[StorageRecord]: + async def fetch(self, max_count: Optional[int] = None) -> Sequence[StorageRecord]: """Fetch the next list of results from the store. Args: diff --git a/aries_cloudagent/storage/vc_holder/askar.py b/aries_cloudagent/storage/vc_holder/askar.py index d19bebe7fb..bf4874a65f 100644 --- a/aries_cloudagent/storage/vc_holder/askar.py +++ b/aries_cloudagent/storage/vc_holder/askar.py @@ -1,7 +1,7 @@ """Askar storage implementation of VC holder interface.""" import json -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from dateutil.parser import ParserError from dateutil.parser import parse as dateutil_parser @@ -88,11 +88,11 @@ def search_credentials( contexts: Sequence[str] = None, types: Sequence[str] = None, schema_ids: Sequence[str] = None, - issuer_id: str = None, - subject_ids: str = None, + issuer_id: Optional[str] = None, + subject_ids: Optional[str] = None, proof_types: Sequence[str] = None, - given_id: str = None, - tag_query: Mapping = None, + given_id: Optional[str] = None, + tag_query: Optional[Mapping] = None, pd_uri_list: Sequence[str] = None, ) -> "VCRecordSearch": """Start a new VC record search. @@ -161,7 +161,7 @@ async def close(self): """Dispose of the search query.""" await self._search.close() - async def fetch(self, max_count: int = None) -> Sequence[VCRecord]: + async def fetch(self, max_count: Optional[int] = None) -> Sequence[VCRecord]: """Fetch the next list of VC records from the store. Args: diff --git a/aries_cloudagent/storage/vc_holder/base.py b/aries_cloudagent/storage/vc_holder/base.py index df3a7138c9..5475de5738 100644 --- a/aries_cloudagent/storage/vc_holder/base.py +++ b/aries_cloudagent/storage/vc_holder/base.py @@ -1,7 +1,7 @@ """Abstract interfaces for VC holder implementations.""" from abc import ABC, abstractmethod -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from .vc_record import VCRecord @@ -61,11 +61,11 @@ def search_credentials( contexts: Sequence[str] = None, types: Sequence[str] = None, schema_ids: Sequence[str] = None, - issuer_id: str = None, + issuer_id: Optional[str] = None, subject_ids: Sequence[str] = None, proof_types: Sequence[str] = None, - given_id: str = None, - tag_query: Mapping = None, + given_id: Optional[str] = None, + tag_query: Optional[Mapping] = None, ) -> "VCRecordSearch": """Start a new VC record search. @@ -95,7 +95,7 @@ class VCRecordSearch(ABC): """A VC record search in progress.""" @abstractmethod - async def fetch(self, max_count: int = None) -> Sequence[VCRecord]: + async def fetch(self, max_count: Optional[int] = None) -> Sequence[VCRecord]: """Fetch the next list of VC records from the store. Args: @@ -122,7 +122,7 @@ def __repr__(self) -> str: class IterVCRecordSearch: """A generic record search async iterator.""" - def __init__(self, search: VCRecordSearch, page_size: int = None): + def __init__(self, search: VCRecordSearch, page_size: Optional[int] = None): """Instantiate a new `IterVCRecordSearch` instance.""" self._buffer = None self._page_size = page_size diff --git a/aries_cloudagent/storage/vc_holder/in_memory.py b/aries_cloudagent/storage/vc_holder/in_memory.py index 66e5a05df0..27bad21520 100644 --- a/aries_cloudagent/storage/vc_holder/in_memory.py +++ b/aries_cloudagent/storage/vc_holder/in_memory.py @@ -1,6 +1,5 @@ """Basic in-memory storage implementation of VC holder interface.""" - -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from dateutil.parser import ParserError from dateutil.parser import parse as dateutil_parser @@ -77,12 +76,12 @@ def search_credentials( self, contexts: Sequence[str] = None, types: Sequence[str] = None, - schema_ids: str = None, - issuer_id: str = None, - subject_ids: str = None, + schema_ids: Optional[str] = None, + issuer_id: Optional[str] = None, + subject_ids: Optional[str] = None, proof_types: Sequence[str] = None, - given_id: str = None, - tag_query: Mapping = None, + given_id: Optional[str] = None, + tag_query: Optional[Mapping] = None, pd_uri_list: Sequence[str] = None, ) -> "VCRecordSearch": """Start a new VC record search. @@ -144,7 +143,7 @@ def __init__(self, search: InMemoryStorageSearch): """Initialize the in-memory VC record search.""" self._search = search - async def fetch(self, max_count: int = None) -> Sequence[VCRecord]: + async def fetch(self, max_count: Optional[int] = None) -> Sequence[VCRecord]: """Fetch the next list of VC records from the store. Args: diff --git a/aries_cloudagent/storage/vc_holder/vc_record.py b/aries_cloudagent/storage/vc_holder/vc_record.py index 327a7ee3c2..4d091bac5a 100644 --- a/aries_cloudagent/storage/vc_holder/vc_record.py +++ b/aries_cloudagent/storage/vc_holder/vc_record.py @@ -1,7 +1,7 @@ """Model for representing a stored verifiable credential.""" import logging -from typing import Mapping, Sequence +from typing import Mapping, Optional, Sequence from marshmallow import EXCLUDE, fields from uuid_utils import uuid4 @@ -30,9 +30,9 @@ def __init__( schema_ids: Sequence[str], # one or more credential schema IDs may be present proof_types: Sequence[str], # one or more proof types may be present cred_value: Mapping, # the credential value as a JSON-serializable mapping - given_id: str = None, # value of the credential 'id' property, if any - cred_tags: Mapping = None, # tags for retrieval (derived from attribute values) - record_id: str = None, # specify the storage record ID + given_id: Optional[str] = None, # value of the credential 'id' property, if any + cred_tags: Optional[Mapping] = None, # tags for retrieval (derived from attribute values) + record_id: Optional[str] = None, # specify the storage record ID ): """Initialize some defaults on record.""" super().__init__() diff --git a/aries_cloudagent/transport/inbound/base.py b/aries_cloudagent/transport/inbound/base.py index 012ec0be45..c41aac5102 100644 --- a/aries_cloudagent/transport/inbound/base.py +++ b/aries_cloudagent/transport/inbound/base.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod from collections import namedtuple -from typing import Awaitable, Callable +from typing import Awaitable, Callable, Optional from ...core.profile import Profile from ..error import TransportError @@ -20,8 +20,8 @@ def __init__( *, max_message_size: int = 0, is_external: bool = False, - wire_format: BaseWireFormat = None, - root_profile: Profile = None, + wire_format: Optional[BaseWireFormat] = None, + root_profile: Optional[Profile] = None, ): """Initialize the inbound transport instance. @@ -64,8 +64,8 @@ def create_session( *, accept_undelivered: bool = False, can_respond: bool = False, - client_info: dict = None, - wire_format: BaseWireFormat = None, + client_info: Optional[dict] = None, + wire_format: Optional[BaseWireFormat] = None, ) -> Awaitable[InboundSession]: """Create a new inbound session. diff --git a/aries_cloudagent/transport/inbound/manager.py b/aries_cloudagent/transport/inbound/manager.py index 74400e6714..eca52ef9dd 100644 --- a/aries_cloudagent/transport/inbound/manager.py +++ b/aries_cloudagent/transport/inbound/manager.py @@ -1,8 +1,7 @@ """Inbound transport manager.""" - import logging from collections import OrderedDict -from typing import Callable, Coroutine +from typing import Callable, Coroutine, Optional from uuid_utils import uuid4 @@ -31,7 +30,7 @@ def __init__( self, profile: Profile, receive_inbound: Coroutine, - return_inbound: Callable = None, + return_inbound: Optional[Callable] = None, ): """Initialize an `InboundTransportManager` instance.""" self.profile = profile @@ -42,7 +41,7 @@ def __init__( self.running_transports = {} self.sessions = OrderedDict() self.task_queue = TaskQueue() - self.undelivered_queue: DeliveryQueue = None + self.undelivered_queue: Optional[DeliveryQueue] = None async def setup(self): """Perform setup operations.""" @@ -142,8 +141,8 @@ async def create_session( *, accept_undelivered: bool = False, can_respond: bool = False, - client_info: dict = None, - wire_format: BaseWireFormat = None, + client_info: Optional[dict] = None, + wire_format: Optional[BaseWireFormat] = None, ): """Create a new inbound session. diff --git a/aries_cloudagent/transport/inbound/message.py b/aries_cloudagent/transport/inbound/message.py index 2def0e1d92..4560d3d39a 100644 --- a/aries_cloudagent/transport/inbound/message.py +++ b/aries_cloudagent/transport/inbound/message.py @@ -1,7 +1,7 @@ """Classes representing inbound messages.""" import asyncio -from typing import Union +from typing import Optional, Union from .receipt import MessageReceipt @@ -14,9 +14,9 @@ def __init__( payload: Union[str, bytes], receipt: MessageReceipt, *, - connection_id: str = None, - session_id: str = None, - transport_type: str = None, + connection_id: Optional[str] = None, + session_id: Optional[str] = None, + transport_type: Optional[str] = None, ): """Initialize the inbound message.""" self.connection_id = connection_id diff --git a/aries_cloudagent/transport/inbound/receipt.py b/aries_cloudagent/transport/inbound/receipt.py index 5c68d43386..302e10efa1 100644 --- a/aries_cloudagent/transport/inbound/receipt.py +++ b/aries_cloudagent/transport/inbound/receipt.py @@ -18,18 +18,18 @@ class MessageReceipt: def __init__( self, *, - connection_id: str = None, - direct_response_mode: str = None, - in_time: datetime = None, - raw_message: str = None, - recipient_verkey: str = None, - recipient_did: str = None, - recipient_did_public: bool = None, - sender_did: str = None, - sender_verkey: str = None, - thread_id: str = None, - parent_thread_id: str = None, - didcomm_version: DIDCommVersion = None, + connection_id: Optional[str] = None, + direct_response_mode: Optional[str] = None, + in_time: Optional[datetime] = None, + raw_message: Optional[str] = None, + recipient_verkey: Optional[str] = None, + recipient_did: Optional[str] = None, + recipient_did_public: Optional[bool] = None, + sender_did: Optional[str] = None, + sender_verkey: Optional[str] = None, + thread_id: Optional[str] = None, + parent_thread_id: Optional[str] = None, + didcomm_version: Optional[DIDCommVersion] = None, ): """Initialize the message delivery instance.""" self._connection_id = connection_id diff --git a/aries_cloudagent/transport/inbound/session.py b/aries_cloudagent/transport/inbound/session.py index dee7441981..866f48df1f 100644 --- a/aries_cloudagent/transport/inbound/session.py +++ b/aries_cloudagent/transport/inbound/session.py @@ -2,7 +2,7 @@ import asyncio import logging -from typing import Callable, Sequence, Union +from typing import Callable, Optional, Sequence, Union from ...admin.server import AdminResponder from ...core.profile import Profile @@ -42,12 +42,12 @@ def __init__( wire_format: BaseWireFormat, accept_undelivered: bool = False, can_respond: bool = False, - client_info: dict = None, - close_handler: Callable = None, - reply_mode: str = None, + client_info: Optional[dict] = None, + close_handler: Optional[Callable] = None, + reply_mode: Optional[str] = None, reply_thread_ids: Sequence[str] = None, reply_verkeys: Sequence[str] = None, - transport_type: str = None, + transport_type: Optional[str] = None, ): """Initialize the inbound session.""" self.profile = profile @@ -58,7 +58,7 @@ def __init__( self.accept_undelivered = accept_undelivered self.client_info = client_info self.close_handler = close_handler - self.response_buffer: OutboundMessage = None + self.response_buffer: Optional[OutboundMessage] = None self.response_event = asyncio.Event() self.transport_type = transport_type diff --git a/aries_cloudagent/transport/outbound/base.py b/aries_cloudagent/transport/outbound/base.py index 0a1c50ffec..3aeec7c0dc 100644 --- a/aries_cloudagent/transport/outbound/base.py +++ b/aries_cloudagent/transport/outbound/base.py @@ -1,8 +1,7 @@ """Base outbound transport.""" - import asyncio from abc import ABC, abstractmethod -from typing import Union +from typing import Optional, Union from ...connections.models.connection_target import ConnectionTarget from ...core.profile import Profile @@ -32,17 +31,17 @@ def __init__( """Initialize the queued outbound message.""" self.profile = profile self.endpoint = target and target.endpoint - self.error: Exception = None + self.error: Optional[Exception] = None self.message = message self.payload: Union[str, bytes] = None self.retries = None - self.retry_at: float = None + self.retry_at: Optional[float] = None self.state = self.STATE_NEW self.target = target self.task: asyncio.Task = None self.transport_id: str = transport_id - self.metadata: dict = None - self.api_key: str = None + self.metadata: Optional[dict] = None + self.api_key: Optional[str] = None class BaseOutboundTransport(ABC): @@ -50,8 +49,8 @@ class BaseOutboundTransport(ABC): def __init__( self, - wire_format: BaseWireFormat = None, - root_profile: Profile = None, + wire_format: Optional[BaseWireFormat] = None, + root_profile: Optional[Profile] = None, ) -> None: """Initialize a `BaseOutboundTransport` instance.""" self._collector = None @@ -102,7 +101,7 @@ async def handle_message( profile: Profile, outbound_message: QueuedOutboundMessage, endpoint: str, - metadata: dict = None, + metadata: Optional[dict] = None, ): """Handle message. diff --git a/aries_cloudagent/transport/outbound/http.py b/aries_cloudagent/transport/outbound/http.py index 60d9bb8896..53b9b58429 100644 --- a/aries_cloudagent/transport/outbound/http.py +++ b/aries_cloudagent/transport/outbound/http.py @@ -1,7 +1,7 @@ """Http outbound transport.""" import logging -from typing import Union +from typing import Optional, Union from aiohttp import ClientSession, DummyCookieJar, TCPConnector @@ -20,8 +20,8 @@ class HttpTransport(BaseOutboundTransport): def __init__(self, **kwargs) -> None: """Initialize an `HttpTransport` instance.""" super().__init__(**kwargs) - self.client_session: ClientSession = None - self.connector: TCPConnector = None + self.client_session: Optional[ClientSession] = None + self.connector: Optional[TCPConnector] = None self.logger = logging.getLogger(__name__) async def start(self): @@ -49,8 +49,8 @@ async def handle_message( profile: Profile, payload: Union[str, bytes], endpoint: str, - metadata: dict = None, - api_key: str = None, + metadata: Optional[dict] = None, + api_key: Optional[str] = None, ): """Handle message from queue. diff --git a/aries_cloudagent/transport/outbound/manager.py b/aries_cloudagent/transport/outbound/manager.py index 0ee1258b74..075e340843 100644 --- a/aries_cloudagent/transport/outbound/manager.py +++ b/aries_cloudagent/transport/outbound/manager.py @@ -4,7 +4,7 @@ import json import logging import time -from typing import Callable, Type +from typing import Callable, Optional, Type from urllib.parse import urlparse from ...connections.models.connection_target import ConnectionTarget @@ -31,7 +31,7 @@ class OutboundTransportManager: MAX_RETRY_COUNT = 4 - def __init__(self, profile: Profile, handle_not_delivered: Callable = None): + def __init__(self, profile: Profile, handle_not_delivered: Optional[Callable] = None): """Initialize a `OutboundTransportManager` instance. Args: @@ -96,7 +96,7 @@ def register(self, module_name: str) -> str: return self.register_class(imported_class) def register_class( - self, transport_class: Type[BaseOutboundTransport], transport_id: str = None + self, transport_class: Type[BaseOutboundTransport], transport_id: Optional[str] = None ) -> str: """Register a new outbound transport class. @@ -276,8 +276,8 @@ def enqueue_webhook( topic: str, payload: dict, endpoint: str, - max_attempts: int = None, - metadata: dict = None, + max_attempts: Optional[int] = None, + metadata: Optional[dict] = None, ): """Add a webhook to the queue. @@ -431,7 +431,7 @@ def encode_queued_message(self, queued: QueuedOutboundMessage) -> asyncio.Task: return queued.task async def perform_encode( - self, queued: QueuedOutboundMessage, wire_format: BaseWireFormat = None + self, queued: QueuedOutboundMessage, wire_format: Optional[BaseWireFormat] = None ): """Perform message encoding.""" wire_format = wire_format or self.root_profile.inject(BaseWireFormat) diff --git a/aries_cloudagent/transport/outbound/message.py b/aries_cloudagent/transport/outbound/message.py index 1f9ed54655..e62f9f4728 100644 --- a/aries_cloudagent/transport/outbound/message.py +++ b/aries_cloudagent/transport/outbound/message.py @@ -1,6 +1,6 @@ """Outbound message representation.""" -from typing import Sequence, Union +from typing import Optional, Sequence, Union from ...connections.models.connection_target import ConnectionTarget @@ -11,15 +11,15 @@ class OutboundMessage: def __init__( self, *, - connection_id: str = None, + connection_id: Optional[str] = None, enc_payload: Union[str, bytes] = None, - endpoint: str = None, + endpoint: Optional[str] = None, payload: Union[str, bytes], - reply_session_id: str = None, - reply_thread_id: str = None, - reply_to_verkey: str = None, - reply_from_verkey: str = None, - target: ConnectionTarget = None, + reply_session_id: Optional[str] = None, + reply_thread_id: Optional[str] = None, + reply_to_verkey: Optional[str] = None, + reply_from_verkey: Optional[str] = None, + target: Optional[ConnectionTarget] = None, target_list: Sequence[ConnectionTarget] = None, to_session_only: bool = False, ): diff --git a/aries_cloudagent/transport/outbound/ws.py b/aries_cloudagent/transport/outbound/ws.py index e3a7c25576..0a21a56517 100644 --- a/aries_cloudagent/transport/outbound/ws.py +++ b/aries_cloudagent/transport/outbound/ws.py @@ -1,7 +1,7 @@ """Websockets outbound transport.""" import logging -from typing import Union +from typing import Optional, Union from aiohttp import ClientSession, DummyCookieJar @@ -35,8 +35,8 @@ async def handle_message( profile: Profile, payload: Union[str, bytes], endpoint: str, - metadata: dict = None, - api_key: str = None, + metadata: Optional[dict] = None, + api_key: Optional[str] = None, ): """Handle message from queue. diff --git a/aries_cloudagent/transport/queue/base.py b/aries_cloudagent/transport/queue/base.py index da0978e843..312f1720e7 100644 --- a/aries_cloudagent/transport/queue/base.py +++ b/aries_cloudagent/transport/queue/base.py @@ -2,6 +2,7 @@ import asyncio from abc import ABC, abstractmethod +from typing import Optional class BaseMessageQueue(ABC): @@ -20,7 +21,7 @@ async def enqueue(self, message): """ @abstractmethod - async def dequeue(self, *, timeout: int = None): + async def dequeue(self, *, timeout: Optional[int] = None): """Dequeue a message. Returns: diff --git a/aries_cloudagent/transport/queue/basic.py b/aries_cloudagent/transport/queue/basic.py index a00a60d7c3..31c22fdacc 100644 --- a/aries_cloudagent/transport/queue/basic.py +++ b/aries_cloudagent/transport/queue/basic.py @@ -2,6 +2,7 @@ import asyncio import logging +from typing import Optional from .base import BaseMessageQueue @@ -36,7 +37,7 @@ async def enqueue(self, message): self.logger.debug(f"Queue size after enqueue is: {self.queue.qsize()}") await self.queue.put(message) - async def dequeue(self, *, timeout: int = None): + async def dequeue(self, *, timeout: Optional[int] = None): """Dequeue a message. Returns: diff --git a/aries_cloudagent/utils/classloader.py b/aries_cloudagent/utils/classloader.py index 3d437fa417..9f3fd63ef5 100644 --- a/aries_cloudagent/utils/classloader.py +++ b/aries_cloudagent/utils/classloader.py @@ -22,7 +22,7 @@ class ClassLoader: """Class used to load classes from modules dynamically.""" @classmethod - def load_module(cls, mod_path: str, package: str = None) -> ModuleType: + def load_module(cls, mod_path: str, package: Optional[str] = None) -> ModuleType: """Load a module by its absolute path. Args: @@ -117,7 +117,7 @@ def load_class( return resolved @classmethod - def load_subclass_of(cls, base_class: Type, mod_path: str, package: str = None): + def load_subclass_of(cls, base_class: Type, mod_path: str, package: Optional[str] = None): """Resolve an implementation of a base path within a module. Args: diff --git a/aries_cloudagent/utils/http.py b/aries_cloudagent/utils/http.py index 9f45ccb411..885260ddab 100644 --- a/aries_cloudagent/utils/http.py +++ b/aries_cloudagent/utils/http.py @@ -3,6 +3,7 @@ import asyncio import logging import urllib.parse +from typing import Optional from aiohttp import BaseConnector, ClientError, ClientResponse, ClientSession, FormData from aiohttp.web import HTTPConflict @@ -24,14 +25,14 @@ class PutError(BaseError): async def fetch_stream( url: str, *, - headers: dict = None, + headers: Optional[dict] = None, retry: bool = True, max_attempts: int = 5, interval: float = 1.0, backoff: float = 0.25, request_timeout: float = 10.0, - connector: BaseConnector = None, - session: ClientSession = None, + connector: Optional[BaseConnector] = None, + session: Optional[ClientSession] = None, ): """Fetch from an HTTP server with automatic retries and timeouts. @@ -72,14 +73,14 @@ async def fetch_stream( async def fetch( url: str, *, - headers: dict = None, + headers: Optional[dict] = None, retry: bool = True, max_attempts: int = 5, interval: float = 1.0, backoff: float = 0.25, request_timeout: float = 10.0, - connector: BaseConnector = None, - session: ClientSession = None, + connector: Optional[BaseConnector] = None, + session: Optional[ClientSession] = None, json: bool = False, ): """Fetch from an HTTP server with automatic retries and timeouts. @@ -128,8 +129,8 @@ async def put_file( interval: float = 1.0, backoff: float = 0.25, request_timeout: float = 10.0, - connector: BaseConnector = None, - session: ClientSession = None, + connector: Optional[BaseConnector] = None, + session: Optional[ClientSession] = None, json: bool = False, ): """Put to HTTP server with automatic retries and timeouts. diff --git a/aries_cloudagent/utils/jwe.py b/aries_cloudagent/utils/jwe.py index 075d9012e1..e3a3099ea1 100644 --- a/aries_cloudagent/utils/jwe.py +++ b/aries_cloudagent/utils/jwe.py @@ -70,7 +70,7 @@ class JweRecipientSchema(Schema): class JweRecipient: """A single message recipient.""" - def __init__(self, *, encrypted_key: bytes, header: dict = None) -> "JweRecipient": + def __init__(self, *, encrypted_key: bytes, header: Optional[dict] = None) -> "JweRecipient": """Initialize the JWE recipient.""" self.encrypted_key = encrypted_key self.header = header or {} @@ -95,13 +95,13 @@ class JweEnvelope: def __init__( self, *, - protected: dict = None, - protected_b64: bytes = None, - unprotected: dict = None, - ciphertext: bytes = None, - iv: bytes = None, - tag: bytes = None, - aad: bytes = None, + protected: Optional[dict] = None, + protected_b64: Optional[bytes] = None, + unprotected: Optional[dict] = None, + ciphertext: Optional[bytes] = None, + iv: Optional[bytes] = None, + tag: Optional[bytes] = None, + aad: Optional[bytes] = None, with_protected_recipients: bool = False, with_flatten_recipients: bool = True, ): @@ -262,7 +262,7 @@ def protected_bytes(self) -> bytes: self.protected_b64.encode("utf-8") if self.protected_b64 is not None else None ) - def set_payload(self, ciphertext: bytes, iv: bytes, tag: bytes, aad: bytes = None): + def set_payload(self, ciphertext: bytes, iv: bytes, tag: bytes, aad: Optional[bytes] = None): """Set the payload of the JWE envelope.""" self.ciphertext = ciphertext self.iv = iv diff --git a/aries_cloudagent/utils/repeat.py b/aries_cloudagent/utils/repeat.py index b13d73fb6e..fd10a29802 100644 --- a/aries_cloudagent/utils/repeat.py +++ b/aries_cloudagent/utils/repeat.py @@ -1,6 +1,7 @@ """Utils for repeating tasks.""" import asyncio +from typing import Optional import async_timeout @@ -44,7 +45,7 @@ def next_interval(self) -> float: """Calculate the interval before the next attempt.""" return self.seq.next_interval(self.index) - def timeout(self, interval: float = None): + def timeout(self, interval: Optional[float] = None): """Create a context manager for timing out an attempt.""" return async_timeout.timeout(self.next_interval if interval is None else interval) diff --git a/aries_cloudagent/utils/stats.py b/aries_cloudagent/utils/stats.py index 45a18f2019..976d66a834 100644 --- a/aries_cloudagent/utils/stats.py +++ b/aries_cloudagent/utils/stats.py @@ -3,7 +3,7 @@ import functools import inspect import time -from typing import Sequence, TextIO, Union +from typing import Optional, Sequence, TextIO, Union class Stats: @@ -95,10 +95,10 @@ def __exit__(self, type, value, tb): class Collector: """Collector for a set of statistics.""" - def __init__(self, *, enabled: bool = True, log_path: str = None): + def __init__(self, *, enabled: bool = True, log_path: Optional[str] = None): """Initialize the Collector instance.""" self._enabled = enabled - self._log_file: TextIO = None + self._log_file: Optional[TextIO] = None self._log_path = log_path self._stats = None self.reset() @@ -122,7 +122,7 @@ def enabled(self, val: bool): """Setter for the collector's enabled property.""" self._enabled = val - def log(self, name: str, duration: float, start: float = None): + def log(self, name: str, duration: float, start: Optional[float] = None): """Log an entry in the statistics if the collector is enabled.""" if self._enabled: self._stats.log(name, duration) diff --git a/aries_cloudagent/utils/task_queue.py b/aries_cloudagent/utils/task_queue.py index 1f6f225a96..226040e17e 100644 --- a/aries_cloudagent/utils/task_queue.py +++ b/aries_cloudagent/utils/task_queue.py @@ -1,9 +1,8 @@ """Classes for managing a set of asyncio tasks.""" - import asyncio import logging import time -from typing import Callable, Coroutine, Tuple +from typing import Callable, Coroutine, Optional, Tuple LOGGER = logging.getLogger(__name__) @@ -41,8 +40,8 @@ def __init__( self, task: asyncio.Task, exc_info: Tuple, - ident: str = None, - timing: dict = None, + ident: Optional[str] = None, + timing: Optional[dict] = None, ): """Initialize the completed task.""" self.exc_info = exc_info @@ -61,10 +60,10 @@ class PendingTask: def __init__( self, coro: Coroutine, - complete_hook: Callable = None, - ident: str = None, + complete_hook: Optional[Callable] = None, + ident: Optional[str] = None, task_future: asyncio.Future = None, - queued_time: float = None, + queued_time: Optional[float] = None, ): """Initialize the pending task. @@ -81,7 +80,7 @@ def __init__( self.complete_hook = complete_hook self.coro = coro self.queued_time: float = queued_time - self.unqueued_time: float = None + self.unqueued_time: Optional[float] = None self.ident = ident or coro_ident(coro) self.task_future = task_future or asyncio.get_event_loop().create_future() @@ -124,7 +123,7 @@ class TaskQueue: """A class for managing a set of asyncio tasks.""" def __init__( - self, max_active: int = 0, timed: bool = False, trace_fn: Callable = None + self, max_active: int = 0, timed: bool = False, trace_fn: Optional[Callable] = None ): """Initialize the task queue. @@ -253,9 +252,9 @@ def add_pending(self, pending: PendingTask): def add_active( self, task: asyncio.Task, - task_complete: Callable = None, - ident: str = None, - timing: dict = None, + task_complete: Optional[Callable] = None, + ident: Optional[str] = None, + timing: Optional[dict] = None, ) -> asyncio.Task: """Register an active async task with an optional completion callback. @@ -275,9 +274,9 @@ def add_active( def run( self, coro: Coroutine, - task_complete: Callable = None, - ident: str = None, - timing: dict = None, + task_complete: Optional[Callable] = None, + ident: Optional[str] = None, + timing: Optional[dict] = None, ) -> asyncio.Task: """Start executing a coroutine as an async task, bypassing the pending queue. @@ -304,7 +303,7 @@ def run( return self.add_active(task, task_complete, ident, timing) def put( - self, coro: Coroutine, task_complete: Callable = None, ident: str = None + self, coro: Coroutine, task_complete: Optional[Callable] = None, ident: Optional[str] = None ) -> PendingTask: """Add a new task to the queue, delaying execution if busy. @@ -330,7 +329,7 @@ def completed_task( task: asyncio.Task, task_complete: Callable, ident: str, - timing: dict = None, + timing: Optional[dict] = None, ): """Clean up after a task has completed and run callbacks.""" exc_info = task_exc_info(task) @@ -372,7 +371,7 @@ def cancel(self): if not task.done(): task.cancel() - async def complete(self, timeout: float = None, cleanup: bool = True): + async def complete(self, timeout: Optional[float] = None, cleanup: bool = True): """Cancel any pending tasks and wait for, or cancel active tasks.""" self._cancelled = True self.cancel_pending() diff --git a/aries_cloudagent/utils/tracing.py b/aries_cloudagent/utils/tracing.py index c3ce84e0a4..f6e59c7da3 100644 --- a/aries_cloudagent/utils/tracing.py +++ b/aries_cloudagent/utils/tracing.py @@ -4,6 +4,7 @@ import json import logging import time +from typing import Optional import requests from marshmallow import fields @@ -111,9 +112,9 @@ def decode_inbound_message(message): def trace_event( context, message, - handler: str = None, - outcome: str = None, - perf_counter: float = None, + handler: Optional[str] = None, + outcome: Optional[str] = None, + perf_counter: Optional[float] = None, force_trace: bool = False, raise_errors: bool = False, ) -> float: diff --git a/aries_cloudagent/vc/ld_proofs/check.py b/aries_cloudagent/vc/ld_proofs/check.py index dfb9f3c70b..e928122d93 100644 --- a/aries_cloudagent/vc/ld_proofs/check.py +++ b/aries_cloudagent/vc/ld_proofs/check.py @@ -1,6 +1,6 @@ """Validator methods to check for properties without a context.""" -from typing import Sequence, Tuple, Union +from typing import Optional, Sequence, Tuple, Union from pyld import jsonld @@ -10,7 +10,7 @@ def diff_dict_keys( full: dict, with_missing: dict, - prefix: str = None, + prefix: Optional[str] = None, *, document_loader: DocumentLoaderMethod, context, diff --git a/aries_cloudagent/vc/ld_proofs/ld_proofs.py b/aries_cloudagent/vc/ld_proofs/ld_proofs.py index c520d75e62..02269698a4 100644 --- a/aries_cloudagent/vc/ld_proofs/ld_proofs.py +++ b/aries_cloudagent/vc/ld_proofs/ld_proofs.py @@ -1,6 +1,6 @@ """Linked data proof signing and verification methods.""" -from typing import List +from typing import List, Optional from .document_loader import DocumentLoaderMethod from .proof_set import ProofSet @@ -85,7 +85,7 @@ async def derive( reveal_document: dict, suite: LinkedDataProof, document_loader: DocumentLoaderMethod, - nonce: bytes = None, + nonce: Optional[bytes] = None, ) -> dict: """Derive proof(s) for document with reveal document. diff --git a/aries_cloudagent/vc/ld_proofs/proof_set.py b/aries_cloudagent/vc/ld_proofs/proof_set.py index 9d82f0b634..de43ebc749 100644 --- a/aries_cloudagent/vc/ld_proofs/proof_set.py +++ b/aries_cloudagent/vc/ld_proofs/proof_set.py @@ -1,6 +1,6 @@ """Class to represent a Linked Data proof set.""" -from typing import List, Union +from typing import List, Optional, Union from pyld.jsonld import JsonLdProcessor @@ -145,7 +145,7 @@ async def derive( # But then, why do multiple proofs? suite: LinkedDataProof, document_loader: DocumentLoaderMethod, - nonce: bytes = None, + nonce: Optional[bytes] = None, ) -> dict: """Create new derived Linked Data proof(s) on document using the reveal document. diff --git a/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py b/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py index c988b3f2a2..404a3355a6 100644 --- a/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py +++ b/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py @@ -1,6 +1,7 @@ """Assertion proof purpose class.""" from datetime import datetime, timedelta +from typing import Optional from .controller_proof_purpose import ControllerProofPurpose @@ -10,7 +11,7 @@ class AssertionProofPurpose(ControllerProofPurpose): term = "assertionMethod" - def __init__(self, *, date: datetime = None, max_timestamp_delta: timedelta = None): + def __init__(self, *, date: Optional[datetime] = None, max_timestamp_delta: Optional[timedelta] = None): """Initialize new instance of AssertionProofPurpose.""" super().__init__( term=AssertionProofPurpose.term, diff --git a/aries_cloudagent/vc/ld_proofs/suites/bbs_bls_signature_proof_2020.py b/aries_cloudagent/vc/ld_proofs/suites/bbs_bls_signature_proof_2020.py index 86fecc648c..a0b9459321 100644 --- a/aries_cloudagent/vc/ld_proofs/suites/bbs_bls_signature_proof_2020.py +++ b/aries_cloudagent/vc/ld_proofs/suites/bbs_bls_signature_proof_2020.py @@ -2,7 +2,7 @@ import re from os import urandom -from typing import List +from typing import List, Optional from pyld import jsonld @@ -66,7 +66,7 @@ async def derive_proof( document: dict, reveal_document: dict, document_loader: DocumentLoaderMethod, - nonce: bytes = None, + nonce: Optional[bytes] = None, ): """Derive proof for document, return dict with derived document and proof.""" assert_ursa_bbs_signatures_installed() diff --git a/aries_cloudagent/vc/vc_di/prove.py b/aries_cloudagent/vc/vc_di/prove.py index 779c6a581f..940e7ec76c 100644 --- a/aries_cloudagent/vc/vc_di/prove.py +++ b/aries_cloudagent/vc/vc_di/prove.py @@ -27,9 +27,9 @@ async def create_signed_anoncreds_presentation( pres_definition: dict, presentation: dict, credentials: list, - purpose: ProofPurpose = None, + purpose: Optional[ProofPurpose] = None, challenge: str, - domain: str = None, + domain: Optional[str] = None, ) -> tuple[dict, dict, list]: """Sign the presentation with the passed signature suite. diff --git a/aries_cloudagent/vc/vc_di/verify.py b/aries_cloudagent/vc/vc_di/verify.py index 8710264f74..daac9355f3 100644 --- a/aries_cloudagent/vc/vc_di/verify.py +++ b/aries_cloudagent/vc/vc_di/verify.py @@ -1,5 +1,7 @@ """Verifiable Credential and Presentation verification methods.""" +from typing import Optional + from anoncreds import AnoncredsError from aries_cloudagent.anoncreds.holder import AnonCredsHolderError @@ -15,10 +17,10 @@ async def verify_signed_anoncredspresentation( *, profile: Profile, presentation: dict, - purpose: ProofPurpose = None, - challenge: str = None, - domain: str = None, - pres_req: dict = None, + purpose: Optional[ProofPurpose] = None, + challenge: Optional[str] = None, + domain: Optional[str] = None, + pres_req: Optional[dict] = None, ) -> PresentationVerificationResult: """Verify presentation structure, credentials, proof purpose and signature. diff --git a/aries_cloudagent/vc/vc_ld/issue.py b/aries_cloudagent/vc/vc_ld/issue.py index 0939a108a5..a4ce4a9e3f 100644 --- a/aries_cloudagent/vc/vc_ld/issue.py +++ b/aries_cloudagent/vc/vc_ld/issue.py @@ -1,5 +1,7 @@ """Verifiable Credential issuance methods.""" +from typing import Optional + from ..ld_proofs import ( CredentialIssuancePurpose, DocumentLoaderMethod, @@ -16,7 +18,7 @@ async def issue( credential: dict, suite: LinkedDataProof, document_loader: DocumentLoaderMethod, - purpose: ProofPurpose = None, + purpose: Optional[ProofPurpose] = None, ) -> dict: """Issue a verifiable credential. diff --git a/aries_cloudagent/vc/vc_ld/manager.py b/aries_cloudagent/vc/vc_ld/manager.py index 25e8827619..1f3289c7f8 100644 --- a/aries_cloudagent/vc/vc_ld/manager.py +++ b/aries_cloudagent/vc/vc_ld/manager.py @@ -405,7 +405,7 @@ async def issue( return VerifiableCredential.deserialize(vc) async def store_credential( - self, vc: VerifiableCredential, options: LDProofVCOptions, cred_id: str = None + self, vc: VerifiableCredential, options: LDProofVCOptions, cred_id: Optional[str] = None ) -> VerifiableCredential: """Store a verifiable credential.""" diff --git a/aries_cloudagent/vc/vc_ld/prove.py b/aries_cloudagent/vc/vc_ld/prove.py index 24b2ee9861..e20cad3a92 100644 --- a/aries_cloudagent/vc/vc_ld/prove.py +++ b/aries_cloudagent/vc/vc_ld/prove.py @@ -1,6 +1,6 @@ """Verifiable Credential and Presentation proving methods.""" -from typing import List +from typing import List, Optional from ..ld_proofs import ( AuthenticationProofPurpose, @@ -16,7 +16,7 @@ async def create_presentation( - *, credentials: List[dict], presentation_id: str = None + *, credentials: List[dict], presentation_id: Optional[str] = None ) -> dict: """Create presentation and add the credentials to it. @@ -59,9 +59,9 @@ async def sign_presentation( presentation: dict, suite: LinkedDataProof, document_loader: DocumentLoaderMethod, - purpose: ProofPurpose = None, - challenge: str = None, - domain: str = None, + purpose: Optional[ProofPurpose] = None, + challenge: Optional[str] = None, + domain: Optional[str] = None, ) -> dict: """Sign the presentation with the passed signature suite. diff --git a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py index 78f621a2b9..d44bf58ce5 100644 --- a/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py +++ b/aries_cloudagent/vc/vc_ld/tests/test_vc_ld.py @@ -15,14 +15,9 @@ ) from ...ld_proofs.error import LinkedDataProofException from ...tests.document_loader import custom_document_loader -from ...vc_ld import ( - create_presentation, - derive_credential, - sign_presentation, - verify_credential, - verify_presentation, -) +from ...vc_ld import create_presentation, derive_credential from ...vc_ld import issue_vc as issue +from ...vc_ld import sign_presentation, verify_credential, verify_presentation from .test_credential import ( CREDENTIAL_ISSUED, CREDENTIAL_ISSUED_2020, diff --git a/aries_cloudagent/vc/vc_ld/verify.py b/aries_cloudagent/vc/vc_ld/verify.py index 1dd3f51ec5..07f856d7b3 100644 --- a/aries_cloudagent/vc/vc_ld/verify.py +++ b/aries_cloudagent/vc/vc_ld/verify.py @@ -1,7 +1,7 @@ """Verifiable Credential and Presentation verification methods.""" import asyncio -from typing import List +from typing import List, Optional from pyld.jsonld import JsonLdProcessor @@ -24,7 +24,7 @@ async def _verify_credential( credential: dict, suites: List[LinkedDataProof], document_loader: DocumentLoaderMethod, - purpose: ProofPurpose = None, + purpose: Optional[ProofPurpose] = None, ) -> DocumentVerificationResult: """Verify credential structure, proof purpose and signature.""" @@ -53,7 +53,7 @@ async def verify_credential( credential: dict, suites: List[LinkedDataProof], document_loader: DocumentLoaderMethod, - purpose: ProofPurpose = None, + purpose: Optional[ProofPurpose] = None, ) -> DocumentVerificationResult: """Verify credential structure, proof purpose and signature. @@ -85,9 +85,9 @@ async def _verify_presentation( presentation: dict, suites: List[LinkedDataProof], document_loader: DocumentLoaderMethod, - challenge: str = None, - domain: str = None, - purpose: ProofPurpose = None, + challenge: Optional[str] = None, + domain: Optional[str] = None, + purpose: Optional[ProofPurpose] = None, ): """Verify presentation structure, credentials, proof purpose and signature.""" @@ -143,9 +143,9 @@ async def verify_presentation( presentation: dict, suites: List[LinkedDataProof], document_loader: DocumentLoaderMethod, - purpose: ProofPurpose = None, - challenge: str = None, - domain: str = None, + purpose: Optional[ProofPurpose] = None, + challenge: Optional[str] = None, + domain: Optional[str] = None, ) -> PresentationVerificationResult: """Verify presentation structure, credentials, proof purpose and signature. diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index b885843b3b..1dbffadfe6 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -551,9 +551,9 @@ async def set_did_endpoint( did: str, endpoint: str, ledger: BaseLedger, - endpoint_type: EndpointType = None, + endpoint_type: Optional[EndpointType] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, routing_keys: List[str] = None, ): """Update the endpoint for a DID in the wallet, send to ledger if posted. @@ -612,7 +612,7 @@ async def set_did_endpoint( await self.replace_local_did_metadata(did, metadata) - async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str: + async def rotate_did_keypair_start(self, did: str, next_seed: Optional[str] = None) -> str: """Begin key rotation for DID that wallet owns: generate new keypair. Args: @@ -781,7 +781,7 @@ async def verify_message( ) async def pack_message( - self, message: str, to_verkeys: Sequence[str], from_verkey: str = None + self, message: str, to_verkeys: Sequence[str], from_verkey: Optional[str] = None ) -> bytes: """Pack a message for one or more recipients. diff --git a/aries_cloudagent/wallet/base.py b/aries_cloudagent/wallet/base.py index 7def4e65f4..780b1da6ec 100644 --- a/aries_cloudagent/wallet/base.py +++ b/aries_cloudagent/wallet/base.py @@ -108,7 +108,7 @@ async def replace_signing_key_metadata(self, verkey: str, metadata: dict): """ @abstractmethod - async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str: + async def rotate_did_keypair_start(self, did: str, next_seed: Optional[str] = None) -> str: """Begin key rotation for DID that wallet owns: generate new keypair. Args: @@ -177,8 +177,8 @@ async def create_public_did( self, method: DIDMethod, key_type: KeyType, - seed: str = None, - did: str = None, + seed: Optional[str] = None, + did: Optional[str] = None, metadata: Optional[dict] = None, ) -> DIDInfo: """Create and store a new public DID. @@ -290,9 +290,9 @@ async def set_did_endpoint( did: str, endpoint: str, _ledger: BaseLedger, - endpoint_type: EndpointType = None, + endpoint_type: Optional[EndpointType] = None, write_ledger: bool = True, - endorser_did: str = None, + endorser_did: Optional[str] = None, routing_keys: List[str] = None, ): """Update the endpoint for a DID in the wallet, send to ledger if posted. @@ -364,7 +364,7 @@ async def verify_message( @abstractmethod async def pack_message( - self, message: str, to_verkeys: Sequence[str], from_verkey: str = None + self, message: str, to_verkeys: Sequence[str], from_verkey: Optional[str] = None ) -> bytes: """Pack a message for one or more recipients. diff --git a/aries_cloudagent/wallet/bbs.py b/aries_cloudagent/wallet/bbs.py index 3fa54621ba..816dea6fed 100644 --- a/aries_cloudagent/wallet/bbs.py +++ b/aries_cloudagent/wallet/bbs.py @@ -1,6 +1,6 @@ """BBS+ crypto.""" -from typing import List, Tuple +from typing import List, Optional, Tuple from ..core.error import BaseError from ..utils.dependencies import ( @@ -82,7 +82,7 @@ def verify_signed_messages_bls12381g2( raise BbsException("Unable to verify BBS+ signature") from error -def create_bls12381g2_keypair(seed: bytes = None) -> Tuple[bytes, bytes]: +def create_bls12381g2_keypair(seed: Optional[bytes] = None) -> Tuple[bytes, bytes]: """Create a public and private bls12381g2 keypair from a seed value. Args: diff --git a/aries_cloudagent/wallet/crypto.py b/aries_cloudagent/wallet/crypto.py index 82834c0c82..860052118c 100644 --- a/aries_cloudagent/wallet/crypto.py +++ b/aries_cloudagent/wallet/crypto.py @@ -21,7 +21,7 @@ from .util import b58_to_bytes, b64_to_bytes, bytes_to_b58, random_seed -def create_keypair(key_type: KeyType, seed: bytes = None) -> Tuple[bytes, bytes]: +def create_keypair(key_type: KeyType, seed: Optional[bytes] = None) -> Tuple[bytes, bytes]: """Create a public and private keypair from a seed value. Args: @@ -45,7 +45,7 @@ def create_keypair(key_type: KeyType, seed: bytes = None) -> Tuple[bytes, bytes] raise WalletError(f"Unsupported key type: {key_type.key_type}") -def create_ed25519_keypair(seed: bytes = None) -> Tuple[bytes, bytes]: +def create_ed25519_keypair(seed: Optional[bytes] = None) -> Tuple[bytes, bytes]: """Create a public and private ed25519 keypair from a seed value. Args: @@ -238,7 +238,7 @@ def add_pack_recipients( wrapper: JweEnvelope, cek: bytes, to_verkeys: Sequence[bytes], - from_secret: bytes = None, + from_secret: Optional[bytes] = None, ): """Assemble the recipients block of a packed message. @@ -337,7 +337,7 @@ def decrypt_plaintext( def encode_pack_message( - message: str, to_verkeys: Sequence[bytes], from_secret: bytes = None + message: str, to_verkeys: Sequence[bytes], from_secret: Optional[bytes] = None ) -> bytes: """Assemble a packed message for a set of recipients, optionally including the sender. diff --git a/aries_cloudagent/wallet/in_memory.py b/aries_cloudagent/wallet/in_memory.py index bc6f40bc97..aaea16d579 100644 --- a/aries_cloudagent/wallet/in_memory.py +++ b/aries_cloudagent/wallet/in_memory.py @@ -179,7 +179,7 @@ async def replace_signing_key_metadata(self, verkey: str, metadata: dict): raise WalletNotFoundError("Key not found: {}".format(verkey)) self.profile.keys[verkey]["metadata"] = metadata.copy() if metadata else {} - async def rotate_did_keypair_start(self, did: str, next_seed: str = None) -> str: + async def rotate_did_keypair_start(self, did: str, next_seed: Optional[str] = None) -> str: """Begin key rotation for DID that wallet owns: generate new keypair. Args: @@ -545,7 +545,7 @@ async def verify_message( return verified async def pack_message( - self, message: str, to_verkeys: Sequence[str], from_verkey: str = None + self, message: str, to_verkeys: Sequence[str], from_verkey: Optional[str] = None ) -> bytes: """Pack a message for one or more recipients. diff --git a/aries_cloudagent/wallet/models/wallet_record.py b/aries_cloudagent/wallet/models/wallet_record.py index 86546c225f..93549be5fc 100644 --- a/aries_cloudagent/wallet/models/wallet_record.py +++ b/aries_cloudagent/wallet/models/wallet_record.py @@ -29,12 +29,12 @@ class Meta: def __init__( self, *, - wallet_id: str = None, - key_management_mode: str = None, - settings: dict = None, + wallet_id: Optional[str] = None, + key_management_mode: Optional[str] = None, + settings: Optional[dict] = None, # MTODO: how to make this a tag without making it # a constructor param - wallet_name: str = None, + wallet_name: Optional[str] = None, jwt_iat: Optional[int] = None, **kwargs, ): diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 406c4a6b49..fe202fb793 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -733,7 +733,7 @@ async def wallet_set_public_did(request: web.BaseRequest): if not did: raise web.HTTPBadRequest(reason="Request query must include DID") - info: DIDInfo = None + info: Optional[DIDInfo] = None mediation_id = request.query.get("mediation_id") profile = context.profile @@ -800,13 +800,13 @@ async def promote_wallet_public_did( context: Union[AdminRequestContext, InjectionContext], did: str, write_ledger: bool = False, - profile: Profile = None, - connection_id: str = None, + profile: Optional[Profile] = None, + connection_id: Optional[str] = None, routing_keys: List[str] = None, - mediator_endpoint: str = None, + mediator_endpoint: Optional[str] = None, ) -> Tuple[DIDInfo, Optional[dict]]: """Promote supplied DID to the wallet public DID.""" - info: DIDInfo = None + info: Optional[DIDInfo] = None endorser_did = None is_indy_did = bool(IndyDID.PATTERN.match(did)) @@ -891,7 +891,7 @@ async def promote_wallet_public_did( ) endorser_did = endorser_info["endorser_did"] - did_info: DIDInfo = None + did_info: Optional[DIDInfo] = None attrib_def = None async with ( context.session() if is_ctx_admin_request else profile.session() @@ -1264,7 +1264,7 @@ async def wallet_rotate_did_keypair(request: web.BaseRequest): if not wallet: raise web.HTTPForbidden(reason="No wallet available") try: - did_info: DIDInfo = None + did_info: Optional[DIDInfo] = None did_info = await wallet.get_local_did(did) if did_info.metadata.get("posted", False): # call from ledger API instead to propagate through ledger NYM transaction diff --git a/aries_cloudagent/wallet/sd_jwt.py b/aries_cloudagent/wallet/sd_jwt.py index 9f65cf330d..48c5afa397 100644 --- a/aries_cloudagent/wallet/sd_jwt.py +++ b/aries_cloudagent/wallet/sd_jwt.py @@ -309,8 +309,8 @@ async def _verify_key_binding_jwt( async def sd_jwt_verify( profile: Profile, sd_jwt_presentation: str, - expected_aud: str = None, - expected_nonce: str = None, + expected_aud: Optional[str] = None, + expected_nonce: Optional[str] = None, ) -> SDJWTVerifyResult: """Verify sd-jwt using SDJWTVerifierACAPy.verify().""" sd_jwt_verifier = SDJWTVerifierACAPy( diff --git a/aries_cloudagent/wallet/util.py b/aries_cloudagent/wallet/util.py index 7fe01ab7ab..e0770c63c0 100644 --- a/aries_cloudagent/wallet/util.py +++ b/aries_cloudagent/wallet/util.py @@ -2,6 +2,7 @@ import base64 import re +from typing import Optional import base58 import nacl.bindings @@ -93,7 +94,7 @@ def default_did_from_verkey(verkey: str) -> str: return did -def abbr_verkey(full_verkey: str, did: str = None) -> str: +def abbr_verkey(full_verkey: str, did: Optional[str] = None) -> str: """Given a full verkey and DID, return the abbreviated verkey.""" did_len = len(b58_to_bytes(did.split(":")[-1])) if did else 16 return f"~{bytes_to_b58(b58_to_bytes(full_verkey)[did_len:])}" From 97ff423fe8c0696c677742389a0ec6054d4c85e3 Mon Sep 17 00:00:00 2001 From: ff137 Date: Mon, 16 Sep 2024 11:30:13 +0300 Subject: [PATCH 2/3] :art: apply ruff format Signed-off-by: ff137 --- aries_cloudagent/admin/server.py | 4 +++- aries_cloudagent/anoncreds/holder.py | 5 ++++- aries_cloudagent/askar/profile_anon.py | 4 +++- aries_cloudagent/cache/in_memory.py | 4 +++- aries_cloudagent/connections/models/conn_record.py | 10 ++++++++-- aries_cloudagent/core/dispatcher.py | 10 ++++++++-- aries_cloudagent/indy/issuer.py | 6 +++++- aries_cloudagent/indy/models/cred.py | 4 +++- aries_cloudagent/indy/models/revocation.py | 4 +++- .../messaging/decorators/attach_decorator.py | 4 +++- .../messaging/decorators/tests/test_decorator_set.py | 8 +++++++- .../multitenant/single_wallet_askar_manager.py | 4 +++- .../protocols/actionmenu/v1_0/messages/perform.py | 4 +++- .../connections/v1_0/messages/problem_report.py | 8 +++++++- .../connections/v1_0/models/connection_detail.py | 4 +++- .../protocols/coordinate_mediation/v1_0/manager.py | 5 ++++- .../v1_0/messages/transaction_resend.py | 1 + .../introduction/v0_1/messages/forward_invitation.py | 6 +++++- .../introduction/v0_1/messages/invitation.py | 6 +++++- .../introduction/v0_1/messages/invitation_request.py | 5 ++++- .../v1_0/messages/inner/credential_preview.py | 10 ++++++++-- .../issue_credential/v2_0/formats/vc_di/handler.py | 1 + .../protocols/issue_credential/v2_0/manager.py | 5 ++++- .../v2_0/messages/inner/cred_preview.py | 4 +++- .../issue_credential/v2_0/models/cred_ex_record.py | 4 +++- .../issue_credential/v2_0/models/detail/ld_proof.py | 1 + .../protocols/notification/v1_0/messages/ack.py | 1 + .../present_proof/v1_0/messages/presentation_ack.py | 7 ++++++- .../v1_0/messages/presentation_request.py | 1 + .../present_proof/v2_0/formats/anoncreds/handler.py | 1 + .../protocols/present_proof/v2_0/formats/handler.py | 1 + .../protocols/present_proof/v2_0/messages/pres.py | 1 + .../protocols/present_proof/v2_0/messages/pres_ack.py | 7 ++++++- .../revocation_notification/v2_0/messages/revoke.py | 1 + aries_cloudagent/protocols/routing/v1_0/manager.py | 4 +++- .../protocols/routing/v1_0/messages/forward.py | 4 +++- .../protocols/routing/v1_0/models/route_record.py | 1 + .../protocols/trustping/v1_0/messages/ping.py | 5 ++++- aries_cloudagent/revocation/indy.py | 5 ++++- .../revocation/models/revocation_registry.py | 1 + .../models/tests/test_issuer_rev_reg_record.py | 4 +++- aries_cloudagent/storage/base.py | 6 +++++- aries_cloudagent/storage/in_memory.py | 1 + aries_cloudagent/storage/vc_holder/in_memory.py | 1 + aries_cloudagent/storage/vc_holder/vc_record.py | 4 +++- aries_cloudagent/transport/inbound/manager.py | 1 + aries_cloudagent/transport/outbound/base.py | 1 + aries_cloudagent/transport/outbound/manager.py | 4 +++- aries_cloudagent/utils/classloader.py | 4 +++- aries_cloudagent/utils/jwe.py | 8 ++++++-- aries_cloudagent/utils/task_queue.py | 11 +++++++++-- .../vc/ld_proofs/purposes/assertion_proof_purpose.py | 7 ++++++- aries_cloudagent/vc/vc_ld/manager.py | 5 ++++- aries_cloudagent/wallet/askar.py | 4 +++- aries_cloudagent/wallet/base.py | 4 +++- aries_cloudagent/wallet/crypto.py | 4 +++- aries_cloudagent/wallet/in_memory.py | 4 +++- 57 files changed, 197 insertions(+), 47 deletions(-) diff --git a/aries_cloudagent/admin/server.py b/aries_cloudagent/admin/server.py index 6834f9ec34..9e489f2690 100644 --- a/aries_cloudagent/admin/server.py +++ b/aries_cloudagent/admin/server.py @@ -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") diff --git a/aries_cloudagent/anoncreds/holder.py b/aries_cloudagent/anoncreds/holder.py index 17de18435b..04a1a16fac 100644 --- a/aries_cloudagent/anoncreds/holder.py +++ b/aries_cloudagent/anoncreds/holder.py @@ -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. diff --git a/aries_cloudagent/askar/profile_anon.py b/aries_cloudagent/askar/profile_anon.py index 437da10f20..71c66f2364 100644 --- a/aries_cloudagent/askar/profile_anon.py +++ b/aries_cloudagent/askar/profile_anon.py @@ -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) diff --git a/aries_cloudagent/cache/in_memory.py b/aries_cloudagent/cache/in_memory.py index e6de5fed71..e06358b1ad 100644 --- a/aries_cloudagent/cache/in_memory.py +++ b/aries_cloudagent/cache/in_memory.py @@ -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. diff --git a/aries_cloudagent/connections/models/conn_record.py b/aries_cloudagent/connections/models/conn_record.py index 3bd1a8c103..874d8c3d7f 100644 --- a/aries_cloudagent/connections/models/conn_record.py +++ b/aries_cloudagent/connections/models/conn_record.py @@ -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. @@ -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. diff --git a/aries_cloudagent/core/dispatcher.py b/aries_cloudagent/core/dispatcher.py index e69b4eb137..962b69d97c 100644 --- a/aries_cloudagent/core/dispatcher.py +++ b/aries_cloudagent/core/dispatcher.py @@ -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) diff --git a/aries_cloudagent/indy/issuer.py b/aries_cloudagent/indy/issuer.py index 9ef0f8c52b..102a84619c 100644 --- a/aries_cloudagent/indy/issuer.py +++ b/aries_cloudagent/indy/issuer.py @@ -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 diff --git a/aries_cloudagent/indy/models/cred.py b/aries_cloudagent/indy/models/cred.py index 477eb6c73c..865a7acffd 100644 --- a/aries_cloudagent/indy/models/cred.py +++ b/aries_cloudagent/indy/models/cred.py @@ -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 diff --git a/aries_cloudagent/indy/models/revocation.py b/aries_cloudagent/indy/models/revocation.py index 528b8d073a..a7a2795fbd 100644 --- a/aries_cloudagent/indy/models/revocation.py +++ b/aries_cloudagent/indy/models/revocation.py @@ -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 diff --git a/aries_cloudagent/messaging/decorators/attach_decorator.py b/aries_cloudagent/messaging/decorators/attach_decorator.py index 49a40173d7..98fc177996 100644 --- a/aries_cloudagent/messaging/decorators/attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/attach_decorator.py @@ -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: diff --git a/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py b/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py index be9610b09e..61a01a9e3c 100644 --- a/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py +++ b/aries_cloudagent/messaging/decorators/tests/test_decorator_set.py @@ -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 diff --git a/aries_cloudagent/multitenant/single_wallet_askar_manager.py b/aries_cloudagent/multitenant/single_wallet_askar_manager.py index 92340d0326..157bd287e0 100644 --- a/aries_cloudagent/multitenant/single_wallet_askar_manager.py +++ b/aries_cloudagent/multitenant/single_wallet_askar_manager.py @@ -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: diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py index e385e95c7d..29481a6e66 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py @@ -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: diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py b/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py index 49aa7a44d7..2e8eebd923 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py @@ -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: diff --git a/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py b/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py index 2363fa42b5..6029cb1614 100644 --- a/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py +++ b/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py @@ -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: diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py index 125e07217f..8fc9e414ec 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py @@ -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. diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py index 82216f3449..5b52e4c805 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py @@ -1,4 +1,5 @@ """Represents a transaction resend message.""" + from typing import Optional from marshmallow import EXCLUDE, fields diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py b/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py index d45fc9dd5b..5a8399c282 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py @@ -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. diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py index 433e31df9c..1deb28dbb5 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py @@ -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. diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py index 1ad4ee2527..a6966759f4 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py @@ -1,4 +1,5 @@ """Represents an request for an invitation from the introduction service.""" + from typing import Optional from marshmallow import EXCLUDE, fields @@ -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: diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py index 16b1560f6e..9a2e75b06b 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py @@ -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: @@ -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. diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py index 7836ab4d24..7ab50cf9ae 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/handler.py @@ -2,6 +2,7 @@ indy compatible, attachment is a valid verifiable credential """ + import datetime import json import logging diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py index 1548b4b8b0..068f94a4bd 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py @@ -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. diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py index fb58534a69..6b6e556471 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py @@ -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: diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py index 36dad47fa0..b9b1b1074f 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py @@ -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, diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py index 524a9d5c67..2997201e82 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/detail/ld_proof.py @@ -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 diff --git a/aries_cloudagent/protocols/notification/v1_0/messages/ack.py b/aries_cloudagent/protocols/notification/v1_0/messages/ack.py index 3732c59653..1e425976c2 100644 --- a/aries_cloudagent/protocols/notification/v1_0/messages/ack.py +++ b/aries_cloudagent/protocols/notification/v1_0/messages/ack.py @@ -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 diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py index 695351bb9a..ebebf9112b 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py @@ -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: diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py index 97c46e51db..0eb44ca721 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py @@ -1,4 +1,5 @@ """A presentation request content message.""" + from typing import Optional, Sequence from marshmallow import EXCLUDE, fields diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py index 74529488cd..d5618f4a50 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/anoncreds/handler.py @@ -1,4 +1,5 @@ """V2.0 present-proof indy presentation-exchange format handler.""" + import json import logging from typing import Mapping, Optional, Tuple diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py index 9761b54d24..c4abf9d4c2 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/handler.py @@ -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 diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py index 290de5f277..5cf19bb81b 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py @@ -1,4 +1,5 @@ """A (proof) presentation content message.""" + from typing import Optional, Sequence from marshmallow import EXCLUDE, ValidationError, fields, validates_schema diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py index 859310da79..6efe4568da 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py @@ -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: diff --git a/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py b/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py index 44fef8d8c0..8ed4d83e96 100644 --- a/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py +++ b/aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py @@ -1,4 +1,5 @@ """Revoke message.""" + from typing import Optional from marshmallow import fields, validate diff --git a/aries_cloudagent/protocols/routing/v1_0/manager.py b/aries_cloudagent/protocols/routing/v1_0/manager.py index facef0711c..121d0026ab 100644 --- a/aries_cloudagent/protocols/routing/v1_0/manager.py +++ b/aries_cloudagent/protocols/routing/v1_0/manager.py @@ -77,7 +77,9 @@ async def get_recipient(self, recip_verkey: str) -> RouteRecord: await asyncio.sleep(RECIP_ROUTE_PAUSE) async def get_routes( - self, client_connection_id: Optional[str] = None, tag_filter: Optional[dict] = None + self, + client_connection_id: Optional[str] = None, + tag_filter: Optional[dict] = None, ) -> Sequence[RouteRecord]: """Fetch all routes associated with the current connection. diff --git a/aries_cloudagent/protocols/routing/v1_0/messages/forward.py b/aries_cloudagent/protocols/routing/v1_0/messages/forward.py index 19f0bdc06d..ab455af073 100644 --- a/aries_cloudagent/protocols/routing/v1_0/messages/forward.py +++ b/aries_cloudagent/protocols/routing/v1_0/messages/forward.py @@ -21,7 +21,9 @@ class Meta: message_type = FORWARD schema_class = "ForwardSchema" - def __init__(self, *, to: Optional[str] = None, msg: Union[dict, str] = None, **kwargs): + def __init__( + self, *, to: Optional[str] = None, msg: Union[dict, str] = None, **kwargs + ): """Initialize forward message object. Args: diff --git a/aries_cloudagent/protocols/routing/v1_0/models/route_record.py b/aries_cloudagent/protocols/routing/v1_0/models/route_record.py index 0f42081107..e82990f221 100644 --- a/aries_cloudagent/protocols/routing/v1_0/models/route_record.py +++ b/aries_cloudagent/protocols/routing/v1_0/models/route_record.py @@ -1,4 +1,5 @@ """An object for containing information on an individual route.""" + from typing import Optional from marshmallow import EXCLUDE, ValidationError, fields, validates_schema diff --git a/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py b/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py index e04b1500eb..9e8d98b5af 100644 --- a/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py +++ b/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py @@ -1,4 +1,5 @@ """Represents a trust ping message.""" + from typing import Optional from marshmallow import EXCLUDE, fields @@ -19,7 +20,9 @@ class Meta: message_type = PING schema_class = "PingSchema" - def __init__(self, *, response_requested: bool = True, comment: Optional[str] = None, **kwargs): + def __init__( + self, *, response_requested: bool = True, comment: Optional[str] = None, **kwargs + ): """Initialize a Ping message instance. Args: diff --git a/aries_cloudagent/revocation/indy.py b/aries_cloudagent/revocation/indy.py index 2f2e009f47..7c1efe6e25 100644 --- a/aries_cloudagent/revocation/indy.py +++ b/aries_cloudagent/revocation/indy.py @@ -203,7 +203,10 @@ async def list_issuer_registries(self) -> Sequence[IssuerRevRegRecord]: return await IssuerRevRegRecord.query(session) async def get_issuer_rev_reg_delta( - self, rev_reg_id: str, timestamp_from: Optional[int] = None, timestamp_to: Optional[int] = None + self, + rev_reg_id: str, + timestamp_from: Optional[int] = None, + timestamp_to: Optional[int] = None, ) -> dict: """Check ledger for revocation status for a given revocation registry. diff --git a/aries_cloudagent/revocation/models/revocation_registry.py b/aries_cloudagent/revocation/models/revocation_registry.py index f2d4e262b8..177d67860d 100644 --- a/aries_cloudagent/revocation/models/revocation_registry.py +++ b/aries_cloudagent/revocation/models/revocation_registry.py @@ -1,4 +1,5 @@ """Classes for managing a revocation registry.""" + import hashlib import http import logging diff --git a/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py index 9dc6ce1287..e0f7978a86 100644 --- a/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/tests/test_issuer_rev_reg_record.py @@ -120,7 +120,9 @@ async def test_fix_ledger_entry(self): } class TestProfile(InMemoryProfile): - def session(self, context: Optional[InjectionContext] = None) -> "ProfileSession": + def session( + self, context: Optional[InjectionContext] = None + ) -> "ProfileSession": return TestProfileSession(self, context=context) @classmethod diff --git a/aries_cloudagent/storage/base.py b/aries_cloudagent/storage/base.py index bc9c61f319..d1cbc8086e 100644 --- a/aries_cloudagent/storage/base.py +++ b/aries_cloudagent/storage/base.py @@ -1,4 +1,5 @@ """Abstract base classes for non-secrets storage.""" + from abc import ABC, abstractmethod from typing import Mapping, Optional, Sequence @@ -70,7 +71,10 @@ async def delete_record(self, record: StorageRecord): """ async def find_record( - self, type_filter: str, tag_query: Optional[Mapping] = None, options: Optional[Mapping] = None + self, + type_filter: str, + tag_query: Optional[Mapping] = None, + options: Optional[Mapping] = None, ) -> StorageRecord: """Find a record using a unique tag filter. diff --git a/aries_cloudagent/storage/in_memory.py b/aries_cloudagent/storage/in_memory.py index 198cc6bc24..03af62b2cf 100644 --- a/aries_cloudagent/storage/in_memory.py +++ b/aries_cloudagent/storage/in_memory.py @@ -1,4 +1,5 @@ """Basic in-memory storage implementation (non-wallet).""" + from typing import Mapping, Optional, Sequence from ..core.in_memory import InMemoryProfile diff --git a/aries_cloudagent/storage/vc_holder/in_memory.py b/aries_cloudagent/storage/vc_holder/in_memory.py index 27bad21520..6cfcb1c64e 100644 --- a/aries_cloudagent/storage/vc_holder/in_memory.py +++ b/aries_cloudagent/storage/vc_holder/in_memory.py @@ -1,4 +1,5 @@ """Basic in-memory storage implementation of VC holder interface.""" + from typing import Mapping, Optional, Sequence from dateutil.parser import ParserError diff --git a/aries_cloudagent/storage/vc_holder/vc_record.py b/aries_cloudagent/storage/vc_holder/vc_record.py index 4d091bac5a..ea859c78e7 100644 --- a/aries_cloudagent/storage/vc_holder/vc_record.py +++ b/aries_cloudagent/storage/vc_holder/vc_record.py @@ -31,7 +31,9 @@ def __init__( proof_types: Sequence[str], # one or more proof types may be present cred_value: Mapping, # the credential value as a JSON-serializable mapping given_id: Optional[str] = None, # value of the credential 'id' property, if any - cred_tags: Optional[Mapping] = None, # tags for retrieval (derived from attribute values) + cred_tags: Optional[ + Mapping + ] = None, # tags for retrieval (derived from attribute values) record_id: Optional[str] = None, # specify the storage record ID ): """Initialize some defaults on record.""" diff --git a/aries_cloudagent/transport/inbound/manager.py b/aries_cloudagent/transport/inbound/manager.py index eca52ef9dd..cdc3806aa6 100644 --- a/aries_cloudagent/transport/inbound/manager.py +++ b/aries_cloudagent/transport/inbound/manager.py @@ -1,4 +1,5 @@ """Inbound transport manager.""" + import logging from collections import OrderedDict from typing import Callable, Coroutine, Optional diff --git a/aries_cloudagent/transport/outbound/base.py b/aries_cloudagent/transport/outbound/base.py index 3aeec7c0dc..f6b8b73fb0 100644 --- a/aries_cloudagent/transport/outbound/base.py +++ b/aries_cloudagent/transport/outbound/base.py @@ -1,4 +1,5 @@ """Base outbound transport.""" + import asyncio from abc import ABC, abstractmethod from typing import Optional, Union diff --git a/aries_cloudagent/transport/outbound/manager.py b/aries_cloudagent/transport/outbound/manager.py index 075e340843..e76c1ea779 100644 --- a/aries_cloudagent/transport/outbound/manager.py +++ b/aries_cloudagent/transport/outbound/manager.py @@ -96,7 +96,9 @@ def register(self, module_name: str) -> str: return self.register_class(imported_class) def register_class( - self, transport_class: Type[BaseOutboundTransport], transport_id: Optional[str] = None + self, + transport_class: Type[BaseOutboundTransport], + transport_id: Optional[str] = None, ) -> str: """Register a new outbound transport class. diff --git a/aries_cloudagent/utils/classloader.py b/aries_cloudagent/utils/classloader.py index 9f3fd63ef5..29fd81bc4d 100644 --- a/aries_cloudagent/utils/classloader.py +++ b/aries_cloudagent/utils/classloader.py @@ -117,7 +117,9 @@ def load_class( return resolved @classmethod - def load_subclass_of(cls, base_class: Type, mod_path: str, package: Optional[str] = None): + def load_subclass_of( + cls, base_class: Type, mod_path: str, package: Optional[str] = None + ): """Resolve an implementation of a base path within a module. Args: diff --git a/aries_cloudagent/utils/jwe.py b/aries_cloudagent/utils/jwe.py index e3a3099ea1..de7f23802d 100644 --- a/aries_cloudagent/utils/jwe.py +++ b/aries_cloudagent/utils/jwe.py @@ -70,7 +70,9 @@ class JweRecipientSchema(Schema): class JweRecipient: """A single message recipient.""" - def __init__(self, *, encrypted_key: bytes, header: Optional[dict] = None) -> "JweRecipient": + def __init__( + self, *, encrypted_key: bytes, header: Optional[dict] = None + ) -> "JweRecipient": """Initialize the JWE recipient.""" self.encrypted_key = encrypted_key self.header = header or {} @@ -262,7 +264,9 @@ def protected_bytes(self) -> bytes: self.protected_b64.encode("utf-8") if self.protected_b64 is not None else None ) - def set_payload(self, ciphertext: bytes, iv: bytes, tag: bytes, aad: Optional[bytes] = None): + def set_payload( + self, ciphertext: bytes, iv: bytes, tag: bytes, aad: Optional[bytes] = None + ): """Set the payload of the JWE envelope.""" self.ciphertext = ciphertext self.iv = iv diff --git a/aries_cloudagent/utils/task_queue.py b/aries_cloudagent/utils/task_queue.py index 226040e17e..5780dd1a9d 100644 --- a/aries_cloudagent/utils/task_queue.py +++ b/aries_cloudagent/utils/task_queue.py @@ -1,4 +1,5 @@ """Classes for managing a set of asyncio tasks.""" + import asyncio import logging import time @@ -123,7 +124,10 @@ class TaskQueue: """A class for managing a set of asyncio tasks.""" def __init__( - self, max_active: int = 0, timed: bool = False, trace_fn: Optional[Callable] = None + self, + max_active: int = 0, + timed: bool = False, + trace_fn: Optional[Callable] = None, ): """Initialize the task queue. @@ -303,7 +307,10 @@ def run( return self.add_active(task, task_complete, ident, timing) def put( - self, coro: Coroutine, task_complete: Optional[Callable] = None, ident: Optional[str] = None + self, + coro: Coroutine, + task_complete: Optional[Callable] = None, + ident: Optional[str] = None, ) -> PendingTask: """Add a new task to the queue, delaying execution if busy. diff --git a/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py b/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py index 404a3355a6..e1640c6eba 100644 --- a/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py +++ b/aries_cloudagent/vc/ld_proofs/purposes/assertion_proof_purpose.py @@ -11,7 +11,12 @@ class AssertionProofPurpose(ControllerProofPurpose): term = "assertionMethod" - def __init__(self, *, date: Optional[datetime] = None, max_timestamp_delta: Optional[timedelta] = None): + def __init__( + self, + *, + date: Optional[datetime] = None, + max_timestamp_delta: Optional[timedelta] = None, + ): """Initialize new instance of AssertionProofPurpose.""" super().__init__( term=AssertionProofPurpose.term, diff --git a/aries_cloudagent/vc/vc_ld/manager.py b/aries_cloudagent/vc/vc_ld/manager.py index 1f3289c7f8..52808707f3 100644 --- a/aries_cloudagent/vc/vc_ld/manager.py +++ b/aries_cloudagent/vc/vc_ld/manager.py @@ -405,7 +405,10 @@ async def issue( return VerifiableCredential.deserialize(vc) async def store_credential( - self, vc: VerifiableCredential, options: LDProofVCOptions, cred_id: Optional[str] = None + self, + vc: VerifiableCredential, + options: LDProofVCOptions, + cred_id: Optional[str] = None, ) -> VerifiableCredential: """Store a verifiable credential.""" diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index 1dbffadfe6..f648df36b7 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -612,7 +612,9 @@ async def set_did_endpoint( await self.replace_local_did_metadata(did, metadata) - async def rotate_did_keypair_start(self, did: str, next_seed: Optional[str] = None) -> str: + async def rotate_did_keypair_start( + self, did: str, next_seed: Optional[str] = None + ) -> str: """Begin key rotation for DID that wallet owns: generate new keypair. Args: diff --git a/aries_cloudagent/wallet/base.py b/aries_cloudagent/wallet/base.py index 780b1da6ec..dac45d301e 100644 --- a/aries_cloudagent/wallet/base.py +++ b/aries_cloudagent/wallet/base.py @@ -108,7 +108,9 @@ async def replace_signing_key_metadata(self, verkey: str, metadata: dict): """ @abstractmethod - async def rotate_did_keypair_start(self, did: str, next_seed: Optional[str] = None) -> str: + async def rotate_did_keypair_start( + self, did: str, next_seed: Optional[str] = None + ) -> str: """Begin key rotation for DID that wallet owns: generate new keypair. Args: diff --git a/aries_cloudagent/wallet/crypto.py b/aries_cloudagent/wallet/crypto.py index 860052118c..0ceef63a91 100644 --- a/aries_cloudagent/wallet/crypto.py +++ b/aries_cloudagent/wallet/crypto.py @@ -21,7 +21,9 @@ from .util import b58_to_bytes, b64_to_bytes, bytes_to_b58, random_seed -def create_keypair(key_type: KeyType, seed: Optional[bytes] = None) -> Tuple[bytes, bytes]: +def create_keypair( + key_type: KeyType, seed: Optional[bytes] = None +) -> Tuple[bytes, bytes]: """Create a public and private keypair from a seed value. Args: diff --git a/aries_cloudagent/wallet/in_memory.py b/aries_cloudagent/wallet/in_memory.py index aaea16d579..cbd1f00960 100644 --- a/aries_cloudagent/wallet/in_memory.py +++ b/aries_cloudagent/wallet/in_memory.py @@ -179,7 +179,9 @@ async def replace_signing_key_metadata(self, verkey: str, metadata: dict): raise WalletNotFoundError("Key not found: {}".format(verkey)) self.profile.keys[verkey]["metadata"] = metadata.copy() if metadata else {} - async def rotate_did_keypair_start(self, did: str, next_seed: Optional[str] = None) -> str: + async def rotate_did_keypair_start( + self, did: str, next_seed: Optional[str] = None + ) -> str: """Begin key rotation for DID that wallet owns: generate new keypair. Args: From f1b7708916eb064bbc0162cc56b9237918a4d181 Mon Sep 17 00:00:00 2001 From: ff137 Date: Mon, 16 Sep 2024 12:37:22 +0300 Subject: [PATCH 3/3] :art: add optional typing to List[...] = None parameters Signed-off-by: ff137 --- aries_cloudagent/ledger/base.py | 4 ++-- aries_cloudagent/ledger/indy_vdr.py | 2 +- aries_cloudagent/wallet/askar.py | 2 +- aries_cloudagent/wallet/base.py | 2 +- aries_cloudagent/wallet/routes.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aries_cloudagent/ledger/base.py b/aries_cloudagent/ledger/base.py index bba161ef24..caaff97192 100644 --- a/aries_cloudagent/ledger/base.py +++ b/aries_cloudagent/ledger/base.py @@ -86,7 +86,7 @@ async def _construct_attr_json( endpoint: str, endpoint_type: Optional[EndpointType] = None, all_exist_endpoints: Optional[dict] = None, - routing_keys: List[str] = None, + routing_keys: Optional[List[str]] = None, ) -> str: """Create attr_json string. @@ -120,7 +120,7 @@ async def update_endpoint_for_did( endpoint_type: EndpointType = EndpointType.ENDPOINT, write_ledger: bool = True, endorser_did: Optional[str] = None, - routing_keys: List[str] = None, + routing_keys: Optional[List[str]] = None, ) -> bool: """Check and update the endpoint on the ledger. diff --git a/aries_cloudagent/ledger/indy_vdr.py b/aries_cloudagent/ledger/indy_vdr.py index 2d169524dc..81bc44e892 100644 --- a/aries_cloudagent/ledger/indy_vdr.py +++ b/aries_cloudagent/ledger/indy_vdr.py @@ -712,7 +712,7 @@ async def update_endpoint_for_did( endpoint_type: Optional[EndpointType] = None, write_ledger: bool = True, endorser_did: Optional[str] = None, - routing_keys: List[str] = None, + routing_keys: Optional[List[str]] = None, ) -> bool: """Check and update the endpoint on the ledger. diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index f648df36b7..efea7120bb 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -554,7 +554,7 @@ async def set_did_endpoint( endpoint_type: Optional[EndpointType] = None, write_ledger: bool = True, endorser_did: Optional[str] = None, - routing_keys: List[str] = None, + routing_keys: Optional[List[str]] = None, ): """Update the endpoint for a DID in the wallet, send to ledger if posted. diff --git a/aries_cloudagent/wallet/base.py b/aries_cloudagent/wallet/base.py index dac45d301e..2f883fd2ea 100644 --- a/aries_cloudagent/wallet/base.py +++ b/aries_cloudagent/wallet/base.py @@ -295,7 +295,7 @@ async def set_did_endpoint( endpoint_type: Optional[EndpointType] = None, write_ledger: bool = True, endorser_did: Optional[str] = None, - routing_keys: List[str] = None, + routing_keys: Optional[List[str]] = None, ): """Update the endpoint for a DID in the wallet, send to ledger if posted. diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index fe202fb793..9e2045dc95 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -802,7 +802,7 @@ async def promote_wallet_public_did( write_ledger: bool = False, profile: Optional[Profile] = None, connection_id: Optional[str] = None, - routing_keys: List[str] = None, + routing_keys: Optional[List[str]] = None, mediator_endpoint: Optional[str] = None, ) -> Tuple[DIDInfo, Optional[dict]]: """Promote supplied DID to the wallet public DID."""