diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 52d791c6b4..d6c6e8fa69 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -22,10 +22,10 @@ jobs: - name: Ruff Format Check uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1.0.0 with: - version: 0.12.10 + version: 0.13.3 args: "format --check" - name: Ruff Lint Check uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1.0.0 with: - version: 0.12.10 + version: 0.13.3 args: "check" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f7eeab18f..ed5902086b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: additional_dependencies: ['@commitlint/config-conventional'] - repo: https://github.com/astral-sh/ruff-pre-commit # Ensure this is synced with pyproject.toml - rev: v0.12.10 + rev: v0.13.3 hooks: # Run the linter - id: ruff diff --git a/acapy_agent/__main__.py b/acapy_agent/__main__.py index 9669588b83..a64e2c65f1 100644 --- a/acapy_agent/__main__.py +++ b/acapy_agent/__main__.py @@ -9,7 +9,6 @@ def init_debug(args): """Initialize debugging environment.""" - ENABLE_PTVSD = os.getenv("ENABLE_PTVSD", "").lower() ENABLE_PTVSD = ENABLE_PTVSD and ENABLE_PTVSD not in ("false", "0") diff --git a/acapy_agent/admin/server.py b/acapy_agent/admin/server.py index 621f256fd9..bd55141817 100644 --- a/acapy_agent/admin/server.py +++ b/acapy_agent/admin/server.py @@ -105,6 +105,7 @@ async def send_outbound( Args: message: The `OutboundMessage` to be sent **kwargs: Additional keyword arguments + """ profile = self._profile() if not profile: @@ -117,6 +118,7 @@ async def send_webhook(self, topic: str, payload: dict): Args: topic: the webhook topic identifier payload: the webhook payload value + """ warnings.warn( "responder.send_webhook is deprecated; please use the event bus instead.", @@ -136,7 +138,6 @@ def send_fn(self) -> Coroutine: @web.middleware async def ready_middleware(request: web.BaseRequest, handler: Coroutine): """Only continue if application is ready to take work.""" - is_status_check = str(request.rel_url).rstrip("/") in status_paths is_app_ready = request.app._state.get("ready") @@ -241,7 +242,6 @@ async def upgrade_middleware(request: web.BaseRequest, handler: Coroutine): @web.middleware async def debug_middleware(request: web.BaseRequest, handler: Coroutine): """Show request detail in debug log.""" - if LOGGER.isEnabledFor(logging.DEBUG): # Skipped if DEBUG is not enabled LOGGER.debug("Incoming request: %s %s", request.method, request.path_qs) is_status_check = str(request.rel_url).startswith("/status/") @@ -282,6 +282,7 @@ def __init__( conductor_stop (Coroutine): Conductor (graceful) stop for shutdown API call. task_queue (TaskQueue, optional): An optional task queue for handlers. conductor_stats (Coroutine, optional): Conductor statistics API call. + """ self.app = None self.admin_api_key = context.settings.get("admin.admin_api_key") @@ -302,7 +303,6 @@ def __init__( async def make_application(self) -> web.Application: """Get the aiohttp application instance.""" - middlewares = [ready_middleware, debug_middleware] # admin-token and admin-token are mutually exclusive and required. @@ -566,7 +566,6 @@ def notify_fatal_error(self): async def websocket_handler(self, request): """Send notifications to admin client over websocket.""" - ws = web.WebSocketResponse() await ws.prepare(request) socket_id = str(uuid4()) diff --git a/acapy_agent/anoncreds/base.py b/acapy_agent/anoncreds/base.py index 6474dee556..6d1e7c3878 100644 --- a/acapy_agent/anoncreds/base.py +++ b/acapy_agent/anoncreds/base.py @@ -59,6 +59,7 @@ def __init__( obj (T, optional): The generic object associated with the instance. *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. + """ super().__init__(message, obj_id, obj, *args, **kwargs) self._message = message diff --git a/acapy_agent/anoncreds/default/legacy_indy/recover.py b/acapy_agent/anoncreds/default/legacy_indy/recover.py index 65a725ceae..e5a00d4898 100644 --- a/acapy_agent/anoncreds/default/legacy_indy/recover.py +++ b/acapy_agent/anoncreds/default/legacy_indy/recover.py @@ -52,7 +52,6 @@ async def fetch_txns( set[int], ]: """Fetch tails file and revocation registry information.""" - LOGGER.debug(f"Fetch revocation registry def {registry_id} from ledger") revoc_reg_delta_request = indy_vdr.ledger.build_get_revoc_reg_def_request( None, registry_id @@ -92,7 +91,6 @@ async def fetch_txns( async def generate_ledger_rrrecovery_txn(genesis_txns: str, rev_list: RevList) -> dict: """Generate a new ledger accum entry, using the wallet value if revocations ahead of ledger.""" # noqa: E501 - registry_from_ledger, prev_revoked = await fetch_txns( genesis_txns, rev_list.rev_reg_def_id, rev_list.issuer_id ) diff --git a/acapy_agent/anoncreds/default/legacy_indy/registry.py b/acapy_agent/anoncreds/default/legacy_indy/registry.py index 629926dfa1..e66569eea7 100644 --- a/acapy_agent/anoncreds/default/legacy_indy/registry.py +++ b/acapy_agent/anoncreds/default/legacy_indy/registry.py @@ -175,7 +175,6 @@ def make_rev_reg_def_id(rev_reg_def: RevRegDef) -> str: async def get_schema(self, profile: Profile, schema_id: str) -> GetSchemaResult: """Get a schema from the registry.""" - multitenant_mgr = profile.inject_or(BaseMultitenantManager) if multitenant_mgr: ledger_exec_inst = IndyLedgerRequestsExecutor(profile) @@ -333,7 +332,6 @@ async def get_credential_definition( self, profile: Profile, cred_def_id: str ) -> GetCredDefResult: """Get a credential definition from the registry.""" - async with profile.session() as session: multitenant_mgr = session.inject_or(BaseMultitenantManager) if multitenant_mgr: @@ -1211,7 +1209,6 @@ async def txn_submit( write_ledger: bool = True, ) -> str: """Submit a transaction to the ledger.""" - try: async with ledger: return await shield( diff --git a/acapy_agent/anoncreds/events.py b/acapy_agent/anoncreds/events.py index 719c1d5310..6d51675eba 100644 --- a/acapy_agent/anoncreds/events.py +++ b/acapy_agent/anoncreds/events.py @@ -37,6 +37,7 @@ def __init__( Args: payload: CredDefFinishedPayload + """ self._topic = CRED_DEF_FINISHED_EVENT self._payload = payload @@ -84,6 +85,7 @@ def __init__(self, payload: RevRegDefFinishedPayload): Args: payload: RevRegDefFinishedPayload + """ self._topic = REV_REG_DEF_FINISHED_EVENT self._payload = payload @@ -121,6 +123,7 @@ def __init__(self, payload: RevListFinishedPayload): Args: payload: RevListFinishedPayload + """ self._topic = REV_LIST_FINISHED_EVENT self._payload = payload diff --git a/acapy_agent/anoncreds/holder.py b/acapy_agent/anoncreds/holder.py index 43a9a2f656..a70bc058cd 100644 --- a/acapy_agent/anoncreds/holder.py +++ b/acapy_agent/anoncreds/holder.py @@ -87,7 +87,6 @@ def profile(self) -> AskarAnonCredsProfile: async def get_master_secret(self) -> str: """Get or create the default master secret.""" - while True: async with self.profile.session() as session: try: @@ -381,7 +380,6 @@ async def get_credentials(self, *, offset: int, limit: int, wql: dict) -> list[d wql: wql query dict """ - result = [] try: @@ -526,6 +524,7 @@ async def credential_revoked( Returns: bool: True if the credential is revoked, False otherwise. + """ cred = await self._get_credential(credential_id) rev_reg_id = cred.rev_reg_id @@ -604,7 +603,6 @@ async def create_presentation( rev_states: AnonCreds format revocation states JSON """ - creds: Dict[str, Credential] = {} def get_rev_state(cred_id: str, detail: dict): @@ -750,7 +748,6 @@ async def create_revocation_state( the revocation state """ - try: rev_state = await asyncio.get_event_loop().run_in_executor( None, diff --git a/acapy_agent/anoncreds/issuer.py b/acapy_agent/anoncreds/issuer.py index f035f9753e..a168242f30 100644 --- a/acapy_agent/anoncreds/issuer.py +++ b/acapy_agent/anoncreds/issuer.py @@ -272,6 +272,7 @@ async def credential_definition_in_wallet( Args: credential_definition_id: The credential definition ID to check + """ try: async with self.profile.session() as session: diff --git a/acapy_agent/anoncreds/models/credential_definition.py b/acapy_agent/anoncreds/models/credential_definition.py index 6d468084d3..6ada3009ad 100644 --- a/acapy_agent/anoncreds/models/credential_definition.py +++ b/acapy_agent/anoncreds/models/credential_definition.py @@ -44,6 +44,7 @@ def __init__(self, n: str, s: str, r: dict, rctxt: str, z: str, **kwargs): and p'q'-1. This makes up part of the CL-RSA public key, independent of the message blocks being signed. kwargs: Keyword arguments + """ super().__init__(**kwargs) self.n = n @@ -108,6 +109,7 @@ def __init__( r_key above. y: is the an elliptic curve point in G2. computed as h_cap^x (in multiplicative notation), where x is from r_key above + """ self.g = g self.g_dash = g_dash @@ -174,6 +176,7 @@ def __init__( primary: Cred Def value primary revocation: Cred Def value revocation kwargs: Keyword arguments + """ super().__init__(**kwargs) self.primary = primary @@ -226,6 +229,7 @@ def __init__( tag: Tag value: Cred Def value kwargs: Keyword arguments + """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -305,6 +309,7 @@ def __init__( state: State credential_definition_id: Cred Def ID credential_definition: Cred Def + """ self.state = state self.credential_definition_id = credential_definition_id @@ -366,6 +371,7 @@ def __init__( registration_metadata: Registration metadata credential_definition_metadata: Cred Def metadata kwargs: Keyword arguments + """ super().__init__(**kwargs) self.job_id = job_id @@ -414,6 +420,7 @@ def __init__( resolution_metadata: Resolution metadata credential_definition_metadata: Cred Def metadata kwargs: Keyword arguments + """ super().__init__(**kwargs) self.credential_definition_id = credential_definition_id diff --git a/acapy_agent/anoncreds/models/issuer_cred_rev_record.py b/acapy_agent/anoncreds/models/issuer_cred_rev_record.py index e133ef18ef..72da3fa747 100644 --- a/acapy_agent/anoncreds/models/issuer_cred_rev_record.py +++ b/acapy_agent/anoncreds/models/issuer_cred_rev_record.py @@ -73,6 +73,7 @@ async def query_by_ids( cred_def_id: the cred def id by which to filter rev_reg_id: the rev reg id by which to filter state: a state value by which to filter + """ # Call parent method but cast return type return await super().query_by_ids( diff --git a/acapy_agent/anoncreds/models/predicate.py b/acapy_agent/anoncreds/models/predicate.py index f1e563d932..765cf96769 100644 --- a/acapy_agent/anoncreds/models/predicate.py +++ b/acapy_agent/anoncreds/models/predicate.py @@ -57,7 +57,6 @@ def math(self) -> str: @staticmethod def get(relation: str) -> Union["Predicate", None]: """Return enum instance corresponding to input relation string.""" - for pred in Predicate: if relation.upper() in ( pred.value.fortran, @@ -75,8 +74,8 @@ def to_int(value: Any) -> int: Args: value: value to coerce - """ + """ if isinstance(value, (bool, int)): return int(value) return int(str(value)) # kick out floats diff --git a/acapy_agent/anoncreds/models/revocation.py b/acapy_agent/anoncreds/models/revocation.py index c182dc7ecb..3d9821b8c2 100644 --- a/acapy_agent/anoncreds/models/revocation.py +++ b/acapy_agent/anoncreds/models/revocation.py @@ -41,6 +41,7 @@ def __init__( tails_location: Tails file location tails_hash: Tails file hash kwargs: Keyword arguments + """ super().__init__(**kwargs) self.public_keys = public_keys @@ -100,6 +101,7 @@ def __init__( tag: Tag value: Rev Reg Def Value kwargs: Keyword arguments + """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -178,6 +180,7 @@ def __init__( state: State revocation_registry_definition_id: Rev Reg Definition ID revocation_registry_definition: Rev Reg Definition + """ self.state = state self.revocation_registry_definition_id = revocation_registry_definition_id @@ -240,6 +243,7 @@ def __init__( registration_metadata: Registration metadata revocation_registry_definition_metadata: Rev Reg Def metadata kwargs: Keyword arguments + """ super().__init__(**kwargs) self.job_id = job_id @@ -300,6 +304,7 @@ def __init__( resolution_metadata: Resolution metadata revocation_registry_metadata: Revocation Registry metadata kwargs: Keyword arguments + """ super().__init__(**kwargs) self.revocation_registry = revocation_registry @@ -349,6 +354,7 @@ def __init__( current_accumulator: Current accumulator timestamp: Timestamp kwargs: Keyword arguments + """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -437,6 +443,7 @@ def __init__( Args: state: State revocation_list: Revocation list + """ self.state = state self.revocation_list = revocation_list @@ -490,6 +497,7 @@ def __init__( registration_metadata: Registration metadata revocation_list_metadata: Revocation list metadata kwargs: Keyword arguments + """ super().__init__(**kwargs) self.job_id = job_id @@ -541,6 +549,7 @@ def __init__( resolution_metadata: Resolution metadata revocation_registry_metadata: Rev Reg metadata kwargs: Keyword arguments + """ super().__init__(**kwargs) self.revocation_list = revocation_list diff --git a/acapy_agent/anoncreds/models/schema.py b/acapy_agent/anoncreds/models/schema.py index ea2b850eda..4c347c259d 100644 --- a/acapy_agent/anoncreds/models/schema.py +++ b/acapy_agent/anoncreds/models/schema.py @@ -29,6 +29,7 @@ def __init__( name: Schema name version: Schema version kwargs: Addiiotnal keyword arguments + """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -107,6 +108,7 @@ def __init__( resolution_metadata: Resolution Metdata schema_metadata: Schema Metadata kwargs: Additional keyword arguments + """ super().__init__(**kwargs) self.schema_value = schema @@ -223,6 +225,7 @@ def __init__( registration_metadata: Registration Metdata schema_metadata: Schema Metadata kwargs: Additional keyword arguments + """ super().__init__(**kwargs) self.job_id = job_id diff --git a/acapy_agent/anoncreds/models/schema_info.py b/acapy_agent/anoncreds/models/schema_info.py index 81bd7ee0e6..4ead508bc8 100644 --- a/acapy_agent/anoncreds/models/schema_info.py +++ b/acapy_agent/anoncreds/models/schema_info.py @@ -1,4 +1,4 @@ -"""This class represents schema information for anoncreds.""" +"""Schema information for AnonCreds.""" from typing import Optional @@ -15,6 +15,7 @@ class AnonCredsSchemaInfo: issuer_id (str): The identifier of the issuer. name (Optional[str], optional): The name of the schema. Defaults to None. version (Optional[str], optional): The version of the schema. Defaults to None. + """ def __init__( diff --git a/acapy_agent/anoncreds/revocation/manager.py b/acapy_agent/anoncreds/revocation/manager.py index 5debf7d524..2851b79e71 100644 --- a/acapy_agent/anoncreds/revocation/manager.py +++ b/acapy_agent/anoncreds/revocation/manager.py @@ -34,6 +34,7 @@ def __init__(self, profile: Profile) -> None: Args: profile: The profile instance for this revocation manager + """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -248,6 +249,7 @@ async def publish_pending_revocations( options: Additional options for the revocation registry publish Returns: mapping from each revocation registry id to its cred rev ids published. + """ options = options or {} published_crids = {} diff --git a/acapy_agent/anoncreds/revocation/recover.py b/acapy_agent/anoncreds/revocation/recover.py index 7e93e58273..a664c3e0ac 100644 --- a/acapy_agent/anoncreds/revocation/recover.py +++ b/acapy_agent/anoncreds/revocation/recover.py @@ -31,7 +31,6 @@ class RevocRecoveryException(Exception): async def fetch_txns(genesis_txns, registry_id): """Fetch tails file and revocation registry information.""" - try: vdr_module = importlib.import_module("indy_vdr") credx_module = importlib.import_module("indy_credx") @@ -88,7 +87,6 @@ async def generate_ledger_rrrecovery_txn( genesis_txns, registry_id, set_revoked, cred_def, rev_reg_def_private ): """Generate a new ledger accum entry, based on wallet vs ledger revocation state.""" - new_delta = None ledger_data = await fetch_txns(genesis_txns, registry_id) diff --git a/acapy_agent/anoncreds/revocation/revocation.py b/acapy_agent/anoncreds/revocation/revocation.py index fc32f3fc2c..eb23352205 100644 --- a/acapy_agent/anoncreds/revocation/revocation.py +++ b/acapy_agent/anoncreds/revocation/revocation.py @@ -457,7 +457,6 @@ async def create_and_register_revocation_list( async def store_revocation_registry_list(self, result: RevListResult) -> None: """Store a revocation registry list.""" - identifier = result.job_id or result.rev_reg_def_id if not identifier: raise AnonCredsRevocationError( diff --git a/acapy_agent/anoncreds/routes/__init__.py b/acapy_agent/anoncreds/routes/__init__.py index 57e02b29d0..2d0f62bcf0 100644 --- a/acapy_agent/anoncreds/routes/__init__.py +++ b/acapy_agent/anoncreds/routes/__init__.py @@ -22,7 +22,6 @@ async def register(app: web.Application) -> None: """Register all AnonCreds routes.""" - # Register schema routes await register_schema_routes(app) @@ -38,7 +37,6 @@ async def register(app: web.Application) -> None: def post_process_routes(app: web.Application) -> None: """Post-process all routes for swagger documentation.""" - # Post-process schema routes post_process_schema_routes(app) diff --git a/acapy_agent/anoncreds/routes/common/utils.py b/acapy_agent/anoncreds/routes/common/utils.py index 8ec88fbc25..2ec55703d6 100644 --- a/acapy_agent/anoncreds/routes/common/utils.py +++ b/acapy_agent/anoncreds/routes/common/utils.py @@ -23,6 +23,7 @@ async def get_revocation_registry_definition_or_404( Raises: web.HTTPNotFound: If the revocation registry definition is not found web.HTTPInternalServerError: If there's an error retrieving the definition + """ context: AdminRequestContext = request["context"] profile = context.profile @@ -53,6 +54,7 @@ async def get_request_body_with_profile_check( Returns: Tuple of (context, profile, body, options) + """ context: AdminRequestContext = request["context"] profile = context.profile diff --git a/acapy_agent/anoncreds/routes/cred_defs/routes.py b/acapy_agent/anoncreds/routes/cred_defs/routes.py index 50728096ea..d654d663a4 100644 --- a/acapy_agent/anoncreds/routes/cred_defs/routes.py +++ b/acapy_agent/anoncreds/routes/cred_defs/routes.py @@ -152,7 +152,6 @@ async def cred_defs_get(request: web.BaseRequest): async def register(app: web.Application) -> None: """Register routes.""" - app.add_routes( [ web.post("/anoncreds/credential-definition", cred_def_post), @@ -172,7 +171,6 @@ async def register(app: web.Application) -> None: def post_process_routes(app: web.Application) -> None: """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/anoncreds/routes/revocation/credentials/routes.py b/acapy_agent/anoncreds/routes/revocation/credentials/routes.py index 691aaa3791..c24326bf29 100644 --- a/acapy_agent/anoncreds/routes/revocation/credentials/routes.py +++ b/acapy_agent/anoncreds/routes/revocation/credentials/routes.py @@ -190,7 +190,6 @@ async def register(app: web.Application) -> None: def post_process_routes(app: web.Application) -> None: """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/anoncreds/routes/revocation/lists/routes.py b/acapy_agent/anoncreds/routes/revocation/lists/routes.py index f1fda87ce1..aa02fb256a 100644 --- a/acapy_agent/anoncreds/routes/revocation/lists/routes.py +++ b/acapy_agent/anoncreds/routes/revocation/lists/routes.py @@ -51,7 +51,6 @@ async def rev_list_post(request: web.BaseRequest): async def register(app: web.Application) -> None: """Register routes.""" - app.add_routes( [ web.post("/anoncreds/revocation-list", rev_list_post), diff --git a/acapy_agent/anoncreds/routes/revocation/registry/models.py b/acapy_agent/anoncreds/routes/revocation/registry/models.py index 229ab097d1..190a3eec0e 100644 --- a/acapy_agent/anoncreds/routes/revocation/registry/models.py +++ b/acapy_agent/anoncreds/routes/revocation/registry/models.py @@ -100,7 +100,6 @@ class RevRegId(OpenAPISchema): @validates_schema def validate_fields(self, data: dict, **kwargs) -> None: """Validate schema fields - must have either rr-id or cr-id.""" - rev_reg_id = data.get("rev_reg_id") cred_def_id = data.get("cred_def_id") diff --git a/acapy_agent/anoncreds/routes/revocation/registry/routes.py b/acapy_agent/anoncreds/routes/revocation/registry/routes.py index b18de2d639..9e3399e0bc 100644 --- a/acapy_agent/anoncreds/routes/revocation/registry/routes.py +++ b/acapy_agent/anoncreds/routes/revocation/registry/routes.py @@ -566,7 +566,6 @@ async def set_rev_reg_state(request: web.BaseRequest): async def register(app: web.Application) -> None: """Register routes.""" - app.add_routes( [ web.post("/anoncreds/revocation-registry-definition", rev_reg_def_post), @@ -619,7 +618,6 @@ async def register(app: web.Application) -> None: def post_process_routes(app: web.Application) -> None: """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/anoncreds/routes/revocation/tails/routes.py b/acapy_agent/anoncreds/routes/revocation/tails/routes.py index c8aa1f3a85..c51cf41f55 100644 --- a/acapy_agent/anoncreds/routes/revocation/tails/routes.py +++ b/acapy_agent/anoncreds/routes/revocation/tails/routes.py @@ -97,7 +97,6 @@ async def upload_tails_file_deprecated(request: web.BaseRequest): async def register(app: web.Application) -> None: """Register routes.""" - app.add_routes( [ web.put( diff --git a/acapy_agent/anoncreds/routes/schemas/routes.py b/acapy_agent/anoncreds/routes/schemas/routes.py index 406e001c64..8b421fae94 100644 --- a/acapy_agent/anoncreds/routes/schemas/routes.py +++ b/acapy_agent/anoncreds/routes/schemas/routes.py @@ -176,7 +176,6 @@ async def schemas_get(request: web.BaseRequest): async def register(app: web.Application) -> None: """Register routes.""" - app.add_routes( [ web.post("/anoncreds/schema", schemas_post), @@ -188,7 +187,6 @@ async def register(app: web.Application) -> None: def post_process_routes(app: web.Application) -> None: """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/anoncreds/util.py b/acapy_agent/anoncreds/util.py index 1557f54663..de5cb99190 100644 --- a/acapy_agent/anoncreds/util.py +++ b/acapy_agent/anoncreds/util.py @@ -23,8 +23,8 @@ def indy_client_dir(subpath: Optional[str] = None, create: bool = False) -> str: Args: subpath: subpath within indy-client structure create: whether to create subdirectory if absent - """ + """ home = Path.home() target_dir = join( home, diff --git a/acapy_agent/anoncreds/verifier.py b/acapy_agent/anoncreds/verifier.py index d0510c0c28..4f3c9d4422 100644 --- a/acapy_agent/anoncreds/verifier.py +++ b/acapy_agent/anoncreds/verifier.py @@ -52,6 +52,7 @@ def non_revoc_intervals(self, pres_req: dict, pres: dict, cred_defs: dict) -> li pres_req: presentation request pres: corresponding presentation cred_defs: credential definitions by cred def id + """ msgs = [] for req_proof_key, pres_key in { @@ -119,6 +120,7 @@ async def check_timestamps( pres_req: anoncreds proof request pres: anoncreds proof request rev_reg_defs: rev reg defs by rev reg id, augmented with transaction times + """ msgs = [] now = int(time()) @@ -449,8 +451,8 @@ async def verify_presentation( rev_reg_defs: revocation registry definitions rev_reg_entries: revocation registry entries rev_lists: revocation lists - """ + """ msgs = [] try: msgs += self.non_revoc_intervals(pres_req, pres, credential_definitions) diff --git a/acapy_agent/askar/didcomm/v2.py b/acapy_agent/askar/didcomm/v2.py index 4e00c0030e..bd060609e0 100644 --- a/acapy_agent/askar/didcomm/v2.py +++ b/acapy_agent/askar/didcomm/v2.py @@ -70,7 +70,6 @@ def ecdh_es_decrypt( recip_key: Key, ) -> bytes: """Decode a message with DIDComm v2 anonymous encryption.""" - alg_id = wrapper.protected.get("alg") if alg_id in ("ECDH-ES+A128KW", "ECDH-ES+A256KW"): wrap_alg = alg_id[8:] @@ -190,7 +189,6 @@ def ecdh_1pu_decrypt( sender_key: Key, ) -> Tuple[str, str, str]: """Decode a message with DIDComm v2 authenticated encryption.""" - alg_id = wrapper.protected.get("alg") if alg_id in ("ECDH-1PU+A128KW", "ECDH-1PU+A256KW"): wrap_alg = alg_id[9:] diff --git a/acapy_agent/cache/in_memory.py b/acapy_agent/cache/in_memory.py index e06358b1ad..49e85de580 100644 --- a/acapy_agent/cache/in_memory.py +++ b/acapy_agent/cache/in_memory.py @@ -68,5 +68,4 @@ async def clear(self, key: Text): async def flush(self): """Remove all items from the cache.""" - self._cache = {} diff --git a/acapy_agent/commands/upgrade.py b/acapy_agent/commands/upgrade.py index 30724597cf..355dbfef10 100644 --- a/acapy_agent/commands/upgrade.py +++ b/acapy_agent/commands/upgrade.py @@ -574,6 +574,7 @@ async def find_affected_issue_rev_reg_records( Args: session: The profile session to use + """ storage = session.inject(BaseStorage) rows = await storage.find_all_records( diff --git a/acapy_agent/config/argparse.py b/acapy_agent/config/argparse.py index 85703b853b..0d69331d15 100644 --- a/acapy_agent/config/argparse.py +++ b/acapy_agent/config/argparse.py @@ -2105,7 +2105,6 @@ class UpgradeGroup(ArgumentGroup): def add_arguments(self, parser: ArgumentParser): """Add ACA-Py upgrade process specific arguments to the parser.""" - parser.add_argument( "--upgrade-config-path", type=str, diff --git a/acapy_agent/config/banner.py b/acapy_agent/config/banner.py index efe06a5228..5d62861aae 100644 --- a/acapy_agent/config/banner.py +++ b/acapy_agent/config/banner.py @@ -56,6 +56,7 @@ def _lr_pad(self, content: str): Args: content: String content to pad + """ return f"{self.border}{self.border} {content} {self.border}{self.border}" diff --git a/acapy_agent/config/base.py b/acapy_agent/config/base.py index 644fbfd9e4..bcbeb37399 100644 --- a/acapy_agent/config/base.py +++ b/acapy_agent/config/base.py @@ -38,6 +38,7 @@ def get_bool(self, *var_names, default: Optional[bool] = None) -> Optional[bool] Args: var_names: A list of variable name alternatives default: The default value to return if none are defined + """ value = self.get_value(*var_names, default) if value is not None: @@ -51,6 +52,7 @@ def get_int(self, *var_names, default: Optional[int] = None) -> Optional[int]: Args: var_names: A list of variable name alternatives default: The default value to return if none are defined + """ value = self.get_value(*var_names, default) if value is not None: @@ -64,6 +66,7 @@ def get_str(self, *var_names, default: Optional[str] = None) -> Optional[str]: Args: var_names: A list of variable name alternatives default: The default value to return if none are defined + """ value = self.get_value(*var_names, default=default) if value is not None: diff --git a/acapy_agent/config/default_context.py b/acapy_agent/config/default_context.py index 1deea81cec..36d45934f4 100644 --- a/acapy_agent/config/default_context.py +++ b/acapy_agent/config/default_context.py @@ -109,7 +109,6 @@ async def bind_providers(self, context: InjectionContext): async def load_plugins(self, context: InjectionContext): """Set up plugin registry and load plugins.""" - LOGGER.debug("Initializing plugin registry") plugin_registry = PluginRegistry( blocklist=self.settings.get("blocked_plugins", []) diff --git a/acapy_agent/config/ledger.py b/acapy_agent/config/ledger.py index b0b183d68e..b6e0ce5849 100644 --- a/acapy_agent/config/ledger.py +++ b/acapy_agent/config/ledger.py @@ -59,7 +59,6 @@ async def fetch_genesis_from_url_or_file( async def get_genesis_transactions(settings: Settings) -> str: """Fetch genesis transactions if necessary.""" - LOGGER.debug("Getting genesis transactions from settings") txns = settings.get("ledger.genesis_transactions") LOGGER.debug("Genesis transactions from settings: %s", "found" if txns else "absent") @@ -78,7 +77,6 @@ async def get_genesis_transactions(settings: Settings) -> str: async def load_multiple_genesis_transactions_from_config(settings: Settings) -> None: """Fetch genesis transactions for multiple ledger configuration.""" - ledger_config_list = settings.get("ledger.ledger_config_list") ledger_txns_list = [] write_ledger_set = False @@ -138,7 +136,6 @@ async def ledger_config( profile: Profile, public_did: str, provision: bool = False ) -> bool: """Perform Indy ledger configuration.""" - LOGGER.debug( "Configuring ledger for profile %s and public_did %s", profile.name, public_did ) @@ -278,7 +275,6 @@ async def accept_taa( provision: bool = False, ) -> bool: """Perform TAA acceptance.""" - mechanisms = taa_info["aml_record"]["aml"] mechanism = None diff --git a/acapy_agent/config/logging/configurator.py b/acapy_agent/config/logging/configurator.py index a02cbb4851..0030f884d1 100644 --- a/acapy_agent/config/logging/configurator.py +++ b/acapy_agent/config/logging/configurator.py @@ -44,6 +44,7 @@ def load_resource(path: str, encoding: Optional[str] = None): Returns: file-like object: A file-like object representing the resource + """ components = path.rsplit(":", 1) try: @@ -132,7 +133,6 @@ def configure( :param multitenant: bool: (Default value = False) Optional flag if multitenant is enabled """ - write_to_log_file = log_file is not None or log_file == "" if multitenant: @@ -284,6 +284,7 @@ def print_banner( banner_length: (Default value = 40) Length of the banner border_character: (Default value = ":") Character to use in banner border + """ with Banner(border=border_character, length=banner_length) as banner: # Title diff --git a/acapy_agent/config/logging/timed_rotating_file_multi_process_handler.py b/acapy_agent/config/logging/timed_rotating_file_multi_process_handler.py index 00c0aaf3dd..1b3c9e8387 100644 --- a/acapy_agent/config/logging/timed_rotating_file_multi_process_handler.py +++ b/acapy_agent/config/logging/timed_rotating_file_multi_process_handler.py @@ -24,6 +24,7 @@ class TimedRotatingFileMultiProcessHandler(BaseRotatingHandler): References: - https://github.com/python/cpython/blob/main/Lib/logging/handlers.py - https://github.com/yorks/mpfhandler/blob/master/src/mpfhandler.py + """ def __init__( diff --git a/acapy_agent/config/plugin_settings.py b/acapy_agent/config/plugin_settings.py index 006df02de8..913ef48302 100644 --- a/acapy_agent/config/plugin_settings.py +++ b/acapy_agent/config/plugin_settings.py @@ -23,6 +23,7 @@ def __init__(self, values: Optional[Mapping[str, Any]] = None): Args: values: An optional dictionary of settings + """ self._values = {} if values: @@ -67,6 +68,7 @@ def get_value(self, *var_names: str, default: Optional[Any] = None): Args: var_names: A list of variable name alternatives default: The default value to return if none are defined + """ for k in var_names: if k in self._values: diff --git a/acapy_agent/config/settings.py b/acapy_agent/config/settings.py index 386e434a49..8b7787fe30 100644 --- a/acapy_agent/config/settings.py +++ b/acapy_agent/config/settings.py @@ -14,6 +14,7 @@ def __init__(self, values: Optional[Mapping[str, Any]] = None): Args: values: An optional dictionary of settings + """ self._values = {} if values: @@ -25,6 +26,7 @@ def get_value(self, *var_names, default=None): Args: var_names: A list of variable name alternatives default: The default value to return if none are defined + """ for k in var_names: if k in self._values: @@ -37,6 +39,7 @@ def set_value(self, var_name: str, value): Args: var_name: The name of the setting value: The value to assign + """ if not isinstance(var_name, str): raise TypeError("Setting name must be a string") @@ -50,6 +53,7 @@ def set_default(self, var_name: str, value): Args: var_name: The name of the setting value: The value to assign + """ if var_name not in self: self.set_value(var_name, value) @@ -59,6 +63,7 @@ def clear_value(self, var_name: str): Args: var_name: The name of the setting + """ if var_name in self._values: del self._values[var_name] diff --git a/acapy_agent/config/wallet.py b/acapy_agent/config/wallet.py index 2887701d92..a9e9cef77d 100644 --- a/acapy_agent/config/wallet.py +++ b/acapy_agent/config/wallet.py @@ -84,6 +84,7 @@ async def _replace_public_did_if_seed_mismatch( Returns: DIDInfo: Either the original DID info or a new one if replaced + """ if not wallet_seed: return public_did_info @@ -156,7 +157,6 @@ async def wallet_config( context: InjectionContext, provision: bool = False ) -> Tuple[Profile, DIDInfo]: """Initialize the root profile.""" - profile_manager = context.inject(ProfileManager) settings = context.settings diff --git a/acapy_agent/connections/base_manager.py b/acapy_agent/connections/base_manager.py index ecf8ddd8ab..5be1eedb76 100644 --- a/acapy_agent/connections/base_manager.py +++ b/acapy_agent/connections/base_manager.py @@ -92,13 +92,11 @@ def _key_info_to_multikey(key_info: KeyInfo) -> str: def long_did_peer_to_short(self, long_did: str) -> str: """Convert did:peer:4 long format to short format and return.""" - short_did_peer = long_to_short(long_did) return short_did_peer async def long_did_peer_4_to_short(self, long_dp4: str) -> str: """Convert did:peer:4 long format to short format and store in wallet.""" - async with self._profile.session() as session: wallet = session.inject(BaseWallet) long_dp4_info = await wallet.get_local_did(long_dp4) @@ -133,6 +131,7 @@ async def create_did_peer_4( Returns: DIDInfo: The new `DIDInfo` instance representing the created DID. + """ routing_keys: List[str] = [] if mediation_records: @@ -201,6 +200,7 @@ async def create_did_peer_2( Returns: DIDInfo: The new `DIDInfo` instance representing the created DID. + """ routing_keys: List[str] = [] if mediation_records: @@ -278,6 +278,7 @@ async def fetch_invitation_reuse_did( Returns: The `DIDInfo` instance, or "None" if no DID is found + """ did_info = None async with self._profile.session() as session: @@ -357,6 +358,7 @@ async def store_did_document(self, value: Union[DIDDoc, dict]): Args: value: The `DIDDoc` instance to persist + """ if isinstance(value, DIDDoc): did = value.did @@ -393,6 +395,7 @@ async def add_key_for_did(self, did: str, key: str): Args: did: The DID to associate with this key key: The verkey to be added + """ record = StorageRecord(self.RECORD_TYPE_DID_KEY, key, {"did": did, "key": key}) async with self._profile.session() as session: @@ -413,6 +416,7 @@ async def find_did_for_key(self, key: str) -> str: Args: key: The verkey to look up + """ async with self._profile.session() as session: storage: BaseStorage = session.inject(BaseStorage) @@ -425,6 +429,7 @@ async def remove_keys_for_did(self, did: str): Args: did: The DID for which to remove keys + """ async with self._profile.session() as session: storage: BaseStorage = session.inject(BaseStorage) @@ -500,6 +505,7 @@ async def resolve_invitation( Raises: BaseConnectionManagerError: If the public DID has no associated DIDComm services. + """ self._logger.debug("Resolving invitation for DID %s", did) doc, didcomm_services = await self.resolve_didcomm_services(did, service_accept) @@ -643,6 +649,7 @@ async def _fetch_connection_targets_for_invitation( Returns: Sequence[ConnectionTarget]: A list of `ConnectionTarget` objects representing the connection targets for the invitation. + """ assert invitation.services, "Schema requires services in invitation" oob_service_item = invitation.services[0] @@ -688,6 +695,7 @@ async def _fetch_targets_for_connection_in_progress( sender_verkey: The verkey we are using Returns: A list of `ConnectionTarget` objects + """ if ( connection.invitation_msg_id @@ -730,8 +738,8 @@ async def fetch_connection_targets( Args: connection: The connection record (with associated `DIDDoc`) used to generate the connection target - """ + """ if not connection.my_did: self._logger.debug("No local DID associated with connection") return [] @@ -768,6 +776,7 @@ async def get_connection_targets( Args: connection_id: The connection ID to search for connection: The connection record itself, if already available + """ if connection_id is None and connection is None: raise ValueError("Must supply either connection_id or connection") @@ -838,6 +847,7 @@ def diddoc_connection_targets( doc: The DID Document to create the target from sender_verkey: The verkey we are using their_label: The connection label they are using + """ if isinstance(doc, dict): doc = DIDDoc.deserialize(doc) @@ -868,6 +878,7 @@ async def fetch_did_document(self, did: str) -> Tuple[dict, StorageRecord]: Args: did: The DID to search for + """ async with self._profile.session() as session: storage = session.inject(BaseStorage) @@ -950,7 +961,6 @@ async def find_inbound_connection( The `ConnRecord` associated with the expanded message, if any """ - cache_key = None connection = None resolved = False @@ -1000,7 +1010,6 @@ async def resolve_inbound_connection( The `ConnRecord` associated with the expanded message, if any """ - receipt.sender_did = None if receipt.sender_verkey: try: diff --git a/acapy_agent/connections/models/conn_record.py b/acapy_agent/connections/models/conn_record.py index 2f751ffd83..6f56dccdbb 100644 --- a/acapy_agent/connections/models/conn_record.py +++ b/acapy_agent/connections/models/conn_record.py @@ -102,7 +102,6 @@ def rfc23(self): def rfc23strict(self, their_role: "ConnRecord.Role"): """Return RFC 23 (DID exchange protocol) nomenclature to role as per RFC.""" - if not their_role or self in ( ConnRecord.State.INIT, ConnRecord.State.COMPLETED, @@ -268,6 +267,7 @@ async def retrieve_by_did( my_did: One of our DIDs to filter by my_role: Filter connections by their role their_role: Filter connections by their role + """ tag_filter = {} if their_did: @@ -299,6 +299,7 @@ async def retrieve_by_did_peer_4( my_did: One of our DIDs to filter by my_role: Filter connections by their role their_role: Filter connections by their role + """ tag_filter = {} if their_did_long and their_did_short: @@ -332,6 +333,7 @@ async def retrieve_by_invitation_key( session: The active profile session invitation_key: The key on the originating invitation their_role: Filter by their role + """ tag_filter = { "invitation_key": invitation_key, @@ -358,6 +360,7 @@ async def retrieve_by_invitation_msg_id( session: The active profile session invitation_msg_id: Invitation message identifier their_role: Filter by their role + """ tag_filter = {"invitation_msg_id": invitation_msg_id} post_filter = { @@ -379,6 +382,7 @@ async def find_existing_connection( Args: session: The active profile session their_public_did: Inviter public DID (or did:peer) + """ tag_filter = {"their_public_did": their_public_did} conn_records = await cls.query( @@ -400,6 +404,7 @@ async def retrieve_by_request_id( session: The active profile session request_id: The ID of the originating connection request their_role: Filter by their role + """ tag_filter = {"request_id": request_id} if their_role: @@ -413,6 +418,7 @@ async def retrieve_by_alias(cls, session: ProfileSession, alias: str) -> "ConnRe Args: session: The active profile session alias: The alias of the connection + """ post_filter = {"alias": alias} return await cls.query(session, post_filter_positive=post_filter) @@ -427,6 +433,7 @@ async def attach_invitation( Args: session: The active profile session invitation: The invitation to relate to this connection record + """ assert self.connection_id record = StorageRecord( @@ -442,6 +449,7 @@ async def retrieve_invitation(self, session: ProfileSession) -> OOBInvitation: Args: session: The active profile session + """ assert self.connection_id storage = session.inject(BaseStorage) @@ -462,6 +470,7 @@ async def attach_request( Args: session: The active profile session request: The request to relate to this connection record + """ assert self.connection_id record = StorageRecord( @@ -480,6 +489,7 @@ async def retrieve_request( Args: session: The active profile session + """ assert self.connection_id storage: BaseStorage = session.inject(BaseStorage) @@ -509,6 +519,7 @@ async def post_save(self, session: ProfileSession, *args, **kwargs): session: The active profile session args: Additional positional arguments kwargs: Additional keyword arguments + """ await super().post_save(session, *args, **kwargs) @@ -583,6 +594,7 @@ async def metadata_set(self, session: ProfileSession, key: str, value: Any): session (ProfileSession): session used for storage key (str): key identifying metadata value (Any): value to set + """ assert self.connection_id value = json.dumps(value) @@ -607,6 +619,7 @@ async def metadata_delete(self, session: ProfileSession, key: str): Args: session (ProfileSession): session used for storage key (str): key of metadata to delete + """ assert self.connection_id storage: BaseStorage = session.inject(BaseStorage) diff --git a/acapy_agent/connections/models/connection_target.py b/acapy_agent/connections/models/connection_target.py index bc81adc42e..458f9463ef 100644 --- a/acapy_agent/connections/models/connection_target.py +++ b/acapy_agent/connections/models/connection_target.py @@ -40,6 +40,7 @@ def __init__( recipient_keys: A list of recipient keys routing_keys: A list of routing keys sender_key: A sender key + """ self.did = did self.endpoint = endpoint diff --git a/acapy_agent/connections/models/diddoc/diddoc.py b/acapy_agent/connections/models/diddoc/diddoc.py index 1075db62c4..542aa80683 100644 --- a/acapy_agent/connections/models/diddoc/diddoc.py +++ b/acapy_agent/connections/models/diddoc/diddoc.py @@ -50,7 +50,6 @@ def __init__(self, did: Optional[str] = None) -> None: ValueError: for bad input DID. """ - self._did = canon_did(did) if did else None # allow specification post-hoc self._pubkey = {} self._service = {} @@ -58,7 +57,6 @@ def __init__(self, did: Optional[str] = None) -> None: @property def did(self) -> str: """Accessor for DID.""" - return self._did @did.setter @@ -72,25 +70,21 @@ def did(self, value: str) -> None: ValueError: for bad input DID. """ - self._did = canon_did(value) if value else None @property def pubkey(self) -> dict: """Accessor for public keys by identifier.""" - return self._pubkey @property def authnkey(self) -> dict: """Accessor for public keys marked as authentication keys, by identifier.""" - return {k: self._pubkey[k] for k in self._pubkey if self._pubkey[k].authn} @property def service(self) -> dict: """Accessor for services by identifier.""" - return self._service def set(self, item: Union[Service, PublicKey]) -> "DIDDoc": @@ -105,7 +99,6 @@ def set(self, item: Union[Service, PublicKey]) -> "DIDDoc": Returns: the current DIDDoc """ - if isinstance(item, Service): self.service[item.id] = item elif isinstance(item, PublicKey): @@ -123,6 +116,7 @@ def _normalize_routing_keys(service: dict) -> dict: service: service dict Returns: service dict with routing keys normalized + """ routing_keys = service.get("routingKeys") if routing_keys: @@ -170,7 +164,6 @@ def to_json(self) -> str: json representation of current DIDDoc """ - return json.dumps(self.serialize()) def add_service_pubkeys( @@ -189,7 +182,6 @@ def add_service_pubkeys( Returns: list of public keys from the document service specification """ - rv = [] for tag in [tags] if isinstance(tags, str) else list(tags): for svc_key in service.get(tag, {}): @@ -241,7 +233,6 @@ def deserialize(cls, did_doc: dict) -> "DIDDoc": Returns: DIDDoc from input json """ - rv = None if "id" in did_doc: rv = DIDDoc(did_doc["id"]) @@ -325,15 +316,12 @@ def from_json(cls, did_doc_json: str) -> "DIDDoc": Returns: DIDDoc from input json """ - return cls.deserialize(json.loads(did_doc_json)) def __str__(self) -> str: """Return string representation for abbreviated display.""" - return f"DIDDoc({self.did})" def __repr__(self) -> str: """Format DIDDoc for logging.""" - return f"" diff --git a/acapy_agent/connections/models/diddoc/publickey.py b/acapy_agent/connections/models/diddoc/publickey.py index c247a9de04..d07b6837d5 100644 --- a/acapy_agent/connections/models/diddoc/publickey.py +++ b/acapy_agent/connections/models/diddoc/publickey.py @@ -52,7 +52,6 @@ def get(val: str) -> "PublicKeyType": Returns: the public key type """ - for pktype in PublicKeyType: if val in (pktype.ver_type, pktype.authn_type): return pktype @@ -61,19 +60,16 @@ def get(val: str) -> "PublicKeyType": @property def ver_type(self) -> str: """Accessor for the verification type identifier.""" - return self.value.ver_type @property def authn_type(self) -> str: """Accessor for the authentication type identifier.""" - return self.value.authn_type @property def specifier(self) -> str: """Accessor for the value specifier.""" - return self.value.specifier def specification(self, val: str) -> str: @@ -85,7 +81,6 @@ def specification(self, val: str) -> str: Returns: dict mapping applicable specifier to input value """ - return {self.specifier: val} @@ -119,7 +114,6 @@ def __init__( ValueError: on any bad input DID. """ - self._did = canon_did(did) self._id = canon_ref(self._did, ident) self._value = value @@ -130,31 +124,26 @@ def __init__( @property def did(self) -> str: """Accessor for the DID.""" - return self._did @property def id(self) -> str: """Accessor for the public key identifier.""" - return self._id @property def type(self) -> PublicKeyType: """Accessor for the public key type.""" - return self._type @property def value(self) -> str: """Accessor for the public key value.""" - return self._value @property def controller(self) -> str: """Accessor for the controller DID.""" - return self._controller @property @@ -163,7 +152,6 @@ def authn(self) -> bool: Returns: whether public key is marked as having DID authentication privilege """ - return self._authn @authn.setter @@ -172,13 +160,12 @@ def authn(self, value: bool) -> None: Args: value: authentication marker - """ + """ self._authn = value def to_dict(self) -> dict: """Return dict representation of public key to embed in DID document.""" - return { "id": self.id, "type": str(self.type.ver_type), @@ -188,7 +175,6 @@ def to_dict(self) -> dict: def __repr__(self) -> str: """Return string representation of the public key instance.""" - return "PublicKey({}, {}, {}, {}, {}, {})".format( self.did, self.id, self.value, self.type, self.controller, self.authn ) diff --git a/acapy_agent/connections/models/diddoc/service.py b/acapy_agent/connections/models/diddoc/service.py index 28ee50a0e3..28b1509d63 100644 --- a/acapy_agent/connections/models/diddoc/service.py +++ b/acapy_agent/connections/models/diddoc/service.py @@ -57,7 +57,6 @@ def __init__( ValueError: on bad input controller DID """ - self._did = canon_did(did) self._id = canon_ref(self._did, ident, ";") self._type = typ @@ -75,48 +74,40 @@ def __init__( @property def did(self) -> str: """Accessor for the DID value.""" - return self._did @property def id(self) -> str: """Accessor for the service identifier.""" - return self._id @property def type(self) -> str: """Accessor for the service type.""" - return self._type @property def recip_keys(self) -> List[PublicKey]: """Accessor for the recipient keys.""" - return self._recip_keys @property def routing_keys(self) -> List[str]: """Accessor for the routing keys.""" - return self._routing_keys @property def endpoint(self) -> str: """Accessor for the endpoint value.""" - return self._endpoint @property def priority(self) -> int: """Accessor for the priority value.""" - return self._priority def to_dict(self) -> dict: """Return dict representation of service to embed in DID document.""" - rv = {"id": self.id, "type": self.type, "priority": self.priority} if self.recip_keys: rv["recipientKeys"] = [k.value for k in self.recip_keys] diff --git a/acapy_agent/connections/models/diddoc/util.py b/acapy_agent/connections/models/diddoc/util.py index 6a7fc9671e..0b822b0a75 100644 --- a/acapy_agent/connections/models/diddoc/util.py +++ b/acapy_agent/connections/models/diddoc/util.py @@ -32,8 +32,8 @@ def resource(ref: str, delimiter: Optional[str] = None) -> str: ref: reference delimiter: delimiter character (default None maps to '#', or ';' introduces identifiers) - """ + """ return ref.split(delimiter if delimiter else "#")[0] @@ -47,7 +47,6 @@ def canon_did(uri: str) -> str: ValueError: for invalid input. """ - if ok_did(uri): return uri @@ -69,8 +68,8 @@ def canon_ref(did: str, ref: str, delimiter: Optional[str] = None): location in the DID doc delimiter: delimiter character marking fragment (default '#') or introducing identifier (';') against DID resource - """ + """ if not ok_did(did): raise ValueError("Bad DID {} cannot act as DID document identifier".format(did)) @@ -103,7 +102,6 @@ def ok_did(token: str) -> bool: Returns: whether input token looks like a valid schema identifier """ - try: return len(b58decode(token)) == 16 if token else False except ValueError: diff --git a/acapy_agent/connections/routes.py b/acapy_agent/connections/routes.py index 964538f142..8864aeccd1 100644 --- a/acapy_agent/connections/routes.py +++ b/acapy_agent/connections/routes.py @@ -437,6 +437,7 @@ async def connections_remove(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] connection_id = request.match_info["conn_id"] @@ -507,7 +508,6 @@ async def connections_create_static(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/connections", connections_list, allow_head=False), @@ -531,7 +531,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/core/conductor.py b/acapy_agent/core/conductor.py index ce12101202..9d61f42b8a 100644 --- a/acapy_agent/core/conductor.py +++ b/acapy_agent/core/conductor.py @@ -652,7 +652,6 @@ def inbound_message_router( can_respond: If the session supports return routing """ - if message.receipt.direct_response_requested and not can_respond: LOGGER.warning( "Direct response requested, but not supported by transport: %s", @@ -732,6 +731,7 @@ async def outbound_message_router( profile: The active profile for the request outbound: An outbound message to be sent inbound: The inbound message that produced this response, if available + """ status: OutboundSendStatus = await self._outbound_message_router( profile=profile, outbound=outbound, inbound=inbound @@ -751,6 +751,7 @@ async def _outbound_message_router( profile: The active profile for the request outbound: An outbound message to be sent inbound: The inbound message that produced this response, if available + """ if not outbound.target and outbound.reply_to_verkey: if not outbound.reply_from_verkey and inbound: @@ -784,6 +785,7 @@ async def queue_outbound( profile: The active profile outbound: The outbound message to be sent inbound: The inbound message that produced this response, if available + """ has_target = outbound.target or outbound.target_list @@ -851,6 +853,7 @@ def webhook_router( endpoint: The endpoint of the webhook target max_attempts: The maximum number of attempts metadata: Additional metadata associated with the payload + """ try: self.outbound_transport_manager.enqueue_webhook( diff --git a/acapy_agent/core/dispatcher.py b/acapy_agent/core/dispatcher.py index dfa476e444..ad0addde9d 100644 --- a/acapy_agent/core/dispatcher.py +++ b/acapy_agent/core/dispatcher.py @@ -115,7 +115,6 @@ def queue_message( A pending task instance resolving to the handler task """ - if ( self.profile.settings.get("experiment.didcomm_v2") and inbound_message.receipt.didcomm_version == DIDCommVersion.v2 @@ -136,7 +135,6 @@ async def handle_v2_message( send_outbound: Coroutine, ): """Handle a DIDComm V2 message.""" - # send a DCV2 Problem Report here for testing, and to punt procotol handling down # the road a bit context = RequestContext(profile) @@ -367,6 +365,7 @@ async def create_outbound( Returns: OutboundMessage: The created outbound message. + """ context = self._context() if not context: @@ -391,6 +390,7 @@ async def send_outbound( Args: message: The `OutboundMessage` to be sent kwargs: Additional keyword arguments + """ context = self._context() if not context: @@ -421,6 +421,7 @@ async def send_webhook(self, topic: str, payload: dict): Args: topic: the webhook topic identifier payload: the webhook payload value + """ warnings.warn( "responder.send_webhook is deprecated; please use the event bus instead.", diff --git a/acapy_agent/core/oob_processor.py b/acapy_agent/core/oob_processor.py index 15f4028837..f303f88473 100644 --- a/acapy_agent/core/oob_processor.py +++ b/acapy_agent/core/oob_processor.py @@ -300,7 +300,6 @@ async def handle_message( their_service: Optional[ServiceDecorator] = None, ): """Message handler for inbound messages.""" - supported_types = [ CREDENTIAL_OFFER, CRED_20_OFFER, diff --git a/acapy_agent/core/plugin_registry.py b/acapy_agent/core/plugin_registry.py index 685ef86898..a32aa58a64 100644 --- a/acapy_agent/core/plugin_registry.py +++ b/acapy_agent/core/plugin_registry.py @@ -35,7 +35,6 @@ def plugins(self) -> Sequence[ModuleType]: def validate_version(self, version_list, module_name): """Validate version dict format.""" - is_list = isinstance(version_list, list) # Must be a list diff --git a/acapy_agent/core/profile.py b/acapy_agent/core/profile.py index 8c52e419fe..20a59be06c 100644 --- a/acapy_agent/core/profile.py +++ b/acapy_agent/core/profile.py @@ -286,8 +286,8 @@ async def emit_event(self, topic: str, payload: Any, force_emit: bool = False): payload (Any): The payload of the event. force_emit (bool, optional): If True, force the event to be emitted even if there is an active transaction. Defaults to False. - """ + """ if force_emit or (not self.is_transaction): # just emit directly await self.profile.notify(topic, payload) diff --git a/acapy_agent/core/protocol_registry.py b/acapy_agent/core/protocol_registry.py index 18a1623015..08fe4f9a46 100644 --- a/acapy_agent/core/protocol_registry.py +++ b/acapy_agent/core/protocol_registry.py @@ -60,7 +60,6 @@ class ProtocolRegistry: def __init__(self): """Initialize a `ProtocolRegistry` instance.""" - self._definitions: Dict[str, ProtocolDefinition] = {} self._type_to_message_cls: Dict[str, Union[DeferLoad, type]] = {} diff --git a/acapy_agent/did/did_key.py b/acapy_agent/did/did_key.py index b62ce1cc14..139fbb33e2 100644 --- a/acapy_agent/did/did_key.py +++ b/acapy_agent/did/did_key.py @@ -31,7 +31,6 @@ def __init__(self, public_key: bytes, key_type: KeyType) -> None: @classmethod def from_public_key(cls, public_key: bytes, key_type: KeyType) -> "DIDKey": """Initialize new DIDKey instance from public key and key type.""" - return cls(public_key, key_type) @classmethod @@ -131,7 +130,6 @@ def construct_did_key_bls12381g2(did_key: "DIDKey") -> dict: dict: The bls12381g2 did:key did document """ - return construct_did_signature_key_base( id=did_key.did, key_id=did_key.key_id, @@ -154,7 +152,6 @@ def construct_did_key_bls12381g1(did_key: "DIDKey") -> dict: dict: The bls12381g1 did:key did document """ - return construct_did_signature_key_base( id=did_key.did, key_id=did_key.key_id, @@ -177,7 +174,6 @@ def construct_did_key_bls12381g1g2(did_key: "DIDKey") -> dict: dict: The bls12381g1g2 did:key did document """ - g1_public_key = did_key.public_key[:48] g2_public_key = did_key.public_key[48:] @@ -222,7 +218,6 @@ def construct_did_key_x25519(did_key: "DIDKey") -> dict: dict: The x25519 did:key did document """ - return { "@context": DID_V1_CONTEXT_URL, "id": did_key.did, @@ -289,7 +284,6 @@ def construct_did_key_p256(did_key: "DIDKey") -> dict: dict: The p256 did:key did document """ - did_doc = construct_did_signature_key_base( id=did_key.did, key_id=did_key.key_id, @@ -317,7 +311,6 @@ def construct_did_signature_key_base( May not be suitable for all did key types """ - return { "@context": [DID_V1_CONTEXT_URL] + (extra_context or []), "id": id, diff --git a/acapy_agent/holder/routes.py b/acapy_agent/holder/routes.py index 8dfb0f3785..db0748621a 100644 --- a/acapy_agent/holder/routes.py +++ b/acapy_agent/holder/routes.py @@ -562,7 +562,6 @@ async def w3c_creds_list(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/credential/{credential_id}", credentials_get, allow_head=False), @@ -591,7 +590,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/indy/credx/holder.py b/acapy_agent/indy/credx/holder.py index 0beebe9b14..3e53e3f27b 100644 --- a/acapy_agent/indy/credx/holder.py +++ b/acapy_agent/indy/credx/holder.py @@ -267,7 +267,6 @@ async def get_credentials(self, *, offset: int, limit: int, wql: dict): wql: wql query dict """ - result = [] try: @@ -413,6 +412,7 @@ async def credential_revoked( Returns: bool: True if the credential is revoked, False otherwise. + """ cred = await self._get_credential(credential_id) rev_reg_id = cred.rev_reg_id @@ -490,7 +490,6 @@ async def create_presentation( rev_states: Indy format revocation states JSON """ - creds: Dict[str, Credential] = {} def get_rev_state(cred_id: str, detail: dict): diff --git a/acapy_agent/indy/credx/issuer.py b/acapy_agent/indy/credx/issuer.py index 4dc09c2ba2..c18bf85f64 100644 --- a/acapy_agent/indy/credx/issuer.py +++ b/acapy_agent/indy/credx/issuer.py @@ -101,6 +101,7 @@ async def credential_definition_in_wallet( Args: credential_definition_id: The credential definition ID to check + """ try: async with self._profile.session() as session: @@ -379,7 +380,6 @@ async def revoke_credentials( Tuple with the combined revocation delta, list of cred rev ids not revoked """ - delta = None failed_crids = set() max_attempt = 5 diff --git a/acapy_agent/indy/credx/verifier.py b/acapy_agent/indy/credx/verifier.py index 3f3ef06d78..9fa1c60c8d 100644 --- a/acapy_agent/indy/credx/verifier.py +++ b/acapy_agent/indy/credx/verifier.py @@ -42,8 +42,8 @@ async def verify_presentation( credential_definitions: credential definition data rev_reg_defs: revocation registry definitions rev_reg_entries: revocation registry entries - """ + """ accept_legacy_revocation = ( self.profile.settings.get("revocation.anoncreds_legacy_support", "accept") == "accept" diff --git a/acapy_agent/indy/holder.py b/acapy_agent/indy/holder.py index a8e0fe4886..e46a5aa7be 100644 --- a/acapy_agent/indy/holder.py +++ b/acapy_agent/indy/holder.py @@ -55,6 +55,7 @@ async def credential_revoked( Returns: bool: True if the credential is revoked, False otherwise. + """ @abstractmethod @@ -98,6 +99,7 @@ async def create_presentation( schemas: Indy formatted schemas JSON credential_definitions: Indy formatted credential definitions JSON rev_states: Indy format revocation states JSON + """ @abstractmethod diff --git a/acapy_agent/indy/issuer.py b/acapy_agent/indy/issuer.py index 102a84619c..382bc8b807 100644 --- a/acapy_agent/indy/issuer.py +++ b/acapy_agent/indy/issuer.py @@ -76,6 +76,7 @@ async def credential_definition_in_wallet( Args: credential_definition_id: The credential definition ID to check + """ @abstractmethod diff --git a/acapy_agent/indy/models/predicate.py b/acapy_agent/indy/models/predicate.py index d455e78d55..1a9c375fda 100644 --- a/acapy_agent/indy/models/predicate.py +++ b/acapy_agent/indy/models/predicate.py @@ -57,7 +57,6 @@ def math(self) -> str: @staticmethod def get(relation: str) -> "Predicate": """Return enum instance corresponding to input relation string.""" - for pred in Predicate: if relation.upper() in ( pred.value.fortran, @@ -75,8 +74,8 @@ def to_int(value: Any) -> int: Args: value: value to coerce - """ + """ if isinstance(value, (bool, int)): return int(value) return int(str(value)) # kick out floats diff --git a/acapy_agent/indy/models/pres_preview.py b/acapy_agent/indy/models/pres_preview.py index d9e740193e..114dc92f30 100644 --- a/acapy_agent/indy/models/pres_preview.py +++ b/acapy_agent/indy/models/pres_preview.py @@ -64,7 +64,6 @@ def __init__( def __eq__(self, other): """Equality comparator.""" - if canon(self.name) != canon(other.name): return False # distinct attribute names modulo canonicalization @@ -178,7 +177,6 @@ def list_plain(plain: dict, cred_def_id: str, referent: Optional[str] = None): @property def posture(self) -> "IndyPresAttrSpec.Posture": """Attribute posture: self-attested, revealed claim, or unrevealed claim.""" - if self.cred_def_id: if self.value: return IndyPresAttrSpec.Posture.REVEALED_CLAIM @@ -190,12 +188,10 @@ def posture(self) -> "IndyPresAttrSpec.Posture": def b64_decoded_value(self) -> str: """Value, base64-decoded if applicable.""" - return b64_to_str(self.value) if self.value and self.mime_type else self.value def satisfies(self, pred_spec: IndyPresPredSpec): """Whether current specified attribute satisfies input specified predicate.""" - return bool( self.value and not self.mime_type @@ -209,7 +205,6 @@ def satisfies(self, pred_spec: IndyPresPredSpec): def __eq__(self, other): """Equality comparator.""" - if canon(self.name) != canon(other.name): return False # distinct attribute names @@ -290,7 +285,6 @@ def __init__( @property def _type(self): """Accessor for message type.""" - return DIDCommPrefix.qualify_current(IndyPresPreview.Meta.message_type) def has_attr_spec(self, cred_def_id: str, name: str, value: str) -> bool: @@ -305,7 +299,6 @@ def has_attr_spec(self, cred_def_id: str, name: str, value: str) -> bool: Whether preview contains matching attribute specification. """ - return any( canon(a.name) == canon(name) and a.value in (value, None) @@ -340,7 +333,6 @@ async def indy_proof_request( def non_revoc(cred_def_id: str) -> IndyNonRevocationInterval: """Non-revocation interval to use for input cred def id.""" - nonlocal epoch_now nonlocal non_revoc_intervals @@ -467,7 +459,6 @@ def non_revoc(cred_def_id: str) -> IndyNonRevocationInterval: def __eq__(self, other): """Equality comparator.""" - for part in vars(self): if getattr(self, part, None) != getattr(other, part, None): return False diff --git a/acapy_agent/indy/models/revocation.py b/acapy_agent/indy/models/revocation.py index 14c5617709..6869b25d79 100644 --- a/acapy_agent/indy/models/revocation.py +++ b/acapy_agent/indy/models/revocation.py @@ -29,7 +29,6 @@ class Meta: def __init__(self, z: Optional[str] = None): """Initialize.""" - self.z = z @@ -60,7 +59,6 @@ class Meta: def __init__(self, accum_key: Optional[IndyRevRegDefValuePublicKeysAccumKey] = None): """Initialize.""" - self.accum_key = accum_key @@ -161,7 +159,6 @@ def __init__( value: Optional[IndyRevRegDefValue] = None, ): """Initialize.""" - self.ver = ver self.id_ = id_ self.revoc_def_type = revoc_def_type @@ -279,7 +276,6 @@ def __init__( self, ver: Optional[str] = None, value: Optional[IndyRevRegEntryValue] = None ): """Initialize.""" - self.ver = ver self.value = value diff --git a/acapy_agent/indy/util.py b/acapy_agent/indy/util.py index c42b83fab7..63c4432946 100644 --- a/acapy_agent/indy/util.py +++ b/acapy_agent/indy/util.py @@ -19,8 +19,8 @@ def indy_client_dir(subpath: Optional[str] = None, create: bool = False) -> str: Args: subpath: subpath within indy-client structure create: whether to create subdirectory if absent - """ + """ home = Path.home() target_dir = join( home, diff --git a/acapy_agent/indy/verifier.py b/acapy_agent/indy/verifier.py index f707c64c14..7e6a572b41 100644 --- a/acapy_agent/indy/verifier.py +++ b/acapy_agent/indy/verifier.py @@ -120,6 +120,7 @@ async def check_timestamps( pres_req: indy proof request pres: indy proof request rev_reg_defs: rev reg defs by rev reg id, augmented with transaction times + """ msgs = [] now = int(time()) @@ -396,4 +397,5 @@ def verify_presentation( credential_definitions: credential definition data rev_reg_defs: revocation registry definitions rev_reg_entries: revocation registry entries + """ diff --git a/acapy_agent/ledger/base.py b/acapy_agent/ledger/base.py index d0c67f056d..47f902c3dc 100644 --- a/acapy_agent/ledger/base.py +++ b/acapy_agent/ledger/base.py @@ -60,6 +60,7 @@ async def get_key_for_did(self, did: str) -> str: Args: did: The DID to look up on the ledger or in the cache + """ @abstractmethod @@ -71,6 +72,7 @@ async def get_endpoint_for_did( Args: did: The DID to look up on the ledger or in the cache endpoint_type: The type of the endpoint (default 'endpoint') + """ @abstractmethod @@ -79,6 +81,7 @@ async def get_all_endpoints_for_did(self, did: str) -> dict: Args: did: The DID to look up on the ledger or in the cache + """ async def _construct_attr_json( @@ -95,8 +98,8 @@ async def _construct_attr_json( endpoint: The endpoint address endpoint_type: The type of the endpoint routing_keys: List of routing_keys if mediator is present - """ + """ if not routing_keys: routing_keys = [] @@ -131,6 +134,7 @@ async def update_endpoint_for_did( write_ledger: Flag to write the endpoint to the ledger endorser_did: Optional DID of the endorser routing_keys: List of routing_keys if mediator is present + """ @abstractmethod @@ -152,6 +156,7 @@ async def register_nym( role: For permissioned ledgers, what role should the new DID have. write_ledger: Flag to write the nym to the ledger endorser_did: Optional DID of the endorser + """ @abstractmethod @@ -160,6 +165,7 @@ async def get_nym_role(self, did: str): Args: did: DID to register on the ledger. + """ @abstractmethod @@ -172,6 +178,7 @@ async def rotate_public_did_keypair(self, next_seed: Optional[str] = None) -> No Args: next_seed: seed for incoming ed25519 keypair (default random) + """ @abstractmethod @@ -288,7 +295,6 @@ async def create_and_send_schema( endorser_did: Optional DID of the endorser """ - public_info = await self.get_wallet_public_did() if not public_info: raise BadLedgerRequestError("Cannot publish schema without a public DID") @@ -799,6 +805,7 @@ def get(token: Union[str, int] = None) -> "Role": Args: token: token identifying role to indy-sdk: "STEWARD", "TRUSTEE", "ENDORSER", "" or None + """ if token is None: return Role.USER @@ -818,10 +825,8 @@ def to_indy_num_str(self) -> str: Recall that None signifies USER and "" signifies a role undergoing reset. """ - return str(self.value[0]) if isinstance(self.value[0], int) else self.value[0] def token(self) -> str: """Return token identifying role to indy-sdk.""" - return self.value[0] if self in (Role.USER, Role.ROLE_REMOVE) else self.name diff --git a/acapy_agent/ledger/indy_vdr.py b/acapy_agent/ledger/indy_vdr.py index 9763c492a1..d6dcf17c79 100644 --- a/acapy_agent/ledger/indy_vdr.py +++ b/acapy_agent/ledger/indy_vdr.py @@ -88,6 +88,7 @@ def __init__( genesis_transactions: The ledger genesis transaction as a string read_only: Prevent any ledger write operations socks_proxy: Specifies socks proxy for ZMQ to connect to ledger pool + """ self.ref_count = 0 self.ref_lock = asyncio.Lock() @@ -132,7 +133,6 @@ def genesis_txns(self) -> str: async def create_pool_config(self, genesis_transactions: str, recreate: bool = False): """Create the pool ledger configuration.""" - cfg_pool = self.cfg_path.joinpath(self.name) cfg_pool.mkdir(exist_ok=True) genesis = _normalize_txns(genesis_transactions) @@ -166,7 +166,6 @@ async def create_pool_config(self, genesis_transactions: str, recreate: bool = F async def open(self): """Open the pool ledger, creating it if necessary.""" - if self.init_config: await self.create_pool_config(self.genesis_txns_cache, recreate=True) self.init_config = False @@ -258,6 +257,7 @@ def __init__( Args: pool: The pool instance handling the raw ledger connection profile: The active profile instance + """ self.pool = pool self.profile = profile @@ -323,7 +323,6 @@ async def _submit( write_ledger: whether to write the request to the ledger """ - if not self.pool_handle: raise ClosedPoolError( f"Cannot sign and submit request to closed pool '{self.pool_name}'" @@ -460,7 +459,6 @@ async def fetch_schema_by_id(self, schema_id: str) -> dict: Indy schema dict """ - public_info = await self.get_wallet_public_did() public_did = public_info.did if public_info else None @@ -582,7 +580,6 @@ async def fetch_credential_definition( credential_definition_id: The cred def id of the cred def to fetch """ - public_info = await self.get_wallet_public_did() public_did = public_info.did if public_info else None @@ -620,8 +617,8 @@ async def credential_definition_id2schema_id(self, credential_definition_id): Args: credential_definition_id: The identifier of the credential definition from which to identify a schema - """ + """ # scrape schema id or sequence number from cred def id tokens = credential_definition_id.split(":") if len(tokens) == 8: # node protocol >= 1.4: cred def id has 5 or 8 tokens @@ -636,6 +633,7 @@ async def get_key_for_did(self, did: str) -> Optional[str]: Args: did: The DID to look up on the ledger or in the cache + """ nym = strip_did_prefix(did) public_info = await self.get_wallet_public_did() @@ -659,6 +657,7 @@ async def get_all_endpoints_for_did(self, did: str) -> dict: Args: did: The DID to look up on the ledger or in the cache + """ nym = strip_did_prefix(did) public_info = await self.get_wallet_public_did() @@ -688,8 +687,8 @@ async def get_endpoint_for_did( Args: did: The DID to look up on the ledger or in the cache endpoint_type: The type of the endpoint. If none given, returns all - """ + """ if not endpoint_type: endpoint_type = EndpointType.ENDPOINT nym = strip_did_prefix(did) @@ -730,6 +729,7 @@ async def update_endpoint_for_did( write_ledger: Whether to write the endpoint to the ledger endorser_did: DID of the endorser to use for the transaction routing_keys: List of routing keys + """ routing_keys = routing_keys or [] # Ensure list type if None was passed public_info = await self.get_wallet_public_did() @@ -807,6 +807,7 @@ async def register_nym( role: For permissioned ledgers, what role should the new DID have. write_ledger: Whether to write the nym to the ledger. endorser_did: DID of the endorser to use for the transaction. + """ if self.read_only: raise LedgerError( @@ -846,6 +847,7 @@ async def get_nym_role(self, did: str) -> Role: Args: did: DID to query for role on the ledger. + """ public_info = await self.get_wallet_public_did() public_did = public_info.did if public_info else None @@ -889,6 +891,7 @@ async def rotate_public_did_keypair(self, next_seed: Optional[str] = None) -> No Args: next_seed: seed for incoming ed25519 keypair (default random) + """ # generate new key async with self.profile.transaction() as txn: diff --git a/acapy_agent/ledger/merkel_validation/utils.py b/acapy_agent/ledger/merkel_validation/utils.py index 395f4ce1cd..65ad64f71e 100644 --- a/acapy_agent/ledger/merkel_validation/utils.py +++ b/acapy_agent/ledger/merkel_validation/utils.py @@ -40,7 +40,6 @@ def unpack_to_nibbles(bindata): bindata: binary packed from nibbles """ - o = bin_to_nibbles(bindata) flags = o[0] if flags & 2: diff --git a/acapy_agent/ledger/multiple_ledger/indy_vdr_manager.py b/acapy_agent/ledger/multiple_ledger/indy_vdr_manager.py index 4b34f24126..427b7112dd 100644 --- a/acapy_agent/ledger/multiple_ledger/indy_vdr_manager.py +++ b/acapy_agent/ledger/multiple_ledger/indy_vdr_manager.py @@ -106,6 +106,7 @@ async def _get_ledger_by_did( Return: (str, IndyVdrLedger, bool) or None + """ try: indy_vdr_ledger = None diff --git a/acapy_agent/ledger/multiple_ledger/manager_provider.py b/acapy_agent/ledger/multiple_ledger/manager_provider.py index 052065993f..6449c49d60 100644 --- a/acapy_agent/ledger/multiple_ledger/manager_provider.py +++ b/acapy_agent/ledger/multiple_ledger/manager_provider.py @@ -39,7 +39,6 @@ def __init__(self, root_profile): def provide(self, settings: BaseSettings, injector: BaseInjector): """Create the multiple Indy ledger manager instance.""" - backend_name = self.root_profile.BACKEND_NAME if backend_name in ("askar", "askar-anoncreds"): manager_type = "single-wallet-askar" diff --git a/acapy_agent/ledger/routes.py b/acapy_agent/ledger/routes.py index c84638ee9e..6c60f7ed98 100644 --- a/acapy_agent/ledger/routes.py +++ b/acapy_agent/ledger/routes.py @@ -268,6 +268,7 @@ async def register_ledger_nym(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] @@ -428,6 +429,7 @@ async def get_nym_role(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] @@ -475,6 +477,7 @@ async def rotate_public_did_keypair(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] async with context.profile.session() as session: @@ -505,6 +508,7 @@ async def get_did_verkey(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] @@ -554,6 +558,7 @@ async def get_did_endpoint(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] @@ -819,7 +824,6 @@ async def get_ledger_config(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.post("/ledger/register-nym", register_ledger_nym), @@ -843,7 +847,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/messaging/agent_message.py b/acapy_agent/messaging/agent_message.py index 4a9a346a0f..ee1ad127da 100644 --- a/acapy_agent/messaging/agent_message.py +++ b/acapy_agent/messaging/agent_message.py @@ -288,6 +288,7 @@ def _service(self, val: Union[ServiceDecorator, dict]): Args: val: ServiceDecorator or dict to set as the service + """ if val is None: self._decorators.pop("service", None) @@ -310,6 +311,7 @@ def _thread(self, val: Union[ThreadDecorator, dict, None]): Args: val: ThreadDecorator or dict to set as the thread + """ if val is None: self._decorators.pop("thread", None) @@ -328,6 +330,7 @@ def assign_thread_from(self, msg: "AgentMessage"): Args: msg: The received message containing optional thread information + """ if msg: thread = msg._thread @@ -341,6 +344,7 @@ def assign_thread_id(self, thid: Optional[str] = None, pthid: Optional[str] = No Args: thid: The thread identifier pthid: The parent thread identifier + """ if thid or pthid: self._thread = ThreadDecorator(thid=thid, pthid=pthid) @@ -363,6 +367,7 @@ def _trace(self, val: Union[TraceDecorator, dict]): Args: val: TraceDecorator or dict to set as the trace + """ if val is None: self._decorators.pop("trace", None) @@ -374,6 +379,7 @@ def assign_trace_from(self, msg: "AgentMessage"): Args: msg: The received message containing optional trace information + """ if msg and msg._trace: # ignore if not a valid type @@ -386,6 +392,7 @@ def assign_trace_decorator(self, context, trace): Args: context: context object trace: string containing trace json structure + """ if trace: self.add_trace_decorator( @@ -401,6 +408,7 @@ def add_trace_decorator( Args: target: The trace target full_thread: Full thread flag + """ if self._trace: # don't replace if there is already a trace decorator @@ -415,6 +423,7 @@ def add_trace_report(self, val: Union[TraceReport, dict]): Args: val: The trace target + """ if not self._trace: self.add_trace_decorator(target=TRACE_MESSAGE_TARGET, full_thread=True) diff --git a/acapy_agent/messaging/credential_definitions/routes.py b/acapy_agent/messaging/credential_definitions/routes.py index 6a10d7f71c..c54da063fd 100644 --- a/acapy_agent/messaging/credential_definitions/routes.py +++ b/acapy_agent/messaging/credential_definitions/routes.py @@ -633,7 +633,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/messaging/decorators/attach_decorator.py b/acapy_agent/messaging/decorators/attach_decorator.py index 7b17c6f670..02974ca19a 100644 --- a/acapy_agent/messaging/decorators/attach_decorator.py +++ b/acapy_agent/messaging/decorators/attach_decorator.py @@ -54,7 +54,6 @@ def __init__(self, kid: str): def __eq__(self, other: Any): """Compare equality with another.""" - return isinstance(self, other.__class__) and self.kid == other.kid @@ -99,7 +98,6 @@ def __init__( def __eq__(self, other: Any): """Compare equality with another.""" - return ( isinstance(self, other.__class__) and self.header == other.header @@ -173,7 +171,6 @@ class Meta: @pre_load def validate_single_xor_multi_sig(self, data: Mapping, **kwargs): """Ensure model is for either 1 or many signatures, not mishmash of both.""" - if "signatures" in data: if any(k in data for k in ("header", "protected", "signature")): raise BaseModelError( @@ -211,7 +208,6 @@ def validate_single_xor_multi_sig(self, data: Mapping, **kwargs): def did_key(verkey: str) -> str: """Qualify verkey into DID key if need be.""" - if verkey.startswith("did:key:"): return verkey @@ -220,7 +216,6 @@ def did_key(verkey: str) -> str: def raw_key(verkey: str) -> str: """Strip qualified key to raw key if need be.""" - if verkey.startswith("did:key:"): return DIDKey.from_did(verkey).public_key_b58 @@ -278,19 +273,16 @@ def __init__( @property def base64(self): """Accessor for base64 decorator data, or None.""" - return getattr(self, "base64_", None) @property def jws(self): """Accessor for JWS, or None.""" - return getattr(self, "jws_", None) @property def signatures(self) -> int: """Accessor for number of signatures.""" - if self.jws: return 1 if self.jws.signature else len(self.jws.signatures) return 0 @@ -298,7 +290,6 @@ def signatures(self) -> int: @property def signed(self) -> bytes: """Accessor for signed content (payload), None for unsigned.""" - return ( b64_to_bytes(unpad(set_urlsafe_b64(self.base64, urlsafe=True))) if self.signatures @@ -335,13 +326,11 @@ def json(self): @property def links(self): """Accessor for links decorator data, or None.""" - return getattr(self, "links_", None) @property def sha256(self): """Accessor for sha256 decorator data, or None.""" - return getattr(self, "sha256_", None) async def sign( @@ -359,7 +348,6 @@ async def sign( def build_protected(verkey: str): """Build protected header.""" - return str_to_b64( json.dumps( { @@ -468,7 +456,6 @@ async def verify( def __eq__(self, other): """Compare equality with another.""" - for attr in ["jws_", "sha256_", "base64_"]: if getattr(self, attr, None) != getattr(other, attr, None): return False @@ -489,7 +476,6 @@ class Meta: @pre_load def validate_data_spec(self, data: Mapping, **kwargs): """Ensure model chooses exactly one of base64, json, or links.""" - if len(set(data.keys()) & {"base64", "json", "links"}) != 1: raise BaseModelError( "AttachDecoratorSchema: choose exactly one of base64, json, or links" @@ -623,6 +609,7 @@ def data_base64_string( filename: optional attachment filename lastmod_time: optional attachment last modification time byte_count: optional attachment byte count + """ return AttachDecorator( ident=ident or str(uuid4()), diff --git a/acapy_agent/messaging/decorators/signature_decorator.py b/acapy_agent/messaging/decorators/signature_decorator.py index 4d980d2f22..7c72af1b87 100644 --- a/acapy_agent/messaging/decorators/signature_decorator.py +++ b/acapy_agent/messaging/decorators/signature_decorator.py @@ -45,6 +45,7 @@ def __init__( signature: The signature sig_data: Signature data signer: The verkey of the signer + """ self.signature_type = signature_type self.signature = signature diff --git a/acapy_agent/messaging/decorators/thread_decorator.py b/acapy_agent/messaging/decorators/thread_decorator.py index 32fb93170e..973a771258 100644 --- a/acapy_agent/messaging/decorators/thread_decorator.py +++ b/acapy_agent/messaging/decorators/thread_decorator.py @@ -77,6 +77,7 @@ def pthid(self, val: str): Args: val: The new pthid + """ self._pthid = val diff --git a/acapy_agent/messaging/decorators/timing_decorator.py b/acapy_agent/messaging/decorators/timing_decorator.py index cd8dd829d7..46ba681f1c 100644 --- a/acapy_agent/messaging/decorators/timing_decorator.py +++ b/acapy_agent/messaging/decorators/timing_decorator.py @@ -41,6 +41,7 @@ def __init__( expires_time: When the message should be considered expired delay_milli: The number of milliseconds to delay processing wait_until_time: The earliest time at which to perform processing + """ super().__init__() self.in_time = datetime_to_str(in_time) diff --git a/acapy_agent/messaging/decorators/trace_decorator.py b/acapy_agent/messaging/decorators/trace_decorator.py index caf4234ac9..3bb03ae456 100644 --- a/acapy_agent/messaging/decorators/trace_decorator.py +++ b/acapy_agent/messaging/decorators/trace_decorator.py @@ -46,6 +46,7 @@ def __init__( handler: ... elapsed_milli: ... outcome: ... + """ super().__init__() self._msg_id = msg_id @@ -166,6 +167,7 @@ def __init__( Trace reports can be used to identify steps in the processing of a message or thread, and support troubleshooting and performance issues. + """ super(TraceDecorator, self).__init__() self._target = target diff --git a/acapy_agent/messaging/decorators/transport_decorator.py b/acapy_agent/messaging/decorators/transport_decorator.py index 90dcdffc41..4ce0adcbc3 100644 --- a/acapy_agent/messaging/decorators/transport_decorator.py +++ b/acapy_agent/messaging/decorators/transport_decorator.py @@ -32,6 +32,7 @@ def __init__( return_route: Set the return routing mode return_route_thread: Identify the thread to enable return routing for queued_message_count: Indicate the number of queued messages + """ super().__init__() self.return_route = return_route diff --git a/acapy_agent/messaging/jsonld/create_verify_data.py b/acapy_agent/messaging/jsonld/create_verify_data.py index 2eac10c2bb..3efb5a5da9 100644 --- a/acapy_agent/messaging/jsonld/create_verify_data.py +++ b/acapy_agent/messaging/jsonld/create_verify_data.py @@ -50,7 +50,6 @@ def _canonize_document(doc: dict, document_loader: DocumentLoader | None = None) def _created_at() -> str: """Creation Timestamp.""" - stamp = datetime.datetime.now(datetime.timezone.utc) return stamp.strftime("%Y-%m-%dT%H:%M:%SZ") @@ -59,7 +58,6 @@ def create_verify_data( data: dict, signature_options: dict, document_loader: DocumentLoader | None = None ) -> tuple[dict, str]: """Encapsulate process of constructing string used during sign and verify.""" - signature_options["type"] = signature_options.get("type", "Ed25519Signature2018") type_ = signature_options.get("type") if type_ != "Ed25519Signature2018": diff --git a/acapy_agent/messaging/jsonld/credential.py b/acapy_agent/messaging/jsonld/credential.py index 995c4366b0..90a9d9579d 100644 --- a/acapy_agent/messaging/jsonld/credential.py +++ b/acapy_agent/messaging/jsonld/credential.py @@ -14,7 +14,6 @@ def did_key(verkey: str) -> str: """Qualify verkey into DID key if need be.""" - if verkey.startswith("did:key:"): return verkey @@ -38,7 +37,6 @@ def create_jws(encoded_header: str, verify_data: bytes) -> bytes: async def jws_sign(session: ProfileSession, verify_data: bytes, verkey: str) -> str: """Sign JWS.""" - header = {"alg": "EdDSA", "b64": False, "crit": ["b64"]} encoded_header = b64encode(json.dumps(header)) @@ -55,7 +53,6 @@ async def jws_sign(session: ProfileSession, verify_data: bytes, verkey: str) -> def verify_jws_header(header: dict) -> None: """Check header requirements.""" - if header != {"alg": "EdDSA", "b64": False, "crit": ["b64"]}: raise BadJWSHeaderError("Invalid JWS header parameters for Ed25519Signature2018.") @@ -64,7 +61,6 @@ async def jws_verify( session: ProfileSession, verify_data: bytes, signature: str, public_key: str ) -> bool: """Detached jws verify handling.""" - encoded_header, _, encoded_signature = signature.partition("..") decoded_header = json.loads(b64decode(encoded_header)) @@ -86,7 +82,6 @@ async def sign_credential( session: ProfileSession, credential: dict, signature_options: dict, verkey: str ) -> dict: """Sign Credential.""" - document_loader = session.profile.inject_or(DocumentLoader) _, verify_data_hex_string = create_verify_data( credential, @@ -100,7 +95,6 @@ async def sign_credential( async def verify_credential(session: ProfileSession, doc: dict, verkey: str) -> bool: """Verify credential.""" - document_loader = session.profile.inject_or(DocumentLoader) framed, verify_data_hex_string = create_verify_data( doc, diff --git a/acapy_agent/messaging/jsonld/routes.py b/acapy_agent/messaging/jsonld/routes.py index abffd1106a..2d00338aed 100644 --- a/acapy_agent/messaging/jsonld/routes.py +++ b/acapy_agent/messaging/jsonld/routes.py @@ -170,7 +170,6 @@ async def verify(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes([web.post("/jsonld/sign", sign), web.post("/jsonld/verify", verify)]) diff --git a/acapy_agent/messaging/models/base_record.py b/acapy_agent/messaging/models/base_record.py index f32a8e0c4e..c6534747ff 100644 --- a/acapy_agent/messaging/models/base_record.py +++ b/acapy_agent/messaging/models/base_record.py @@ -43,6 +43,7 @@ def match_post_filter( positive: whether matching all filter criteria positively or negatively alt: set to match any (positive=True) value or miss all (positive=False) values in post_filter + """ if not post_filter: return True @@ -113,6 +114,7 @@ def from_storage(cls, record_id: str, record: Mapping[str, Any]): Args: record_id: The unique record identifier record: The stored representation + """ record_id_name = cls.RECORD_ID_NAME if record_id_name in record: @@ -124,13 +126,11 @@ def from_storage(cls, record_id: str, record: Mapping[str, Any]): @classmethod def get_tag_map(cls) -> Mapping[str, str]: """Accessor for the set of defined tags.""" - return {tag.lstrip("~"): tag for tag in cls.TAG_NAMES or ()} @property def storage_record(self) -> StorageRecord: """Accessor for a `StorageRecord` representing this record.""" - return StorageRecord( self.RECORD_TYPE, json.dumps(self.value), self.tags, self._id ) @@ -138,13 +138,11 @@ def storage_record(self) -> StorageRecord: @property def record_value(self) -> dict: """Accessor to define custom properties for the JSON record value.""" - return {} @property def value(self) -> dict: """Accessor for the JSON record value generated for this record.""" - ret = self.strip_tag_prefix(self.tags) ret.update({"created_at": self.created_at, "updated_at": self.updated_at}) ret.update(self.record_value) @@ -153,7 +151,6 @@ def value(self) -> dict: @property def record_tags(self) -> dict: """Accessor to define implementation-specific tags.""" - return { tag: getattr(self, prop) for (prop, tag) in self.get_tag_map().items() @@ -163,7 +160,6 @@ def record_tags(self) -> dict: @property def tags(self) -> dict: """Accessor for the record tags generated for this record.""" - tags = self.record_tags return tags @@ -174,6 +170,7 @@ async def get_cached_key(cls, session: ProfileSession, cache_key: str): Args: session: The profile session to use cache_key: The unique cache identifier + """ if not cache_key: return @@ -192,8 +189,8 @@ async def set_cached_key( cache_key: The unique cache identifier value: The value to cache ttl: The cache ttl - """ + """ if not cache_key: return cache = session.inject_or(BaseCache) @@ -207,8 +204,8 @@ async def clear_cached_key(cls, session: ProfileSession, cache_key: str): Args: session: The profile session to use cache_key: The unique cache identifier - """ + """ if not cache_key: return cache = session.inject_or(BaseCache) @@ -229,8 +226,8 @@ async def retrieve_by_id( session: The profile session to use record_id: The ID of the record to find for_update: Whether to lock the record for update - """ + """ storage = session.inject(BaseStorage) result = await storage.get_record( cls.RECORD_TYPE, record_id, options={"forUpdate": for_update} @@ -256,8 +253,8 @@ async def retrieve_by_tag_filter( post_filter: Additional value filters to apply matching positively, with sequence values specifying alternatives to match (hit any) for_update: Whether to lock the record for update - """ + """ storage = session.inject(BaseStorage) rows = await storage.find_all_records( cls.RECORD_TYPE, @@ -312,8 +309,8 @@ async def query( post_filter_negative: Additional value filters to apply matching negatively alt: set to match any (positive=True) value or miss all (positive=False) values in post_filter - """ + """ storage = session.inject(BaseStorage) tag_query = cls.prefix_tag_filter(tag_filter) @@ -392,8 +389,8 @@ async def save( log_params: Additional parameters to log log_override: Override configured logging regimen, print to stderr instead event: Flag to override whether the event is sent - """ + """ new_record = None log_reason = reason or ("Updated record" if self._id else "Created record") try: @@ -439,8 +436,8 @@ async def post_save( new_record: Flag indicating if the record was just created last_state: The previous state value event: Flag to override whether the event is sent - """ + """ if event is None: event = new_record or (last_state != self.state) if event: @@ -451,8 +448,8 @@ async def delete_record(self, session: ProfileSession): Args: session: The profile session to use - """ + """ if self._id: storage = session.inject(BaseStorage) if self.state: @@ -467,8 +464,8 @@ async def emit_event(self, session: ProfileSession, payload: Optional[Any] = Non Args: session: The profile session to use payload: The event payload - """ + """ if not self.RECORD_TOPIC: return @@ -491,7 +488,6 @@ def log_state( override: bool = False, ): """Print a message with increased visibility (for testing).""" - if override or ( cls.LOG_STATE_FLAG and settings and settings.get(cls.LOG_STATE_FLAG) ): @@ -504,13 +500,11 @@ def log_state( @classmethod def strip_tag_prefix(cls, tags: dict): """Strip tilde from unencrypted tag names.""" - return {(k[1:] if "~" in k else k): v for (k, v) in tags.items()} if tags else {} @classmethod def prefix_tag_filter(cls, tag_filter: dict): """Prefix unencrypted tags used in the tag filter.""" - ret = None if tag_filter: tag_map = cls.get_tag_map() @@ -526,7 +520,6 @@ def prefix_tag_filter(cls, tag_filter: dict): def __eq__(self, other: Any) -> bool: """Comparison between records.""" - if type(other) is type(self): return self.value == other.value and self.tags == other.tags return False @@ -538,8 +531,8 @@ def get_attributes_by_prefix(cls, prefix: str, walk_mro: bool = True): Args: prefix: Common prefix to look for walk_mro: Walk MRO to find attributes inherited from superclasses - """ + """ bases = cls.__mro__ if walk_mro else [cls] return [ vars(base)[name] @@ -561,13 +554,11 @@ def __init__( **kwargs, ): """Initialize a new BaseExchangeRecord.""" - super().__init__(id, state, **kwargs) self.trace = trace def __eq__(self, other: Any) -> bool: """Comparison between records.""" - if type(other) is type(self): return ( self.value == other.value diff --git a/acapy_agent/messaging/models/paginated_query.py b/acapy_agent/messaging/models/paginated_query.py index d52e8ae952..2ced592d4e 100644 --- a/acapy_agent/messaging/models/paginated_query.py +++ b/acapy_agent/messaging/models/paginated_query.py @@ -58,8 +58,8 @@ def get_paginated_query_params(request: BaseRequest) -> Tuple[int, int, str, boo - offset (int): The offset for pagination, defaulting to 0. - order_by (str): The field by which to order results, defaulting to "id". - descending (bool): Order results in descending order; defaults to False. - """ + """ limit = int(request.query.get("limit", DEFAULT_PAGE_SIZE)) offset = int(request.query.get("offset", 0)) order_by = request.query.get("order_by", "id") diff --git a/acapy_agent/messaging/request_context.py b/acapy_agent/messaging/request_context.py index 585f41d287..28ed1f55aa 100644 --- a/acapy_agent/messaging/request_context.py +++ b/acapy_agent/messaging/request_context.py @@ -123,6 +123,7 @@ def message(self, msg: AgentMessage): Args: msg: This context's new agent message + """ self._message = msg @@ -142,6 +143,7 @@ def message_receipt(self, receipt: MessageReceipt): Args: receipt: This context's new message receipt information + """ self._message_receipt = receipt diff --git a/acapy_agent/messaging/responder.py b/acapy_agent/messaging/responder.py index 98a2bb6425..7bc4bc91fc 100644 --- a/acapy_agent/messaging/responder.py +++ b/acapy_agent/messaging/responder.py @@ -191,6 +191,7 @@ async def send_outbound( Args: message: The `OutboundMessage` to be sent kwargs: Additional keyword arguments + """ @abstractmethod @@ -200,6 +201,7 @@ async def send_webhook(self, topic: str, payload: dict): Args: topic: the webhook topic identifier payload: the webhook payload value + """ diff --git a/acapy_agent/messaging/schemas/routes.py b/acapy_agent/messaging/schemas/routes.py index 6ac6d4bf93..7ab4e06780 100644 --- a/acapy_agent/messaging/schemas/routes.py +++ b/acapy_agent/messaging/schemas/routes.py @@ -528,7 +528,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/messaging/util.py b/acapy_agent/messaging/util.py index 8318b15018..8c1d4f2f46 100644 --- a/acapy_agent/messaging/util.py +++ b/acapy_agent/messaging/util.py @@ -16,6 +16,7 @@ def datetime_to_str(dt: Union[str, datetime, None]) -> Union[str, None]: Args: dt: May be a string or datetime to allow automatic conversion + """ if isinstance(dt, datetime): dt = dt.replace(tzinfo=timezone.utc).isoformat().replace("+00:00", "Z") @@ -116,7 +117,6 @@ def encode(orig: Any) -> str: encoded value """ - if isinstance(orig, int) and -I32_BOUND <= orig < I32_BOUND: return str(int(orig)) # python bools are ints @@ -151,7 +151,6 @@ def get_proto_default_version( versions: List[Dict[str, Any]], major_version: int = 1 ) -> str: """Return default protocol version from version definition list.""" - for version in versions: if major_version == version["major_version"]: default_major_version = version["major_version"] diff --git a/acapy_agent/messaging/valid.py b/acapy_agent/messaging/valid.py index 3b54bc01dc..37d3e7617e 100644 --- a/acapy_agent/messaging/valid.py +++ b/acapy_agent/messaging/valid.py @@ -65,7 +65,6 @@ class IntEpoch(Range): def __init__(self): """Initialize the instance.""" - super().__init__( # use u64 for indy-sdk compatibility min=0, max=18446744073709551615, @@ -80,12 +79,10 @@ class WholeNumber(Range): def __init__(self): """Initialize the instance.""" - super().__init__(min=0, error="Value {input} is not a non-negative integer") def __call__(self, value): """Validate input value.""" - if not isinstance(value, int): raise ValidationError("Value {input} is not a valid whole number") super().__call__(value) @@ -99,7 +96,6 @@ class NumericStrWhole(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( NumericStrWhole.PATTERN, error="Value {input} is not a non-negative numeric string", @@ -114,7 +110,6 @@ class NumericStrAny(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( NumericStrAny.PATTERN, error="Value {input} is not a numeric string", @@ -128,12 +123,10 @@ class NaturalNumber(Range): def __init__(self): """Initialize the instance.""" - super().__init__(min=1, error="Value {input} is not a positive integer") def __call__(self, value): """Validate input value.""" - if not isinstance(value, int): raise ValidationError("Value {input} is not a valid natural number") super().__call__(value) @@ -147,7 +140,6 @@ class NumericStrNatural(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( NumericStrNatural.PATTERN, error="Value {input} is not a positive numeric string", @@ -161,7 +153,6 @@ class IndyRevRegSize(Range): def __init__(self): """Initialize the instance.""" - super().__init__( min=RevocationRegistry.MIN_SIZE, max=RevocationRegistry.MAX_SIZE, @@ -174,7 +165,6 @@ def __init__(self): def __call__(self, value): """Validate input value.""" - if not isinstance(value, int): raise ValidationError( "Value {input} must be an integer between " @@ -192,7 +182,6 @@ class JWSHeaderKid(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( JWSHeaderKid.PATTERN, error="Value {input} is neither in W3C did:key nor DID URL format", @@ -212,7 +201,6 @@ class NonSDList(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( NonSDList.PATTERN, error="Value {input} is not a valid NonSDList", @@ -229,7 +217,6 @@ class JSONWebToken(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( JSONWebToken.PATTERN, error="Value {input} is not a valid JSON Web token", @@ -251,7 +238,6 @@ class SDJSONWebToken(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( SDJSONWebToken.PATTERN, error="Value {input} is not a valid SD-JSON Web token", @@ -266,7 +252,6 @@ class DIDKey(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDKey.PATTERN, error="Value {input} is not in W3C did:key format" ) @@ -280,7 +265,6 @@ class DIDKeyOrRef(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDKeyOrRef.PATTERN, error="Value {input} is not a did:key or did:key ref" ) @@ -297,7 +281,6 @@ class DIDKeyRef(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDKeyRef.PATTERN, error="Value {input} is not a did:key reference" ) @@ -311,7 +294,6 @@ class DIDWeb(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDWeb.PATTERN, error="Value {input} is not in W3C did:web format" ) @@ -327,7 +309,6 @@ class DIDWebvh(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDWebvh.PATTERN, error="Value {input} is not in W3C did:webvh format" ) @@ -340,7 +321,6 @@ class DIDPosture(OneOf): def __init__(self): """Initialize the instance.""" - super().__init__( choices=[did_posture.moniker for did_posture in DIDPostureEnum], error="Value {input} must be one of {choices}", @@ -355,7 +335,6 @@ class IndyDID(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( IndyDID.PATTERN, error="Value {input} is not an indy decentralized identifier (DID)", @@ -374,7 +353,6 @@ class AnonCredsDID(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDValidation.PATTERN, error="Value {input} is not an decentralized identifier (DID)", @@ -399,7 +377,6 @@ class DIDValidation(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( DIDValidation.PATTERN, error="Value {input} is not a valid DID", @@ -415,7 +392,6 @@ class MaybeIndyDID(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( MaybeIndyDID.PATTERN, error="Value {input} is not a valid DID", @@ -430,7 +406,6 @@ class RawPublicEd25519VerificationKey2018(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( RawPublicEd25519VerificationKey2018.PATTERN, error="Value {input} is not a raw Ed25519VerificationKey2018 key", @@ -451,7 +426,6 @@ class RoutingKey(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( RoutingKey.PATTERN, error=( @@ -475,7 +449,6 @@ class IndyCredDefId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( IndyCredDefId.PATTERN, error="Value {input} is not an indy credential definition identifier", @@ -490,7 +463,6 @@ class AnonCredsCredDefId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( AnonCredsCredDefId.PATTERN, error="Value {input} is not an anoncreds credential definition identifier", @@ -505,7 +477,6 @@ class MajorMinorVersion(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( MajorMinorVersion.PATTERN, error="Value {input} is not a valid version major minor version (use only digits and '.')", # noqa: E501 @@ -520,7 +491,6 @@ class IndySchemaId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( IndySchemaId.PATTERN, error="Value {input} is not an indy schema identifier", @@ -535,7 +505,6 @@ class AnonCredsSchemaId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( AnonCredsSchemaId.PATTERN, error="Value {input} is not an anoncreds schema identifier", @@ -555,7 +524,6 @@ class IndyRevRegId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( IndyRevRegId.PATTERN, error="Value {input} is not an indy revocation registry identifier", @@ -570,7 +538,6 @@ class AnonCredsRevRegId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( AnonCredsRevRegId.PATTERN, error="Value {input} is not an anoncreds revocation registry identifier", @@ -585,7 +552,6 @@ class IndyCredRevId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( IndyCredRevId.PATTERN, error="Value {input} is not an indy credential revocation identifier", @@ -600,7 +566,6 @@ class AnonCredsCredRevId(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( AnonCredsCredRevId.PATTERN, error="Value {input} is not an anoncreds credential revocation identifier", @@ -614,7 +579,6 @@ class Predicate(OneOf): def __init__(self): """Initialize the instance.""" - super().__init__( choices=["<", "<=", ">=", ">"], error="Value {input} must be one of {choices}", @@ -632,7 +596,6 @@ class ISO8601DateTime(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( ISO8601DateTime.PATTERN, error="Value {input} is not a date in valid format", @@ -650,7 +613,6 @@ class RFC3339DateTime(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( RFC3339DateTime.PATTERN, error="Value {input} is not a date in valid format", @@ -665,7 +627,6 @@ class IndyWQL(Regexp): # using Regexp brings in nice visual validator cue def __init__(self): """Initialize the instance.""" - super().__init__( IndyWQL.PATTERN, error="Value {input} is not a valid WQL query", @@ -673,7 +634,6 @@ def __init__(self): def __call__(self, value): """Validate input value.""" - super().__call__(value or "") message = f"Value {value} is not a valid WQL query" @@ -693,7 +653,6 @@ class IndyExtraWQL(Regexp): # using Regexp brings in nice visual validator cue def __init__(self): """Initialize the instance.""" - super().__init__( IndyExtraWQL.PATTERN, error="Value {input} is not a valid extra WQL query", @@ -701,7 +660,6 @@ def __init__(self): def __call__(self, value): """Validate input value.""" - super().__call__(value or "") message = f"Value {value} is not a valid extra WQL query" @@ -721,7 +679,6 @@ class Base64(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( Base64.PATTERN, error="Value {input} is not a valid base64 encoding", @@ -736,7 +693,6 @@ class Base64URL(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( Base64URL.PATTERN, error="Value {input} is not a valid base64url encoding", @@ -751,7 +707,6 @@ class Base64URLNoPad(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( Base64URLNoPad.PATTERN, error="Value {input} is not a valid unpadded base64url encoding", @@ -766,7 +721,6 @@ class SHA256Hash(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( SHA256Hash.PATTERN, error="Value {input} is not a valid (binhex-encoded) SHA-256 hash", @@ -781,7 +735,6 @@ class Base58SHA256Hash(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( Base58SHA256Hash.PATTERN, error="Value {input} is not a base58 encoding of a SHA-256 hash", @@ -802,7 +755,6 @@ class UUIDFour(Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( UUIDFour.PATTERN, error="Value {input} is not UUID4 (8-4-4-4-12 hex digits with digit#13=4)", @@ -833,7 +785,6 @@ class Endpoint(Regexp): # using Regexp brings in nice visual validator cue def __init__(self): """Initialize the instance.""" - super().__init__( Endpoint.PATTERN, error="Value {input} is not a valid endpoint", @@ -847,7 +798,6 @@ class EndpointType(OneOf): def __init__(self): """Initialize the instance.""" - super().__init__( choices=[e.w3c for e in EndpointTypeEnum], error="Value {input} must be one of {choices}", @@ -910,7 +860,6 @@ def __init__(self) -> None: def __call__(self, value): """Validate input value.""" - if not isinstance(value, list): raise ValidationError("Value must be a non-empty list.") diff --git a/acapy_agent/multitenant/admin/routes.py b/acapy_agent/multitenant/admin/routes.py index e0ddee87a1..6b26205991 100644 --- a/acapy_agent/multitenant/admin/routes.py +++ b/acapy_agent/multitenant/admin/routes.py @@ -90,7 +90,6 @@ def format_wallet_record(wallet_record: WalletRecord): """Serialize a WalletRecord object.""" - wallet_info = wallet_record.serialize() # Hide wallet wallet key @@ -102,7 +101,6 @@ def format_wallet_record(wallet_record: WalletRecord): def get_extra_settings_dict_per_tenant(tenant_settings: dict) -> dict: """Get per tenant settings to be applied when creating wallet.""" - endorser_role_flag = tenant_settings.get( "ACAPY_ENDORSER_ROLE" ) or tenant_settings.get("endorser-protocol-role") @@ -243,7 +241,6 @@ def validate_fields(self, data, **kwargs): ValidationError: If any of the fields do not validate """ - if data.get("wallet_type") == "indy": for field in ("wallet_key", "wallet_name"): if field not in data: @@ -373,8 +370,8 @@ async def wallets_list(request: web.BaseRequest): Args: request: aiohttp request object - """ + """ context: AdminRequestContext = request["context"] profile = context.profile @@ -416,7 +413,6 @@ async def wallet_get(request: web.BaseRequest): HTTPNotFound: if wallet_id does not match any known wallets """ - context: AdminRequestContext = request["context"] profile = context.profile wallet_id = request.match_info["wallet_id"] @@ -442,8 +438,8 @@ async def wallet_create(request: web.BaseRequest): Args: request: aiohttp request object - """ + """ context: AdminRequestContext = request["context"] body = await request.json() @@ -509,8 +505,8 @@ async def wallet_update(request: web.BaseRequest): Args: request: aiohttp request object - """ + """ context: AdminRequestContext = request["context"] wallet_id = request.match_info["wallet_id"] @@ -574,8 +570,8 @@ async def wallet_create_token(request: web.BaseRequest): Args: request: aiohttp request object - """ + """ context: AdminRequestContext = request["context"] wallet_id = request.match_info["wallet_id"] wallet_key = None @@ -621,7 +617,6 @@ async def wallet_remove(request: web.BaseRequest): request: aiohttp request object. """ - context: AdminRequestContext = request["context"] wallet_id = request.match_info["wallet_id"] wallet_key = None @@ -659,7 +654,6 @@ async def wallet_remove(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/multitenancy/wallets", wallets_list, allow_head=False), @@ -674,7 +668,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/multitenant/base.py b/acapy_agent/multitenant/base.py index f4ec416e78..326c4a57c4 100644 --- a/acapy_agent/multitenant/base.py +++ b/acapy_agent/multitenant/base.py @@ -38,6 +38,7 @@ def __init__(self, profile: Optional[Profile]): Args: profile: The profile for this manager + """ if not profile: raise MissingProfileError() @@ -96,6 +97,7 @@ def get_webhook_urls( Returns: webhook urls according to dispatch_type + """ wallet_id = wallet_record.wallet_id dispatch_type = wallet_record.wallet_dispatch_type @@ -391,6 +393,7 @@ async def _get_wallet_by_key(self, recipient_key: str) -> Optional[WalletRecord] recipient_key: The recipient key Returns: Wallet record associated with the recipient key + """ routing_mgr = RoutingManager(self._profile) diff --git a/acapy_agent/multitenant/cache.py b/acapy_agent/multitenant/cache.py index ea18e34529..ff62f1aa9e 100644 --- a/acapy_agent/multitenant/cache.py +++ b/acapy_agent/multitenant/cache.py @@ -19,8 +19,8 @@ def __init__(self, capacity: int): Args: capacity: The capacity of the cache. If capacity is exceeded profiles are closed. - """ + """ LOGGER.debug(f"Profile cache initialized with capacity {capacity}") self._cache: OrderedDict[str, Profile] = OrderedDict() @@ -86,8 +86,8 @@ def put(self, key: str, value: Profile) -> None: Args: key (str): the key to set value (Profile): the profile to set - """ + """ # Profiles are responsible for cleaning up after themselves when they # fall out of scope. Previously the cache needed to create a finalizer. # value.finalzer() @@ -108,6 +108,7 @@ def remove(self, key: str): Args: key (str): The key to remove from the cache. + """ del self.profiles[key] del self._cache[key] diff --git a/acapy_agent/multitenant/manager.py b/acapy_agent/multitenant/manager.py index 9431e965f4..76c9086c21 100644 --- a/acapy_agent/multitenant/manager.py +++ b/acapy_agent/multitenant/manager.py @@ -22,6 +22,7 @@ def __init__(self, profile: Profile): Args: profile: The profile for this manager + """ super().__init__(profile) self._profiles = ProfileCache( diff --git a/acapy_agent/multitenant/manager_provider.py b/acapy_agent/multitenant/manager_provider.py index d15de17520..b11ffed840 100644 --- a/acapy_agent/multitenant/manager_provider.py +++ b/acapy_agent/multitenant/manager_provider.py @@ -33,7 +33,6 @@ def __init__(self, root_profile): def provide(self, settings: BaseSettings, injector: BaseInjector): """Create the multitenant manager instance.""" - manager_type = settings.get_value( "multitenant.wallet_type", default="basic" ).lower() diff --git a/acapy_agent/multitenant/single_wallet_askar_manager.py b/acapy_agent/multitenant/single_wallet_askar_manager.py index 8294fcd779..d04610e4c9 100644 --- a/acapy_agent/multitenant/single_wallet_askar_manager.py +++ b/acapy_agent/multitenant/single_wallet_askar_manager.py @@ -24,6 +24,7 @@ def __init__( Args: profile: The base profile for this manager multitenant_profile: The multitenant profile for this manager + """ super().__init__(profile) self._multitenant_profile: Optional[AskarProfile] = multitenant_profile diff --git a/acapy_agent/protocols/actionmenu/v1_0/base_service.py b/acapy_agent/protocols/actionmenu/v1_0/base_service.py index fd8d85287b..b0d81ba01a 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/base_service.py +++ b/acapy_agent/protocols/actionmenu/v1_0/base_service.py @@ -40,6 +40,7 @@ async def get_active_menu( profile: The profile connection: The active connection record thread_id: The thread identifier from the requesting message. + """ @abstractmethod @@ -59,4 +60,5 @@ async def perform_menu_action( action_params: A collection of parameters for the action connection: The active connection record thread_id: The thread identifier from the requesting message. + """ diff --git a/acapy_agent/protocols/actionmenu/v1_0/controller.py b/acapy_agent/protocols/actionmenu/v1_0/controller.py index 8bc9b3a147..8cb8fad751 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/controller.py +++ b/acapy_agent/protocols/actionmenu/v1_0/controller.py @@ -14,7 +14,6 @@ def __init__(self, protocol: str): async def determine_roles(self, context: InjectionContext) -> Sequence[str]: """Determine what action menu roles are defined.""" - service = context.inject_or(BaseMenuService) if service: return ["provider"] diff --git a/acapy_agent/protocols/actionmenu/v1_0/driver_service.py b/acapy_agent/protocols/actionmenu/v1_0/driver_service.py index 96163d9a3f..211ba1b792 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/driver_service.py +++ b/acapy_agent/protocols/actionmenu/v1_0/driver_service.py @@ -27,6 +27,7 @@ async def get_active_menu( profile: The profile connection: The active connection record thread_id: The thread identifier from the requesting message. + """ await profile.notify( "acapy::actionmenu::get-active-menu", @@ -53,6 +54,7 @@ async def perform_menu_action( action_params: A collection of parameters for the action connection: The active connection record thread_id: The thread identifier from the requesting message. + """ await profile.notify( "acapy::actionmenu::perform-menu-action", diff --git a/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_handler.py b/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_handler.py index b7cb04e35d..d58041a877 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_handler.py +++ b/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_handler.py @@ -19,6 +19,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("MenuHandler called with context %s", context) assert isinstance(context.message, Menu) diff --git a/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_request_handler.py b/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_request_handler.py index 4aef949495..c5d1c7f546 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_request_handler.py +++ b/acapy_agent/protocols/actionmenu/v1_0/handlers/menu_request_handler.py @@ -19,6 +19,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("MenuRequestHandler called with context %s", context) assert isinstance(context.message, MenuRequest) diff --git a/acapy_agent/protocols/actionmenu/v1_0/handlers/perform_handler.py b/acapy_agent/protocols/actionmenu/v1_0/handlers/perform_handler.py index 4f6a5b1387..856f1a9dba 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/handlers/perform_handler.py +++ b/acapy_agent/protocols/actionmenu/v1_0/handlers/perform_handler.py @@ -19,6 +19,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("PerformHandler called with context %s", context) assert isinstance(context.message, Perform) diff --git a/acapy_agent/protocols/actionmenu/v1_0/messages/menu.py b/acapy_agent/protocols/actionmenu/v1_0/messages/menu.py index 0c0b73b7ad..0955c55613 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/messages/menu.py +++ b/acapy_agent/protocols/actionmenu/v1_0/messages/menu.py @@ -38,6 +38,7 @@ def __init__( errormsg: An optional error message to display options: A sequence of menu options kwargs: Additional keyword arguments + """ super().__init__(**kwargs) self.title = title diff --git a/acapy_agent/protocols/actionmenu/v1_0/messages/perform.py b/acapy_agent/protocols/actionmenu/v1_0/messages/perform.py index 29481a6e66..094bd672e4 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/messages/perform.py +++ b/acapy_agent/protocols/actionmenu/v1_0/messages/perform.py @@ -29,6 +29,7 @@ def __init__( name: The name of the menu option params: Input parameter values kwargs: Additional keyword arguments + """ super().__init__(**kwargs) self.name = name diff --git a/acapy_agent/protocols/actionmenu/v1_0/models/menu_form.py b/acapy_agent/protocols/actionmenu/v1_0/models/menu_form.py index 699c0631a9..52878bbdc4 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/models/menu_form.py +++ b/acapy_agent/protocols/actionmenu/v1_0/models/menu_form.py @@ -31,6 +31,7 @@ def __init__( description: Additional descriptive text for the menu form params: A list of form parameters submit_label: An alternative label for the form submit button + """ self.title = title self.description = description diff --git a/acapy_agent/protocols/actionmenu/v1_0/models/menu_option.py b/acapy_agent/protocols/actionmenu/v1_0/models/menu_option.py index b30fac72b6..f1f090747e 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/models/menu_option.py +++ b/acapy_agent/protocols/actionmenu/v1_0/models/menu_option.py @@ -33,6 +33,7 @@ def __init__( description: Additional descriptive text for the menu option disabled: If the option should be shown as disabled form: A form to display when the option is selected + """ self.name = name self.title = title diff --git a/acapy_agent/protocols/actionmenu/v1_0/routes.py b/acapy_agent/protocols/actionmenu/v1_0/routes.py index b066fd2550..8ee7be03dd 100644 --- a/acapy_agent/protocols/actionmenu/v1_0/routes.py +++ b/acapy_agent/protocols/actionmenu/v1_0/routes.py @@ -239,7 +239,6 @@ async def actionmenu_send(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.post("/action-menu/{conn_id}/close", actionmenu_close), @@ -253,7 +252,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/basicmessage/v1_0/handlers/basicmessage_handler.py b/acapy_agent/protocols/basicmessage/v1_0/handlers/basicmessage_handler.py index e30c6002c4..f6e59b19bd 100644 --- a/acapy_agent/protocols/basicmessage/v1_0/handlers/basicmessage_handler.py +++ b/acapy_agent/protocols/basicmessage/v1_0/handlers/basicmessage_handler.py @@ -18,6 +18,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("BasicMessageHandler called with context %s", context) assert isinstance(context.message, BasicMessage) diff --git a/acapy_agent/protocols/basicmessage/v1_0/routes.py b/acapy_agent/protocols/basicmessage/v1_0/routes.py index 772a26b571..2232807623 100644 --- a/acapy_agent/protocols/basicmessage/v1_0/routes.py +++ b/acapy_agent/protocols/basicmessage/v1_0/routes.py @@ -65,7 +65,6 @@ async def connections_send_message(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [web.post("/connections/{conn_id}/send-message", connections_send_message)] ) @@ -73,7 +72,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/coordinate_mediation/mediation_invite_store.py b/acapy_agent/protocols/coordinate_mediation/mediation_invite_store.py index 6ae5ac4b9e..8c2234be97 100644 --- a/acapy_agent/protocols/coordinate_mediation/mediation_invite_store.py +++ b/acapy_agent/protocols/coordinate_mediation/mediation_invite_store.py @@ -89,7 +89,6 @@ async def store( async def __retrieve(self) -> Optional[MediationInviteRecord]: """:return: the currently stored mediation invite url.""" - invite_record = await self.__retrieve_record(self.MEDIATION_INVITE_ID) return ( MediationInviteRecord.from_json(invite_record.value) @@ -148,7 +147,6 @@ async def get_mediation_invite_record( :return: mediation invite to use/that was used to connect to the mediator. None if no invitation was provided/provisioned. """ - stored_invite = await self.__retrieve() if stored_invite is None and provided_mediation_invitation is None: diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/problem_report_handler.py b/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/problem_report_handler.py index 9e0fbbc486..266942b78d 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/problem_report_handler.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/handlers/problem_report_handler.py @@ -18,6 +18,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback + """ self._logger.debug("CMProblemReportHandler called with context %s", context) assert isinstance(context.message, CMProblemReport) diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/manager.py b/acapy_agent/protocols/coordinate_mediation/v1_0/manager.py index 8fc9e414ec..a9dc0b04e0 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/manager.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/manager.py @@ -64,6 +64,7 @@ def __init__(self, profile: Profile): Args: profile: The Profile instance for this manager + """ self._profile = profile if not profile: diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist.py b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist.py index a2c25a891c..8105411eb5 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist.py @@ -35,6 +35,7 @@ def __init__( keys: Found keys by requested query pagination: Pagination rules kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.keys = list(keys) if keys else [] diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py index c0d960638c..383104cb55 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py @@ -34,6 +34,7 @@ def __init__( filter: Filter for query paginate: Pagination rules kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.filter = filter diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py index 2800500a27..cf9cd3dce8 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py @@ -32,6 +32,7 @@ def __init__( Args: updates: Update rules for keylist update request kwargs: Additional keyword arguments for the message + """ super(KeylistUpdate, self).__init__(**kwargs) self.updates = list(updates) if updates else [] diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py index 3ea951f9cf..af0f14005e 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py @@ -35,6 +35,7 @@ def __init__( Args: updated: Update rules for keylist update request kwargs: Additional keyword arguments for the message + """ super(KeylistUpdateResponse, self).__init__(**kwargs) self.updated = list(updated) if updated else [] diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py index 4175fe7e9f..4af8d92d99 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py @@ -38,6 +38,7 @@ def __init__( endpoint: Endpoint address for the mediation route routing_keys: Keys for the mediation route kwargs: Additional keyword arguments for the message + """ super(MediationGrant, self).__init__(**kwargs) self.endpoint = endpoint diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/problem_report.py b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/problem_report.py index 747b4a9f11..f5a2364703 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/messages/problem_report.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/messages/problem_report.py @@ -49,7 +49,6 @@ class Meta: @validates_schema def validate_fields(self, data, **kwargs): """Validate schema fields.""" - if not data.get("description", {}).get("code", ""): raise ValidationError("Value for description.code must be present") elif data.get("description", {}).get("code", "") not in [ diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/routes.py b/acapy_agent/protocols/coordinate_mediation/v1_0/routes.py index 16e4a7cc5c..bf9e1c9b7d 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/routes.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/routes.py @@ -525,7 +525,6 @@ async def update_keylist_for_connection(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/mediation/requests", list_mediation_requests, allow_head=False), @@ -564,7 +563,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_multiuse_invitation.py b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_multiuse_invitation.py index 088e76f59b..ca40ec079c 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_multiuse_invitation.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/tests/test_multiuse_invitation.py @@ -1,15 +1,17 @@ +import json +from contextlib import asynccontextmanager from unittest.mock import AsyncMock, MagicMock + import pytest + +from acapy_agent.cache.base import BaseCache from acapy_agent.connections.models.conn_record import ConnRecord +from acapy_agent.core.profile import Profile from acapy_agent.protocols.coordinate_mediation.v1_0.route_manager import ( CoordinateMediationV1RouteManager, ) -from contextlib import asynccontextmanager -from acapy_agent.core.profile import Profile from acapy_agent.storage.base import BaseStorage -from acapy_agent.cache.base import BaseCache from acapy_agent.storage.record import StorageRecord -import json @asynccontextmanager diff --git a/acapy_agent/protocols/did_rotate/v1_0/handlers/ack_handler.py b/acapy_agent/protocols/did_rotate/v1_0/handlers/ack_handler.py index 4b8746e2bb..27404a960a 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/handlers/ack_handler.py +++ b/acapy_agent/protocols/did_rotate/v1_0/handlers/ack_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("RotateAckHandler called with context %s", context) assert isinstance(context.message, RotateAck) diff --git a/acapy_agent/protocols/did_rotate/v1_0/handlers/hangup_handler.py b/acapy_agent/protocols/did_rotate/v1_0/handlers/hangup_handler.py index 8e1cb7b102..1e6f4ff70b 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/handlers/hangup_handler.py +++ b/acapy_agent/protocols/did_rotate/v1_0/handlers/hangup_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("HangupHandler called with context %s", context) assert isinstance(context.message, Hangup) diff --git a/acapy_agent/protocols/did_rotate/v1_0/handlers/problem_report_handler.py b/acapy_agent/protocols/did_rotate/v1_0/handlers/problem_report_handler.py index 199952526d..81986aec8d 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/handlers/problem_report_handler.py +++ b/acapy_agent/protocols/did_rotate/v1_0/handlers/problem_report_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("ProblemReportHandler called with context %s", context) assert isinstance(context.message, RotateProblemReport) diff --git a/acapy_agent/protocols/did_rotate/v1_0/handlers/rotate_handler.py b/acapy_agent/protocols/did_rotate/v1_0/handlers/rotate_handler.py index e5fd8f0f83..9ba48fa2c1 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/handlers/rotate_handler.py +++ b/acapy_agent/protocols/did_rotate/v1_0/handlers/rotate_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug("RotateHandler called with context %s", context) assert isinstance(context.message, Rotate) diff --git a/acapy_agent/protocols/did_rotate/v1_0/manager.py b/acapy_agent/protocols/did_rotate/v1_0/manager.py index c7bcae3b7d..515fb4888c 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/manager.py +++ b/acapy_agent/protocols/did_rotate/v1_0/manager.py @@ -72,8 +72,8 @@ async def hangup(self, conn: ConnRecord) -> Hangup: Args: conn (ConnRecord): The connection to hangup. - """ + """ hangup = Hangup() responder = self.profile.inject(BaseResponder) @@ -90,8 +90,8 @@ async def rotate_my_did(self, conn: ConnRecord, new_did: str) -> Rotate: Args: conn (ConnRecord): The connection to rotate the DID for. new_did (str): The new DID to use for the connection. - """ + """ record = RotateRecord( role=RotateRecord.ROLE_ROTATING, state=RotateRecord.STATE_ROTATE_SENT, @@ -115,6 +115,7 @@ async def receive_rotate(self, conn: ConnRecord, rotate: Rotate) -> RotateRecord Args: conn (ConnRecord): The connection to rotate the DID for. rotate (Rotate): The received rotate message. + """ record = RotateRecord( role=RotateRecord.ROLE_OBSERVING, @@ -142,6 +143,7 @@ async def commit_rotate(self, conn: ConnRecord, record: RotateRecord): Args: conn (ConnRecord): The connection to rotate the DID for. record (RotateRecord): The rotate record. + """ record.state = RotateRecord.STATE_ACK_SENT if not record.new_did: @@ -180,6 +182,7 @@ async def receive_ack(self, conn: ConnRecord, ack: RotateAck): Args: conn (ConnRecord): The connection to rotate the DID for. ack (RotateAck): The received rotate ack message. + """ async with self.profile.session() as session: record = await RotateRecord.retrieve_by_thread_id(session, ack._thread_id) @@ -208,6 +211,7 @@ async def receive_problem_report(self, problem_report: RotateProblemReport): Args: conn (ConnRecord): The connection to rotate the DID for. problem_report (ProblemReport): The received problem report message. + """ async with self.profile.session() as session: record = await RotateRecord.retrieve_by_thread_id( @@ -227,6 +231,7 @@ async def receive_hangup(self, conn: ConnRecord): Args: conn (ConnRecord): The connection to rotate the DID for. hangup (Hangup): The received hangup message. + """ async with self.profile.session() as session: await conn.delete_record(session) diff --git a/acapy_agent/protocols/did_rotate/v1_0/messages/problem_report.py b/acapy_agent/protocols/did_rotate/v1_0/messages/problem_report.py index 0d0a39b2f2..a97f3c2b76 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/messages/problem_report.py +++ b/acapy_agent/protocols/did_rotate/v1_0/messages/problem_report.py @@ -40,6 +40,7 @@ def for_code(cls, problem_code: ProblemReportReason, did: str, **kwargs): constructor Returns: An instance of RotateProblemReport + """ description = { ProblemReportReason.UNRESOLVABLE: "Unable to resolve DID", @@ -68,6 +69,7 @@ def unresolvable(cls, did: str, **kwargs): constructor Returns: An instance of RotateProblemReport + """ return cls.for_code(ProblemReportReason.UNRESOLVABLE, did, **kwargs) @@ -81,6 +83,7 @@ def unsupported_method(cls, did: str, **kwargs): constructor Returns: An instance of RotateProblemReport + """ return cls.for_code(ProblemReportReason.UNSUPPORTED_METHOD, did, **kwargs) @@ -94,6 +97,7 @@ def unresolvable_services(cls, did: str, **kwargs): constructor Returns: An instance of RotateProblemReport + """ return cls.for_code(ProblemReportReason.UNRESOLVABLE_SERVICES, did, **kwargs) @@ -107,6 +111,7 @@ def unrecordable_keys(cls, did: str, **kwargs): constructor Returns: An instance of RotateProblemReport + """ # noqa: E501 return cls.for_code(ProblemReportReason.UNRECORDABLE_KEYS, did, **kwargs) diff --git a/acapy_agent/protocols/did_rotate/v1_0/routes.py b/acapy_agent/protocols/did_rotate/v1_0/routes.py index 15c485371f..b9d183270f 100644 --- a/acapy_agent/protocols/did_rotate/v1_0/routes.py +++ b/acapy_agent/protocols/did_rotate/v1_0/routes.py @@ -55,7 +55,6 @@ class DIDRotateRequestJSONSchema(OpenAPISchema): @tenant_authentication async def rotate(request: web.BaseRequest): """Request to rotate a DID.""" - LOGGER.debug("DID Rotate Rotate request >>>") context: AdminRequestContext = request["context"] @@ -97,7 +96,6 @@ async def rotate(request: web.BaseRequest): @tenant_authentication async def hangup(request: web.BaseRequest): """Hangup a DID rotation.""" - LOGGER.debug("DID Rotate Hangup request >>>") context: AdminRequestContext = request["context"] @@ -120,14 +118,12 @@ async def hangup(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes([web.post("/did-rotate/{conn_id}/rotate", rotate)]) app.add_routes([web.post("/did-rotate/{conn_id}/hangup", hangup)]) def post_process_routes(app: web.Application): """Amend Swagger API.""" - if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] app._state["swagger_dict"]["tags"].append( diff --git a/acapy_agent/protocols/didcomm_prefix.py b/acapy_agent/protocols/didcomm_prefix.py index ee5475fec9..b472edcb58 100644 --- a/acapy_agent/protocols/didcomm_prefix.py +++ b/acapy_agent/protocols/didcomm_prefix.py @@ -8,7 +8,6 @@ def qualify(msg_type: str, prefix: str): """Qualify a message type with a prefix, if unqualified.""" - return msg_type if QUALIFIED.match(msg_type or "") else f"{prefix}/{msg_type}" @@ -20,13 +19,11 @@ class DIDCommPrefix(Enum): def qualify(self, msg_type: str) -> str: """Qualify input message type with prefix and separator.""" - return qualify(msg_type, self.value) @classmethod def qualify_all(cls, messages: dict) -> dict: """Apply all known prefixes to a dictionary of message types.""" - return {qualify(k, pfx.value): v for pfx in cls for k, v in messages.items()} @staticmethod @@ -35,7 +32,6 @@ def qualify_current(slug: str) -> str: This method now will always use the new prefix. """ - return qualify(slug, DIDCommPrefix.NEW.value) @staticmethod diff --git a/acapy_agent/protocols/didexchange/v1_0/handlers/complete_handler.py b/acapy_agent/protocols/didexchange/v1_0/handlers/complete_handler.py index 6d14129674..9dd7ebe197 100644 --- a/acapy_agent/protocols/didexchange/v1_0/handlers/complete_handler.py +++ b/acapy_agent/protocols/didexchange/v1_0/handlers/complete_handler.py @@ -14,6 +14,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback + """ self._logger.debug("DIDXCompleteHandler called with context %s", context) assert isinstance(context.message, DIDXComplete) diff --git a/acapy_agent/protocols/didexchange/v1_0/handlers/invitation_handler.py b/acapy_agent/protocols/didexchange/v1_0/handlers/invitation_handler.py index 8976e72b8b..5b67bbd6a0 100644 --- a/acapy_agent/protocols/didexchange/v1_0/handlers/invitation_handler.py +++ b/acapy_agent/protocols/didexchange/v1_0/handlers/invitation_handler.py @@ -14,8 +14,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug("InvitationHandler called with context %s", context) assert isinstance(context.message, InvitationMessage) diff --git a/acapy_agent/protocols/didexchange/v1_0/handlers/request_handler.py b/acapy_agent/protocols/didexchange/v1_0/handlers/request_handler.py index 19d145d37d..f4981fca2e 100644 --- a/acapy_agent/protocols/didexchange/v1_0/handlers/request_handler.py +++ b/acapy_agent/protocols/didexchange/v1_0/handlers/request_handler.py @@ -16,8 +16,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug("DIDXRequestHandler called with context %s", context) assert isinstance(context.message, DIDXRequest) diff --git a/acapy_agent/protocols/didexchange/v1_0/handlers/response_handler.py b/acapy_agent/protocols/didexchange/v1_0/handlers/response_handler.py index 08fbe65ae4..10e3eedeba 100644 --- a/acapy_agent/protocols/didexchange/v1_0/handlers/response_handler.py +++ b/acapy_agent/protocols/didexchange/v1_0/handlers/response_handler.py @@ -15,6 +15,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback + """ self._logger.debug("DIDXResponseHandler called with context %s", context) assert isinstance(context.message, DIDXResponse) diff --git a/acapy_agent/protocols/didexchange/v1_0/manager.py b/acapy_agent/protocols/didexchange/v1_0/manager.py index 42c2876fd4..273ab8c925 100644 --- a/acapy_agent/protocols/didexchange/v1_0/manager.py +++ b/acapy_agent/protocols/didexchange/v1_0/manager.py @@ -59,6 +59,7 @@ def __init__(self, profile: Profile): Args: profile: The profile for this did exchange manager + """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -233,7 +234,6 @@ async def create_request_implicit( `their_public_did` and `my_did`. """ - if use_did and use_did_method: raise DIDXManagerError("Cannot specify both use_did and use_did_method") @@ -919,7 +919,6 @@ async def accept_response( in the request-sent state """ - conn_rec = None if response._thread: # identify the request by the thread ID diff --git a/acapy_agent/protocols/didexchange/v1_0/messages/problem_report.py b/acapy_agent/protocols/didexchange/v1_0/messages/problem_report.py index 36e5f8e295..600f0b2ed4 100644 --- a/acapy_agent/protocols/didexchange/v1_0/messages/problem_report.py +++ b/acapy_agent/protocols/didexchange/v1_0/messages/problem_report.py @@ -50,7 +50,6 @@ class Meta: @validates_schema def validate_fields(self, data, **kwargs): """Validate schema fields.""" - if not data.get("description", {}).get("code", ""): raise ValidationError("Value for description.code must be present") elif data.get("description", {}).get("code", "") not in [ diff --git a/acapy_agent/protocols/didexchange/v1_0/messages/request.py b/acapy_agent/protocols/didexchange/v1_0/messages/request.py index 4817fb3656..2babc3d06f 100644 --- a/acapy_agent/protocols/didexchange/v1_0/messages/request.py +++ b/acapy_agent/protocols/didexchange/v1_0/messages/request.py @@ -49,6 +49,7 @@ def __init__( goal: (optional) is a self-attested string that the receiver may want to display to the user about the context-specific goal of the request message. kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.label = label diff --git a/acapy_agent/protocols/didexchange/v1_0/messages/response.py b/acapy_agent/protocols/didexchange/v1_0/messages/response.py index 9d97ed20ca..cf037a2a77 100644 --- a/acapy_agent/protocols/didexchange/v1_0/messages/response.py +++ b/acapy_agent/protocols/didexchange/v1_0/messages/response.py @@ -41,6 +41,7 @@ def __init__( did_doc_attach: signed DID doc attachment did_rotate_attach: signed DID rotation attachment kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.did = did diff --git a/acapy_agent/protocols/didexchange/v1_0/routes.py b/acapy_agent/protocols/didexchange/v1_0/routes.py index f9c21e8266..3b7ea6c382 100644 --- a/acapy_agent/protocols/didexchange/v1_0/routes.py +++ b/acapy_agent/protocols/didexchange/v1_0/routes.py @@ -478,7 +478,6 @@ async def didx_reject(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.post( @@ -495,7 +494,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/discovery/v1_0/manager.py b/acapy_agent/protocols/discovery/v1_0/manager.py index cb0edabdd6..30c5117388 100644 --- a/acapy_agent/protocols/discovery/v1_0/manager.py +++ b/acapy_agent/protocols/discovery/v1_0/manager.py @@ -26,6 +26,7 @@ def __init__(self, profile: Profile): Args: profile: The profile for this manager + """ self._profile = profile self._logger = logging.getLogger(__name__) diff --git a/acapy_agent/protocols/discovery/v1_0/messages/disclose.py b/acapy_agent/protocols/discovery/v1_0/messages/disclose.py index 0148572a6c..d622e3a774 100644 --- a/acapy_agent/protocols/discovery/v1_0/messages/disclose.py +++ b/acapy_agent/protocols/discovery/v1_0/messages/disclose.py @@ -26,6 +26,7 @@ def __init__(self, *, protocols: Sequence[Mapping[str, Mapping]] = None, **kwarg Args: protocols: A mapping of protocol names to a dictionary of properties kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.protocols = list(protocols) if protocols else [] diff --git a/acapy_agent/protocols/discovery/v1_0/messages/query.py b/acapy_agent/protocols/discovery/v1_0/messages/query.py index 7c055ea7f1..a6c4eacfbe 100644 --- a/acapy_agent/protocols/discovery/v1_0/messages/query.py +++ b/acapy_agent/protocols/discovery/v1_0/messages/query.py @@ -32,6 +32,7 @@ def __init__( query: The query string to match against supported message types comment: An optional comment kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.query = query diff --git a/acapy_agent/protocols/discovery/v1_0/routes.py b/acapy_agent/protocols/discovery/v1_0/routes.py index 3b1f42a305..941d6840d8 100644 --- a/acapy_agent/protocols/discovery/v1_0/routes.py +++ b/acapy_agent/protocols/discovery/v1_0/routes.py @@ -129,7 +129,6 @@ async def query_records(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/discover-features/query", query_features, allow_head=False), @@ -140,7 +139,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/discovery/v2_0/manager.py b/acapy_agent/protocols/discovery/v2_0/manager.py index f60d579f09..2fae35dd1c 100644 --- a/acapy_agent/protocols/discovery/v2_0/manager.py +++ b/acapy_agent/protocols/discovery/v2_0/manager.py @@ -27,6 +27,7 @@ def __init__(self, profile: Profile): Args: profile: The profile for this manager + """ self._profile = profile self._logger = logging.getLogger(__name__) diff --git a/acapy_agent/protocols/discovery/v2_0/messages/disclosures.py b/acapy_agent/protocols/discovery/v2_0/messages/disclosures.py index 2464142674..1cfb50f06e 100644 --- a/acapy_agent/protocols/discovery/v2_0/messages/disclosures.py +++ b/acapy_agent/protocols/discovery/v2_0/messages/disclosures.py @@ -76,6 +76,7 @@ def __init__(self, *, disclosures: Sequence[Mapping] = None, **kwargs): Args: disclosures: A mapping of protocol names to a dictionary of properties kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.disclosures = list(disclosures) if disclosures else [] diff --git a/acapy_agent/protocols/discovery/v2_0/messages/queries.py b/acapy_agent/protocols/discovery/v2_0/messages/queries.py index 6f03a04ac8..34fe20c680 100644 --- a/acapy_agent/protocols/discovery/v2_0/messages/queries.py +++ b/acapy_agent/protocols/discovery/v2_0/messages/queries.py @@ -67,6 +67,7 @@ def __init__(self, *, queries: Sequence[QueryItem] = None, **kwargs): Args: queries: The query string to match against supported message types kwargs: Additional key word arguments for the message + """ super().__init__(**kwargs) self.queries = queries diff --git a/acapy_agent/protocols/discovery/v2_0/routes.py b/acapy_agent/protocols/discovery/v2_0/routes.py index f6a0723c78..aaa9f3eba8 100644 --- a/acapy_agent/protocols/discovery/v2_0/routes.py +++ b/acapy_agent/protocols/discovery/v2_0/routes.py @@ -139,7 +139,6 @@ async def query_records(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/discover-features-2.0/queries", query_features, allow_head=False), @@ -150,7 +149,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/endorsed_transaction_response_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/endorsed_transaction_response_handler.py index a5055d8b76..42762c34cb 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/endorsed_transaction_response_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/endorsed_transaction_response_handler.py @@ -21,8 +21,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug( "EndorsedTransactionResponseHandler called with context %s", context ) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/refused_transaction_response_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/refused_transaction_response_handler.py index a2746eff17..e225bb753a 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/refused_transaction_response_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/refused_transaction_response_handler.py @@ -19,8 +19,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug( "RefusedTransactionResponseHandler called with context %s", context ) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_acknowledgement_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_acknowledgement_handler.py index 72ab2c00f6..32221342da 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_acknowledgement_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_acknowledgement_handler.py @@ -19,8 +19,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug( "TransactionAcknowledgementHandler called with context %s", context ) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_cancel_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_cancel_handler.py index 7f382fd2e2..975d665f78 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_cancel_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_cancel_handler.py @@ -19,8 +19,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug("TransactionCancelHandler called with context %s", context) assert isinstance(context.message, CancelTransaction) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_job_to_send_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_job_to_send_handler.py index d06d4e9fdd..fba5ef7d78 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_job_to_send_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_job_to_send_handler.py @@ -19,8 +19,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug("TransactionJobToSendHandler called with context %s", context) assert isinstance(context.message, TransactionJobToSend) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_request_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_request_handler.py index 15fe834e77..dfb6efca09 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_request_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_request_handler.py @@ -21,8 +21,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug("TransactionRequestHandler called with context %s", context) assert isinstance(context.message, TransactionRequest) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_resend_handler.py b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_resend_handler.py index 7f1c4c1047..2aef142f0d 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_resend_handler.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/handlers/transaction_resend_handler.py @@ -19,8 +19,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback - """ + """ self._logger.debug("TransactionResendHandler called with context %s", context) assert isinstance(context.message, TransactionResend) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/manager.py b/acapy_agent/protocols/endorse_transaction/v1_0/manager.py index fefbec14f7..18fe833827 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/manager.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/manager.py @@ -56,6 +56,7 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this transaction manager + """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -84,7 +85,6 @@ async def create_record( The transaction Record """ - messages_attach_dict = { "@id": str(uuid4()), "mime-type": "application/json", @@ -153,7 +153,6 @@ async def create_request( 'STATE_TRANSACTION_CREATED' state. """ - if transaction.state != TransactionRecord.STATE_TRANSACTION_CREATED: raise TransactionManagerError( f"Cannot create a request for transaction record" @@ -204,8 +203,8 @@ async def receive_request(self, request: TransactionRequest, connection_id: str) Args: request: A Transaction Request connection_id: The connection id related to this transaction record - """ + """ transaction = TransactionRecord() transaction._type = TransactionRecord.SIGNATURE_REQUEST @@ -249,7 +248,6 @@ async def create_endorse_response( The updated transaction and an endorsed response """ - if transaction.state not in ( TransactionRecord.STATE_REQUEST_RECEIVED, TransactionRecord.STATE_TRANSACTION_RESENT_RECEIVED, @@ -375,8 +373,8 @@ async def receive_endorse_response(self, response: EndorsedTransactionResponse): Args: response: The Endorsed Transaction Response - """ + """ async with self._profile.session() as session: transaction = await TransactionRecord.retrieve_by_id( session, response.transaction_id @@ -424,7 +422,6 @@ async def complete_transaction( The updated transaction """ - ledger_transaction = transaction.messages_attach[0]["data"]["json"] # check our goal code! @@ -521,8 +518,8 @@ async def receive_transaction_acknowledgement( Args: response: The transaction acknowledgement connection_id: The connection_id related to this Transaction Record - """ + """ async with self._profile.session() as session: transaction = await TransactionRecord.retrieve_by_connection_and_thread( session, connection_id, response.thread_id @@ -587,7 +584,6 @@ async def create_refuse_response( The updated transaction and the refused response """ - if transaction.state not in ( TransactionRecord.STATE_REQUEST_RECEIVED, TransactionRecord.STATE_TRANSACTION_RESENT_RECEIVED, @@ -628,8 +624,8 @@ async def receive_refuse_response(self, response: RefusedTransactionResponse): Args: response: The refused transaction response - """ + """ async with self._profile.session() as session: transaction = await TransactionRecord.retrieve_by_id( session, response.transaction_id @@ -658,7 +654,6 @@ async def cancel_transaction(self, transaction: TransactionRecord, state: str): The updated transaction and the cancelled transaction response """ - if transaction.state not in ( TransactionRecord.STATE_REQUEST_SENT, TransactionRecord.STATE_TRANSACTION_RESENT, @@ -686,8 +681,8 @@ async def receive_cancel_transaction( Args: response: The cancel transaction response connection_id: The connection_id related to this Transaction Record - """ + """ async with self._profile.session() as session: transaction = await TransactionRecord.retrieve_by_connection_and_thread( session, connection_id, response.thread_id @@ -710,7 +705,6 @@ async def transaction_resend(self, transaction: TransactionRecord, state: str): The updated transaction and the resend response """ - if transaction.state not in ( TransactionRecord.STATE_TRANSACTION_REFUSED, TransactionRecord.STATE_TRANSACTION_CANCELLED, @@ -739,8 +733,8 @@ async def receive_transaction_resend( Args: response: The Resend transaction response connection_id: The connection_id related to this Transaction Record - """ + """ async with self._profile.session() as session: transaction = await TransactionRecord.retrieve_by_connection_and_thread( session, connection_id, response.thread_id @@ -763,7 +757,6 @@ async def set_transaction_my_job(self, record: ConnRecord, transaction_my_job: s The transaction job that is send to other agent """ - async with self._profile.session() as session: value = await record.metadata_get(session, "transaction_jobs") if value: @@ -784,8 +777,8 @@ async def set_transaction_their_job( Args: tx_job_received: The transaction job that is received from the other agent connection: connection to set metadata on - """ + """ try: async with self._profile.session() as session: value = await connection.metadata_get(session, "transaction_jobs") @@ -812,8 +805,8 @@ async def endorsed_txn_post_processing( would be stored in wallet. ledger_response: The ledger response connection_record: The connection record - """ + """ if isinstance(ledger_response, str): ledger_response = json.loads(ledger_response) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py index 4f2037a43f..2701212fed 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py @@ -36,6 +36,7 @@ def __init__( state: State of the transaction record thread_id: Thread id of transaction record kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py index e5acece8bd..daeb157409 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py @@ -45,6 +45,7 @@ def __init__( endorser_did: The public did of the endorser who endorses the transaction ledger_response: The response from the ledger kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/messages_attach.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/messages_attach.py index 75bbdf704a..36c5daa119 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/messages_attach.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/messages_attach.py @@ -44,8 +44,8 @@ def __init__( taaDigest: The digest of the latest TAA present on the ledger time: The time when the latest TAA was set/enabled kwargs: Additional keyword arguments for the message - """ + """ super().__init__(**kwargs) transaction_message = transaction_message or {} diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py index 803023d14f..682750422f 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py @@ -43,6 +43,7 @@ def __init__( state: The state of the transaction record endorser_did: The public did of the endorser who refuses the transaction kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py index 22c5524cdc..6e23afef38 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py @@ -37,6 +37,7 @@ def __init__( thread_id: Thread id of transaction record ledger_response: Response from the ledger kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.thread_id = thread_id diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py index 88cdb2b1a9..11948fe359 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py @@ -36,7 +36,6 @@ def __init__( kwargs: Additional keyword arguments for the message """ - super().__init__(**kwargs) self.job = job diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_request.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_request.py index 4e70c4079a..8072473a35 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_request.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_request.py @@ -44,6 +44,7 @@ def __init__( messages_attach: The attached message describing the actual transaction endorser_write_txn: Request Endorser to write the ledger transaction kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.transaction_id = transaction_id diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py index 5b52e4c805..693eb4291c 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py @@ -36,6 +36,7 @@ def __init__( state: State of the transaction record thread_id: Thread id of transaction record kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/models/transaction_record.py b/acapy_agent/protocols/endorse_transaction/v1_0/models/transaction_record.py index 91ab6b33f8..11b98a3a31 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/models/transaction_record.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/models/transaction_record.py @@ -78,7 +78,6 @@ def __init__( **kwargs, ): """Initialize a new TransactionRecord.""" - super().__init__(transaction_id, state or self.STATE_INIT, **kwargs) self._type = _type self.comment = comment diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/routes.py b/acapy_agent/protocols/endorse_transaction/v1_0/routes.py index a716277120..9a6c484e41 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/routes.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/routes.py @@ -131,8 +131,8 @@ async def transactions_list(request: web.BaseRequest): request: aiohttp request object Returns: The transaction list response - """ + """ context: AdminRequestContext = request["context"] tag_filter = {} @@ -161,8 +161,8 @@ async def transactions_retrieve(request: web.BaseRequest): request: aiohttp request object Returns: The transaction record response - """ + """ context: AdminRequestContext = request["context"] transaction_id = request.match_info["tran_id"] @@ -195,8 +195,8 @@ async def transaction_create_request(request: web.BaseRequest): request: aiohttp request object Returns: The transaction record - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] transaction_id = request.query.get("tran_id") @@ -286,8 +286,8 @@ async def endorse_transaction_response(request: web.BaseRequest): request: aiohttp request object Returns: The updated transaction record details - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] @@ -356,8 +356,8 @@ async def refuse_transaction_response(request: web.BaseRequest): request: aiohttp request object Returns: The updated transaction record details - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] @@ -421,8 +421,8 @@ async def cancel_transaction(request: web.BaseRequest): request: aiohttp request object Returns: The updated transaction record details - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] transaction_id = request.match_info["tran_id"] @@ -484,8 +484,8 @@ async def transaction_resend(request: web.BaseRequest): request: aiohttp request object Returns: The updated transaction record details - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] transaction_id = request.match_info["tran_id"] @@ -547,8 +547,8 @@ async def set_endorser_role(request: web.BaseRequest): request: aiohttp request object Returns: The assigned transaction jobs - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] connection_id = request.match_info["conn_id"] @@ -588,8 +588,8 @@ async def set_endorser_info(request: web.BaseRequest): request: aiohttp request object Returns: The assigned endorser information - """ + """ context: AdminRequestContext = request["context"] connection_id = request.match_info["conn_id"] endorser_did = request.query.get("endorser_did") @@ -652,8 +652,8 @@ async def transaction_write(request: web.BaseRequest): request: aiohttp request object Returns: The returned ledger response - """ + """ context: AdminRequestContext = request["context"] outbound_handler = request["outbound_message_router"] transaction_id = request.match_info["tran_id"] @@ -698,7 +698,6 @@ def register_events(event_bus: EventBus): async def on_startup_event(profile: Profile, event: Event): """Handle any events we need to support.""" - await attempt_auto_author_with_endorser_setup(profile) @@ -710,7 +709,6 @@ async def on_shutdown_event(profile: Profile, event: Event): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/transactions", transactions_list, allow_head=False), @@ -729,7 +727,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/introduction/v0_1/base_service.py b/acapy_agent/protocols/introduction/v0_1/base_service.py index 50e8d7aa9b..d680afca70 100644 --- a/acapy_agent/protocols/introduction/v0_1/base_service.py +++ b/acapy_agent/protocols/introduction/v0_1/base_service.py @@ -45,6 +45,7 @@ async def start_introduction( outbound_handler: The outbound handler coroutine for sending a message session: Profile session to use for connection, introduction records message: The message to use when requesting the invitation + """ @abstractmethod @@ -62,4 +63,5 @@ async def return_invitation( invitation: The received Invitation message session: Profile session to use for introduction records outbound_handler: The outbound handler coroutine for sending a message + """ diff --git a/acapy_agent/protocols/introduction/v0_1/demo_service.py b/acapy_agent/protocols/introduction/v0_1/demo_service.py index bc682ce3f2..fb2ed3d938 100644 --- a/acapy_agent/protocols/introduction/v0_1/demo_service.py +++ b/acapy_agent/protocols/introduction/v0_1/demo_service.py @@ -35,6 +35,7 @@ async def start_introduction( outbound_handler: The outbound handler coroutine for sending a message session: Profile session to use for connection, introduction records message: The message to use when requesting the invitation + """ try: init_connection = await ConnRecord.retrieve_by_id(session, init_connection_id) @@ -94,6 +95,7 @@ async def return_invitation( invitation: The received (Introduction) Invitation message session: Profile session to use for introduction records outbound_handler: The outbound handler coroutine for sending a message + """ thread_id = invitation._thread_id diff --git a/acapy_agent/protocols/introduction/v0_1/messages/forward_invitation.py b/acapy_agent/protocols/introduction/v0_1/messages/forward_invitation.py index bd29ca0983..f6f8ae4bbe 100644 --- a/acapy_agent/protocols/introduction/v0_1/messages/forward_invitation.py +++ b/acapy_agent/protocols/introduction/v0_1/messages/forward_invitation.py @@ -39,6 +39,7 @@ def __init__( invitation: The connection invitation message: Comments on the introduction kwargs: Additional key word arguments for the message + """ super().__init__(**kwargs) self.invitation = invitation diff --git a/acapy_agent/protocols/introduction/v0_1/messages/invitation.py b/acapy_agent/protocols/introduction/v0_1/messages/invitation.py index 178dcfaa43..2f503d980f 100644 --- a/acapy_agent/protocols/introduction/v0_1/messages/invitation.py +++ b/acapy_agent/protocols/introduction/v0_1/messages/invitation.py @@ -37,6 +37,7 @@ def __init__( invitation: The connection invitation message: Comments on the introduction kwargs: Additional key word arguments for the message + """ super().__init__(**kwargs) self.invitation = invitation diff --git a/acapy_agent/protocols/introduction/v0_1/messages/invitation_request.py b/acapy_agent/protocols/introduction/v0_1/messages/invitation_request.py index a6966759f4..f7d97c87e2 100644 --- a/acapy_agent/protocols/introduction/v0_1/messages/invitation_request.py +++ b/acapy_agent/protocols/introduction/v0_1/messages/invitation_request.py @@ -31,6 +31,7 @@ def __init__( responder: The name of the agent initiating the introduction message: Comments on the introduction kwargs: Additional key word arguments for the message + """ super().__init__(**kwargs) self.responder = responder diff --git a/acapy_agent/protocols/introduction/v0_1/routes.py b/acapy_agent/protocols/introduction/v0_1/routes.py index 591b14811c..16030ae7a0 100644 --- a/acapy_agent/protocols/introduction/v0_1/routes.py +++ b/acapy_agent/protocols/introduction/v0_1/routes.py @@ -91,7 +91,6 @@ async def introduction_start(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [web.post("/connections/{conn_id}/start-introduction", introduction_start)] ) @@ -99,7 +98,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_ack_handler.py b/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_ack_handler.py index 7ac46c6f43..5c71237bbd 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_ack_handler.py +++ b/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_ack_handler.py @@ -18,6 +18,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ r_time = get_timer() diff --git a/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_problem_report_handler.py b/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_problem_report_handler.py index 2582b11b9b..dc1ad1aa00 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_problem_report_handler.py +++ b/acapy_agent/protocols/issue_credential/v1_0/handlers/credential_problem_report_handler.py @@ -17,6 +17,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug( "Issue-credential v1.0 problem report handler called with context %s", diff --git a/acapy_agent/protocols/issue_credential/v1_0/manager.py b/acapy_agent/protocols/issue_credential/v1_0/manager.py index 9cbd5b6aec..daca3cc20e 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/manager.py +++ b/acapy_agent/protocols/issue_credential/v1_0/manager.py @@ -55,6 +55,7 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this credential manager + """ self._profile = profile @@ -70,7 +71,6 @@ def profile(self) -> Profile: async def _match_sent_cred_def_id(self, tag_query: Mapping[str, str]) -> str: """Return most recent matching id of cred def that agent sent to ledger.""" - async with self._profile.session() as session: storage = session.inject(BaseStorage) found = await storage.find_all_records( @@ -584,7 +584,6 @@ async def issue_credential( Tuple: (Updated credential exchange record, credential message) """ - credential_ser = None if cred_ex_record.credential: diff --git a/acapy_agent/protocols/issue_credential/v1_0/messages/credential_proposal.py b/acapy_agent/protocols/issue_credential/v1_0/messages/credential_proposal.py index d53ce0e549..6bd4d6128c 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/messages/credential_proposal.py +++ b/acapy_agent/protocols/issue_credential/v1_0/messages/credential_proposal.py @@ -59,6 +59,7 @@ def __init__( cred_def_id: credential definition identifier issuer_did: credential issuer DID kwargs: additional key-value arguments to map into message class properties + """ super().__init__(_id, **kwargs) self.comment = comment diff --git a/acapy_agent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py b/acapy_agent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py index 9a2e75b06b..871657aac9 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py +++ b/acapy_agent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py @@ -52,12 +52,10 @@ def list_plain(plain: dict): def b64_decoded_value(self) -> str: """Value, base64-decoded if applicable.""" - return b64_to_str(self.value) if self.value and self.mime_type else self.value def __eq__(self, other): """Equality comparator.""" - if self.name != other.name: return False # distinct attribute names @@ -147,7 +145,6 @@ def attr_dict(self, decode: bool = False): decode: whether first to decode attributes with MIME type """ - return { attr.name: ( b64_to_str(attr.value) if attr.mime_type and decode else attr.value diff --git a/acapy_agent/protocols/issue_credential/v1_0/models/credential_exchange.py b/acapy_agent/protocols/issue_credential/v1_0/models/credential_exchange.py index a73da8c01d..b737e6c151 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/models/credential_exchange.py +++ b/acapy_agent/protocols/issue_credential/v1_0/models/credential_exchange.py @@ -206,8 +206,8 @@ async def save_error_state( reason: A reason to add to the log log_params: Additional parameters to log log_override: Override configured logging regimen, print to stderr instead - """ + """ if self._last_state == state: # already done return @@ -232,8 +232,8 @@ async def emit_event(self, session: ProfileSession, payload: Optional[Any] = Non Args: session: The profile session to use payload: The event payload - """ + """ if not self.RECORD_TOPIC: return diff --git a/acapy_agent/protocols/issue_credential/v1_0/routes.py b/acapy_agent/protocols/issue_credential/v1_0/routes.py index 6dc8ec793c..eac5335332 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/routes.py +++ b/acapy_agent/protocols/issue_credential/v1_0/routes.py @@ -747,7 +747,6 @@ async def _create_free_offer( trace_msg: Optional[bool] = None, ): """Create a credential offer and related exchange record.""" - credential_preview = CredentialPreview.deserialize(preview_spec) credential_proposal = CredentialProposal( comment=comment, @@ -1451,7 +1450,6 @@ async def credential_exchange_remove(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get( @@ -1501,7 +1499,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py index 2e54c95a13..a013357181 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/anoncreds/handler.py @@ -16,12 +16,12 @@ AnonCredsCredentialDefinitionProposal, ) from ......anoncreds.models.credential_request import AnonCredsCredRequestSchema +from ......anoncreds.models.issuer_cred_rev_record import IssuerCredRevRecord from ......anoncreds.registry import AnonCredsRegistry from ......anoncreds.revocation.revocation import AnonCredsRevocation from ......cache.base import BaseCache from ......messaging.credential_definitions.util import CRED_DEF_SENT_RECORD_TYPE from ......messaging.decorators.attach_decorator import AttachDecorator -from ......anoncreds.models.issuer_cred_rev_record import IssuerCredRevRecord from ......storage.base import BaseStorage from ...message_types import ( ATTACHMENT_FORMAT, @@ -81,7 +81,6 @@ def validate_fields(cls, message_type: str, attachment_data: Mapping): async def get_detail_record(self, cred_ex_id: str) -> V20CredExRecordAnonCreds: """Retrieve credential exchange detail record by cred_ex_id.""" - async with self.profile.session() as session: records = await AnonCredsCredFormatHandler.format.detail.query_by_cred_ex_id( session, cred_ex_id @@ -148,7 +147,6 @@ def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment async def _match_sent_cred_def_id(self, tag_query: Mapping[str, str]) -> str: """Return most recent matching id of cred def that agent sent to ledger.""" - async with self.profile.session() as session: storage = session.inject(BaseStorage) found = await storage.find_all_records( @@ -181,7 +179,6 @@ async def create_offer( self, cred_proposal_message: V20CredProposal ) -> CredFormatAttachment: """Create anoncreds credential offer.""" - issuer = AnonCredsIssuer(self.profile) cache = self.profile.inject_or(BaseCache) @@ -432,7 +429,6 @@ async def store_credential( self, cred_ex_record: V20CredExRecord, cred_id: Optional[str] = None ) -> None: """Store anoncreds credential.""" - # For backwards compatibility, remove indy backup when indy format is retired from ..indy.handler import IndyCredFormatHandler diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/indy/handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/indy/handler.py index c177b40b4f..737dadcc72 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/indy/handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/indy/handler.py @@ -99,7 +99,6 @@ def validate_fields(cls, message_type: str, attachment_data: Mapping): async def get_detail_record(self, cred_ex_id: str) -> V20CredExRecordIndy: """Retrieve credential exchange detail record by cred_ex_id.""" - async with self.profile.session() as session: records = await IndyCredFormatHandler.format.detail.query_by_cred_ex_id( session, cred_ex_id @@ -136,7 +135,6 @@ def get_format_identifier(self, message_type: str) -> str: str: Issue credential attachment format identifier """ - return ATTACHMENT_FORMAT[message_type][IndyCredFormatHandler.format.api] def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment: @@ -155,7 +153,6 @@ def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment CredFormatAttachment: Credential format and attachment data objects """ - return ( V20CredFormat( attach_id=IndyCredFormatHandler.format.api, @@ -166,7 +163,6 @@ def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment async def _match_sent_cred_def_id(self, tag_query: Mapping[str, str]) -> str: """Return most recent matching id of cred def that agent sent to ledger.""" - async with self.profile.session() as session: storage = session.inject(BaseStorage) found = await storage.find_all_records( @@ -206,7 +202,6 @@ async def create_offer( self, cred_proposal_message: V20CredProposal ) -> CredFormatAttachment: """Create indy credential offer.""" - if isinstance(self.profile, AskarAnonCredsProfile): raise V20CredFormatError( "This issuer is anoncreds capable. Please use the anoncreds format." @@ -295,7 +290,6 @@ async def create_request( self, cred_ex_record: V20CredExRecord, request_data: Optional[Mapping] = None ) -> CredFormatAttachment: """Create indy credential request.""" - # Create the request with the anoncreds handler if agent is anoncreds capable if self.anoncreds_handler: return await self.anoncreds_handler.create_request( diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py index c1320f33de..b21ccc0e21 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py @@ -80,7 +80,6 @@ def validate_fields(cls, message_type: str, attachment_data: Mapping) -> None: async def get_detail_record(self, cred_ex_id: str) -> V20CredExRecordLDProof: """Retrieve credential exchange detail record by cred_ex_id.""" - async with self.profile.session() as session: records = await LDProofCredFormatHandler.format.detail.query_by_cred_ex_id( session, cred_ex_id diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/models/cred_detail_options.py b/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/models/cred_detail_options.py index 7a9b1ca549..24fbd15409 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/models/cred_detail_options.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/ld_proof/models/cred_detail_options.py @@ -30,7 +30,6 @@ def __init__( credential_status: Optional[dict] = None, ) -> None: """Initialize the LDProofVCDetailOptions instance.""" - self.proof_type = proof_type self.proof_purpose = proof_purpose self.created = created diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/handler.py b/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/handler.py index 119fa74a41..40e5657944 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/handler.py @@ -13,6 +13,7 @@ from ......anoncreds.holder import AnonCredsHolder, AnonCredsHolderError from ......anoncreds.issuer import AnonCredsIssuer +from ......anoncreds.models.issuer_cred_rev_record import IssuerCredRevRecord from ......anoncreds.registry import AnonCredsRegistry from ......anoncreds.revocation.revocation import AnonCredsRevocation from ......cache.base import BaseCache @@ -27,7 +28,6 @@ ) from ......messaging.decorators.attach_decorator import AttachDecorator from ......multitenant.base import BaseMultitenantManager -from ......anoncreds.models.issuer_cred_rev_record import IssuerCredRevRecord from ......storage.base import BaseStorage from ......vc.vc_ld import VerifiableCredential from ......wallet.base import BaseWallet @@ -85,6 +85,7 @@ def validate_fields(cls, message_type: str, attachment_data: Mapping): The attachment data to valide Raises: Exception: When the data is not valid. + """ mapping = { CRED_20_PROPOSAL: CredDefQueryStringSchema, @@ -101,7 +102,6 @@ def validate_fields(cls, message_type: str, attachment_data: Mapping): async def get_detail_record(self, cred_ex_id: str) -> V20CredExRecordIndy: """Retrieve credential exchange detail record by cred_ex_id.""" - async with self.profile.session() as session: records = await VCDICredFormatHandler.format.detail.query_by_cred_ex_id( session, cred_ex_id @@ -135,6 +135,7 @@ def get_format_identifier(self, message_type: str) -> str: message_type (str): Message type for which to return the format identifier Returns: str: Issue credential attachment format identifier + """ return ATTACHMENT_FORMAT[message_type][VCDICredFormatHandler.format.api] @@ -151,6 +152,7 @@ def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment data (dict): The data to include in the attach decorator Returns: CredFormatAttachment: Credential format and attachment data objects + """ return ( V20CredFormat( @@ -162,7 +164,6 @@ def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment async def _match_sent_cred_def_id(self, tag_query: Mapping[str, str]) -> str: """Return most recent matching id of cred def that agent sent to ledger.""" - async with self.profile.session() as session: storage = session.inject(BaseStorage) found = await storage.find_all_records( @@ -197,7 +198,6 @@ async def create_offer( self, cred_proposal_message: V20CredProposal ) -> CredFormatAttachment: """Create vcdi credential offer.""" - issuer = AnonCredsIssuer(self.profile) # TODO use the ledger registry in the anoncreds module, # or move the functionality into the ledger class. diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py b/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py index 130d29a73b..a3574ee44c 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py @@ -25,6 +25,7 @@ def __init__( Args: credential: credential object kwargs: additional keyword arguments + """ super().__init__(**kwargs) self.credential = credential diff --git a/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py b/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py index 95ecc2d67b..da862b9123 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py +++ b/acapy_agent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py @@ -175,6 +175,7 @@ def __init__( binding_method: required if binding_required is true credential: credential object kwargs: additional key-value arguments to map into message class properties + """ super().__init__(**kwargs) self.data_model_versions_supported = data_model_versions_supported diff --git a/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_ack_handler.py b/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_ack_handler.py index f4ac985f03..eb3a1ad6c7 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_ack_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_ack_handler.py @@ -18,6 +18,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ r_time = get_timer() diff --git a/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_problem_report_handler.py b/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_problem_report_handler.py index f513496c79..5e0316b9d3 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_problem_report_handler.py +++ b/acapy_agent/protocols/issue_credential/v2_0/handlers/cred_problem_report_handler.py @@ -17,6 +17,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug( "Issue-credential v2.0 problem report handler called with context %s", diff --git a/acapy_agent/protocols/issue_credential/v2_0/manager.py b/acapy_agent/protocols/issue_credential/v2_0/manager.py index 124e832c47..d5e2375b0e 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/manager.py +++ b/acapy_agent/protocols/issue_credential/v2_0/manager.py @@ -34,6 +34,7 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this credential manager + """ self._profile = profile @@ -111,7 +112,6 @@ async def create_proposal( Resulting credential exchange record including credential proposal """ - if auto_remove is None: auto_remove = not self._profile.settings.get("preserve_exchange_records") cred_ex_record = V20CredExRecord( @@ -222,7 +222,6 @@ async def create_offer( supported formats. """ - cred_proposal_message = ( counter_proposal if counter_proposal else cred_ex_record.cred_proposal ) @@ -287,7 +286,6 @@ async def receive_offer( The credential exchange record, updated """ - # Get credential exchange record (holder sent proposal first) # or create it (issuer sent offer first) try: @@ -500,7 +498,6 @@ async def issue_credential( Tuple: (Updated credential exchange record, credential issue message) """ - if cred_ex_record.state != V20CredExRecord.STATE_REQUEST_RECEIVED: raise V20CredManagerError( f"Credential exchange {cred_ex_record.cred_ex_id} " @@ -733,7 +730,6 @@ async def receive_credential_ack( async def delete_cred_ex_record(self, cred_ex_id: str) -> None: """Delete credential exchange record and associated detail records.""" - async with self._profile.session() as session: for fmt in V20CredFormat.Format: # details first: do not strand any orphans for record in await fmt.detail.query_by_cred_ex_id( diff --git a/acapy_agent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py b/acapy_agent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py index 6b6e556471..cb1c92f5a1 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py +++ b/acapy_agent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py @@ -52,12 +52,10 @@ def list_plain(plain: dict) -> Sequence["V20CredAttrSpec"]: def b64_decoded_value(self) -> str: """Value, base64-decoded if applicable.""" - return b64_to_str(self.value) if self.value and self.mime_type else self.value def __eq__(self, other): """Equality comparator.""" - if self.name != other.name: return False # distinct attribute names @@ -147,7 +145,6 @@ def attr_dict(self, decode: bool = False): decode: whether first to decode attributes with MIME type """ - return { attr.name: ( b64_to_str(attr.value) if attr.mime_type and decode else attr.value diff --git a/acapy_agent/protocols/issue_credential/v2_0/models/cred_ex_record.py b/acapy_agent/protocols/issue_credential/v2_0/models/cred_ex_record.py index 4cad49f1ae..09edbb9c87 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/models/cred_ex_record.py +++ b/acapy_agent/protocols/issue_credential/v2_0/models/cred_ex_record.py @@ -164,8 +164,8 @@ async def save_error_state( reason: A reason to add to the log log_params: Additional parameters to log log_override: Override configured logging regimen, print to stderr instead - """ + """ if self._last_state == state: # already done return @@ -190,8 +190,8 @@ async def emit_event(self, session: ProfileSession, payload: Optional[Any] = Non Args: session: The profile session to use payload: The event payload - """ + """ if not self.RECORD_TOPIC: return diff --git a/acapy_agent/protocols/issue_credential/v2_0/routes.py b/acapy_agent/protocols/issue_credential/v2_0/routes.py index 6f91cf4a9f..cc9cd26e51 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/routes.py +++ b/acapy_agent/protocols/issue_credential/v2_0/routes.py @@ -351,7 +351,6 @@ class V20IssueCredSchemaCore(AdminAPIMessageTracingSchema): @validates_schema def validate(self, data, **kwargs): """Make sure preview is present when indy/vc_di format is present.""" - if ( data.get("filter", {}).get("indy") or data.get("filter", {}).get("vc_di") ) and not data.get("credential_preview"): @@ -554,7 +553,6 @@ class V20CredExIdMatchInfoSchema(OpenAPISchema): def _formats_filters(filt_spec: Mapping) -> Mapping: """Break out formats and filters for v2.0 cred proposal messages.""" - return ( { "formats": [ @@ -991,7 +989,6 @@ async def _create_free_offer( trace_msg: Optional[bool] = None, ): """Create a credential offer and related exchange record.""" - cred_preview = V20CredPreview.deserialize(preview_spec) if preview_spec else None cred_proposal = V20CredProposal( comment=comment, @@ -1794,7 +1791,6 @@ async def credential_exchange_problem_report(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get( @@ -1853,7 +1849,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/notification/v1_0/handlers/ack_handler.py b/acapy_agent/protocols/notification/v1_0/handlers/ack_handler.py index 71ba1b29a3..9fb7de7b54 100644 --- a/acapy_agent/protocols/notification/v1_0/handlers/ack_handler.py +++ b/acapy_agent/protocols/notification/v1_0/handlers/ack_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ r_time = get_timer() diff --git a/acapy_agent/protocols/out_of_band/v1_0/handlers/problem_report_handler.py b/acapy_agent/protocols/out_of_band/v1_0/handlers/problem_report_handler.py index 0d03e08bfa..0fad9b93f0 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/handlers/problem_report_handler.py +++ b/acapy_agent/protocols/out_of_band/v1_0/handlers/problem_report_handler.py @@ -19,6 +19,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback + """ self._logger.debug( "OOBProblemReportMessageHandler called with context %s", context diff --git a/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_accept_handler.py b/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_accept_handler.py index f1cf3735e2..d6153c957c 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_accept_handler.py +++ b/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_accept_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback + """ self._logger.debug( "HandshakeReuseAcceptMessageHandler called with context %s", context diff --git a/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_handler.py b/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_handler.py index 119af76343..4d49949b0e 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_handler.py +++ b/acapy_agent/protocols/out_of_band/v1_0/handlers/reuse_handler.py @@ -16,6 +16,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: Request context responder: Responder callback + """ self._logger.debug("HandshakeReuseMessageHandler called with context %s", context) assert isinstance(context.message, HandshakeReuse) diff --git a/acapy_agent/protocols/out_of_band/v1_0/manager.py b/acapy_agent/protocols/out_of_band/v1_0/manager.py index 7c1acbedaa..bf31bd34b4 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/manager.py +++ b/acapy_agent/protocols/out_of_band/v1_0/manager.py @@ -569,6 +569,7 @@ def __init__(self, profile: Profile): Args: profile: The profile for this out of band manager + """ self._profile = profile super().__init__(self._profile) diff --git a/acapy_agent/protocols/out_of_band/v1_0/messages/invitation.py b/acapy_agent/protocols/out_of_band/v1_0/messages/invitation.py index f4169dfdb1..257e76b952 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/messages/invitation.py +++ b/acapy_agent/protocols/out_of_band/v1_0/messages/invitation.py @@ -60,7 +60,6 @@ class HSProto(Enum): @classmethod def get(cls, label: Union[str, "HSProto"]) -> Optional["HSProto"]: """Get handshake protocol enum for label.""" - if isinstance(label, str): for hsp in HSProto: if DIDCommPrefix.unqualify(label) == hsp.name or label.lower() in hsp.aka: @@ -316,6 +315,7 @@ def validate_fields(self, data, **kwargs): kwargs: Additional keyword arguments Raises: ValidationError: If any of the fields do not validate + """ handshake_protocols = data.get("handshake_protocols") requests_attach = data.get("requests_attach") diff --git a/acapy_agent/protocols/out_of_band/v1_0/messages/problem_report.py b/acapy_agent/protocols/out_of_band/v1_0/messages/problem_report.py index e624d996fd..b5910427e3 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/messages/problem_report.py +++ b/acapy_agent/protocols/out_of_band/v1_0/messages/problem_report.py @@ -65,7 +65,6 @@ class Meta: @pre_dump def check_thread_deco(self, obj, **kwargs): """Thread decorator, and its thid and pthid, are mandatory.""" - if not obj._decorators.to_dict().get("~thread", {}).keys() >= {"thid", "pthid"}: raise ValidationError("Missing required field(s) in thread decorator") @@ -74,7 +73,6 @@ def check_thread_deco(self, obj, **kwargs): @validates_schema def validate_fields(self, data, **kwargs): """Validate schema fields.""" - if not data.get("description", {}).get("code", ""): raise ValidationError("Value for description.code must be present") elif data.get("description", {}).get("code", "") not in [ diff --git a/acapy_agent/protocols/out_of_band/v1_0/messages/service.py b/acapy_agent/protocols/out_of_band/v1_0/messages/service.py index e1daaeb853..f8466d0253 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/messages/service.py +++ b/acapy_agent/protocols/out_of_band/v1_0/messages/service.py @@ -40,6 +40,7 @@ def __init__( recipient_keys: A list of recipient keys in W3C did:key format routing_keys: A list of routing keys in W3C did:key format service_endpoint: An endpoint for the connection + """ self._id = _id self._type = _type @@ -105,7 +106,6 @@ class Meta: @post_dump def post_dump(self, data, **kwargs): """Post dump hook.""" - if "routingKeys" in data and not data["routingKeys"]: del data["routingKeys"] diff --git a/acapy_agent/protocols/out_of_band/v1_0/models/oob_record.py b/acapy_agent/protocols/out_of_band/v1_0/models/oob_record.py index 1eef17ffe6..229997559b 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/models/oob_record.py +++ b/acapy_agent/protocols/out_of_band/v1_0/models/oob_record.py @@ -190,6 +190,7 @@ async def metadata_set(self, session: ProfileSession, key: str, value: Any): session (ProfileSession): session used for storage key (str): key identifying metadata value (Any): value to set + """ assert self.connection_id value = json.dumps(value) @@ -214,6 +215,7 @@ async def metadata_delete(self, session: ProfileSession, key: str): Args: session (ProfileSession): session used for storage key (str): key of metadata to delete + """ assert self.connection_id storage: BaseStorage = session.inject(BaseStorage) diff --git a/acapy_agent/protocols/out_of_band/v1_0/routes.py b/acapy_agent/protocols/out_of_band/v1_0/routes.py index 5826d9d1f5..ea05b724b1 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/routes.py +++ b/acapy_agent/protocols/out_of_band/v1_0/routes.py @@ -351,7 +351,6 @@ async def invitation_receive(request: web.BaseRequest): The out of band invitation details """ - context: AdminRequestContext = request["context"] if context.settings.get("admin.no_receive_invites"): raise web.HTTPForbidden( @@ -426,7 +425,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/present_proof/anoncreds/pres_exch_handler.py b/acapy_agent/protocols/present_proof/anoncreds/pres_exch_handler.py index e95f5827d7..aeaf21d13f 100644 --- a/acapy_agent/protocols/present_proof/anoncreds/pres_exch_handler.py +++ b/acapy_agent/protocols/present_proof/anoncreds/pres_exch_handler.py @@ -64,7 +64,6 @@ def _get_requested_referents( "referent-1": {"cred_id": "1", "non_revoked": {"from": ..., "to": ...}} } """ - requested_referents = {} attr_creds = requested_credentials.get("requested_attributes", {}) req_attrs = proof_request.get("requested_attributes", {}) @@ -234,7 +233,6 @@ async def return_presentation( requested_credentials: Optional[dict] = None, ) -> dict: """Return AnonCreds proof request as dict.""" - # If not anoncreds capable, try to use indy handler. This should be removed when # indy filter is completely retired if not isinstance(self._profile, AskarAnonCredsProfile): diff --git a/acapy_agent/protocols/present_proof/dif/pres_exch_handler.py b/acapy_agent/protocols/present_proof/dif/pres_exch_handler.py index 388ef06f64..ddede4fb31 100644 --- a/acapy_agent/protocols/present_proof/dif/pres_exch_handler.py +++ b/acapy_agent/protocols/present_proof/dif/pres_exch_handler.py @@ -1028,6 +1028,7 @@ def credential_match_schema(self, credential: VCRecord, schema_id: str) -> bool: schema_id: schema uri to check Return: bool + """ if schema_id in credential.schema_ids: return True @@ -1059,6 +1060,7 @@ async def apply_requirements( records_filter: dict of input_descriptor ID key to list of credential_json Return: dict of input_descriptor ID key to list of credential_json + """ # Dict for storing descriptor_id keys and list of applicable # credentials values @@ -1176,6 +1178,7 @@ async def merge_nested_results( exclude: dict containing info about credentials to exclude Return: dict with input_descriptor.id as keys and merged_credentials_list as values + """ result = {} for res in nested_result: @@ -1221,6 +1224,7 @@ async def create_vp( Returns: Union[Sequence[dict], dict]: VerifiablePresentation. + """ document_loader = self.profile.inject(DocumentLoader) req = await self.make_requirement( @@ -1357,6 +1361,7 @@ async def merge( and merged_credentials_list Return: Tuple of applicable credential list and descriptor map + """ dict_of_creds = {} dict_of_descriptors = {} @@ -1392,6 +1397,7 @@ async def verify_received_pres( Args: pres: received VerifiablePresentation pd: PresentationDefinition + """ input_descriptors = pd.input_descriptors if isinstance(pres, Sequence): diff --git a/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_ack_handler.py b/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_ack_handler.py index e849d8e176..e7211330c2 100644 --- a/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_ack_handler.py +++ b/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_ack_handler.py @@ -18,6 +18,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ r_time = get_timer() diff --git a/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_problem_report_handler.py b/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_problem_report_handler.py index c0dc0d5fae..7db4fb398b 100644 --- a/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_problem_report_handler.py +++ b/acapy_agent/protocols/present_proof/v1_0/handlers/presentation_problem_report_handler.py @@ -17,6 +17,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug( "Present-proof v1.0 problem report handler called with context %s", diff --git a/acapy_agent/protocols/present_proof/v1_0/manager.py b/acapy_agent/protocols/present_proof/v1_0/manager.py index b89aad435c..0a78af298d 100644 --- a/acapy_agent/protocols/present_proof/v1_0/manager.py +++ b/acapy_agent/protocols/present_proof/v1_0/manager.py @@ -39,8 +39,8 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this presentation manager - """ + """ self._profile = profile async def create_exchange_for_proposal( diff --git a/acapy_agent/protocols/present_proof/v1_0/messages/presentation_proposal.py b/acapy_agent/protocols/present_proof/v1_0/messages/presentation_proposal.py index 31b23b04b5..8763e35cad 100644 --- a/acapy_agent/protocols/present_proof/v1_0/messages/presentation_proposal.py +++ b/acapy_agent/protocols/present_proof/v1_0/messages/presentation_proposal.py @@ -38,6 +38,7 @@ def __init__( comment: optional human-readable comment presentation_proposal: proposed presentation preview kwargs: additional keyword arguments for message + """ super().__init__(_id, **kwargs) self.comment = comment diff --git a/acapy_agent/protocols/present_proof/v1_0/models/presentation_exchange.py b/acapy_agent/protocols/present_proof/v1_0/models/presentation_exchange.py index 72a1fcc4d1..526ce110c7 100644 --- a/acapy_agent/protocols/present_proof/v1_0/models/presentation_exchange.py +++ b/acapy_agent/protocols/present_proof/v1_0/models/presentation_exchange.py @@ -171,8 +171,8 @@ async def save_error_state( reason: A reason to add to the log log_params: Additional parameters to log log_override: Override configured logging regimen, print to stderr instead - """ + """ if self._last_state == state: # already done return @@ -197,8 +197,8 @@ async def emit_event(self, session: ProfileSession, payload: Optional[Any] = Non Args: session: The profile session to use payload: The event payload - """ + """ if not self.RECORD_TOPIC: return diff --git a/acapy_agent/protocols/present_proof/v1_0/routes.py b/acapy_agent/protocols/present_proof/v1_0/routes.py index 5b554e4d5e..6e1c87a717 100644 --- a/acapy_agent/protocols/present_proof/v1_0/routes.py +++ b/acapy_agent/protocols/present_proof/v1_0/routes.py @@ -1103,7 +1103,6 @@ async def presentation_exchange_remove(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get( @@ -1159,7 +1158,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/present_proof/v2_0/formats/dif/handler.py b/acapy_agent/protocols/present_proof/v2_0/formats/dif/handler.py index 206a4fc658..d0cb0d0bef 100644 --- a/acapy_agent/protocols/present_proof/v2_0/formats/dif/handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/formats/dif/handler.py @@ -89,7 +89,6 @@ def get_format_data( self, message_type: str, data: dict ) -> Tuple[V20PresFormat, AttachDecorator]: """Get presentation format and attach objects for use in pres_ex messages.""" - return ( V20PresFormat( attach_id=DIFPresFormatHandler.format.api, diff --git a/acapy_agent/protocols/present_proof/v2_0/formats/indy/handler.py b/acapy_agent/protocols/present_proof/v2_0/formats/indy/handler.py index 23744d0651..91c031dde4 100644 --- a/acapy_agent/protocols/present_proof/v2_0/formats/indy/handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/formats/indy/handler.py @@ -77,14 +77,12 @@ def get_format_identifier(self, message_type: str) -> str: str: Issue credential attachment format identifier """ - return ATTACHMENT_FORMAT[message_type][IndyPresExchangeHandler.format.api] def get_format_data( self, message_type: str, data: dict ) -> Tuple[V20PresFormat, AttachDecorator]: """Get presentation format and attach objects for use in pres_ex messages.""" - return ( V20PresFormat( attach_id=IndyPresExchangeHandler.format.api, @@ -109,7 +107,6 @@ async def create_bound_request( A tuple (updated presentation exchange record, presentation request message) """ - indy_proof_request = pres_ex_record.pres_proposal.attachment( IndyPresExchangeHandler.format ) @@ -131,7 +128,6 @@ async def create_pres( request_data: Optional[dict] = None, ) -> Tuple[V20PresFormat, AttachDecorator]: """Create a presentation.""" - requested_credentials = {} if not request_data: try: diff --git a/acapy_agent/protocols/present_proof/v2_0/handlers/pres_ack_handler.py b/acapy_agent/protocols/present_proof/v2_0/handlers/pres_ack_handler.py index 5395c2e1bf..ca2ffd153a 100644 --- a/acapy_agent/protocols/present_proof/v2_0/handlers/pres_ack_handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/handlers/pres_ack_handler.py @@ -18,6 +18,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ r_time = get_timer() diff --git a/acapy_agent/protocols/present_proof/v2_0/handlers/pres_problem_report_handler.py b/acapy_agent/protocols/present_proof/v2_0/handlers/pres_problem_report_handler.py index e10df27e2e..b5d5cd2a25 100644 --- a/acapy_agent/protocols/present_proof/v2_0/handlers/pres_problem_report_handler.py +++ b/acapy_agent/protocols/present_proof/v2_0/handlers/pres_problem_report_handler.py @@ -17,6 +17,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): Args: context: request context responder: responder callback + """ self._logger.debug( "Present-proof v2.0 problem report handler called with context %s", diff --git a/acapy_agent/protocols/present_proof/v2_0/manager.py b/acapy_agent/protocols/present_proof/v2_0/manager.py index 1786a6fea3..3bc3d3a7b6 100644 --- a/acapy_agent/protocols/present_proof/v2_0/manager.py +++ b/acapy_agent/protocols/present_proof/v2_0/manager.py @@ -31,8 +31,8 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this presentation manager - """ + """ self._profile = profile async def create_exchange_for_proposal( @@ -116,6 +116,7 @@ async def create_bound_request( Returns: A tuple (updated presentation exchange record, presentation request message) + """ proof_proposal = pres_ex_record.pres_proposal input_formats = proof_proposal.formats @@ -255,8 +256,8 @@ async def create_pres( Raises: V20PresManagerError: If unable to create the presentation or no supported formats are available. - """ + """ proof_request = pres_ex_record.pres_request input_formats = proof_request.formats request_data = request_data or {} @@ -317,7 +318,6 @@ async def receive_pres( presentation exchange record, retrieved and updated """ - thread_id = message._thread_id # Normally we only set the connection_id to None if an oob record is present # But present proof supports the old-style AIP-1 connectionless exchange that diff --git a/acapy_agent/protocols/present_proof/v2_0/messages/pres_proposal.py b/acapy_agent/protocols/present_proof/v2_0/messages/pres_proposal.py index bc8d7d53e4..a542b4b20a 100644 --- a/acapy_agent/protocols/present_proof/v2_0/messages/pres_proposal.py +++ b/acapy_agent/protocols/present_proof/v2_0/messages/pres_proposal.py @@ -43,6 +43,7 @@ def __init__( formats: acceptable attachment formats proposals_attach: proposal attachments specifying criteria by format kwargs: additional key-value arguments + """ super().__init__(_id, **kwargs) self.comment = comment diff --git a/acapy_agent/protocols/present_proof/v2_0/models/pres_exchange.py b/acapy_agent/protocols/present_proof/v2_0/models/pres_exchange.py index 59d8fe0ba8..2e67bdffc2 100644 --- a/acapy_agent/protocols/present_proof/v2_0/models/pres_exchange.py +++ b/acapy_agent/protocols/present_proof/v2_0/models/pres_exchange.py @@ -162,8 +162,8 @@ async def save_error_state( reason: A reason to add to the log log_params: Additional parameters to log log_override: Override configured logging regimen, print to stderr instead - """ + """ if self._last_state == state: # already done return @@ -188,8 +188,8 @@ async def emit_event(self, session: ProfileSession, payload: Optional[Any] = Non Args: session: The profile session to use payload: The event payload - """ + """ if not self.RECORD_TOPIC: return diff --git a/acapy_agent/protocols/present_proof/v2_0/routes.py b/acapy_agent/protocols/present_proof/v2_0/routes.py index 5204a552d7..67d3b7b9ff 100644 --- a/acapy_agent/protocols/present_proof/v2_0/routes.py +++ b/acapy_agent/protocols/present_proof/v2_0/routes.py @@ -428,7 +428,6 @@ class V20PresExIdMatchInfoSchema(OpenAPISchema): async def _add_nonce(indy_proof_request: Mapping) -> Mapping: """Add nonce to indy proof request if need be.""" - if not indy_proof_request.get("nonce"): indy_proof_request["nonce"] = await generate_pr_nonce() return indy_proof_request @@ -1465,7 +1464,6 @@ async def present_proof_remove(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get( @@ -1521,7 +1519,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/protocols/problem_report/v1_0/message.py b/acapy_agent/protocols/problem_report/v1_0/message.py index ffda9ca6d1..1c1828b753 100644 --- a/acapy_agent/protocols/problem_report/v1_0/message.py +++ b/acapy_agent/protocols/problem_report/v1_0/message.py @@ -48,6 +48,7 @@ def __init__( tracking_uri: URI for tracking the problem escalation_uri: URI for escalating the problem kwargs: Additional keyword arguments for message + """ super().__init__(**kwargs) self.description = description if description else None diff --git a/acapy_agent/protocols/revocation_notification/v1_0/models/rev_notification_record.py b/acapy_agent/protocols/revocation_notification/v1_0/models/rev_notification_record.py index c09dcbc649..bb4eebeaf8 100644 --- a/acapy_agent/protocols/revocation_notification/v1_0/models/rev_notification_record.py +++ b/acapy_agent/protocols/revocation_notification/v1_0/models/rev_notification_record.py @@ -80,6 +80,7 @@ async def query_by_ids( session: the profile session to use cred_rev_id: the cred rev id by which to filter rev_reg_id: the rev reg id by which to filter + """ tag_filter = { **{"version": "v1_0"}, @@ -107,6 +108,7 @@ async def query_by_rev_reg_id( Args: session: the profile session to use rev_reg_id: the rev reg id by which to filter + """ tag_filter = { **{"version": "v1_0"}, diff --git a/acapy_agent/protocols/revocation_notification/v1_0/routes.py b/acapy_agent/protocols/revocation_notification/v1_0/routes.py index 3ab25fec76..1e0b7ee4b3 100644 --- a/acapy_agent/protocols/revocation_notification/v1_0/routes.py +++ b/acapy_agent/protocols/revocation_notification/v1_0/routes.py @@ -70,7 +70,6 @@ async def on_revocation_published(profile: Profile, event: Event): async def on_pending_cleared(profile: Profile, event: Event): """Handle pending cleared event.""" - # Query by rev reg ID async with profile.session() as session: notifications = await RevNotificationRecord.query_by_rev_reg_id( diff --git a/acapy_agent/protocols/revocation_notification/v2_0/models/rev_notification_record.py b/acapy_agent/protocols/revocation_notification/v2_0/models/rev_notification_record.py index 17cc4dac25..cda619583e 100644 --- a/acapy_agent/protocols/revocation_notification/v2_0/models/rev_notification_record.py +++ b/acapy_agent/protocols/revocation_notification/v2_0/models/rev_notification_record.py @@ -80,6 +80,7 @@ async def query_by_ids( session: the profile session to use cred_rev_id: the cred rev id by which to filter rev_reg_id: the rev reg id by which to filter + """ tag_filter = { **{"version": "v2_0"}, @@ -107,6 +108,7 @@ async def query_by_rev_reg_id( Args: session: the profile session to use rev_reg_id: the rev reg id by which to filter + """ tag_filter = { **{"version": "v2_0"}, diff --git a/acapy_agent/protocols/revocation_notification/v2_0/routes.py b/acapy_agent/protocols/revocation_notification/v2_0/routes.py index 3ab25fec76..1e0b7ee4b3 100644 --- a/acapy_agent/protocols/revocation_notification/v2_0/routes.py +++ b/acapy_agent/protocols/revocation_notification/v2_0/routes.py @@ -70,7 +70,6 @@ async def on_revocation_published(profile: Profile, event: Event): async def on_pending_cleared(profile: Profile, event: Event): """Handle pending cleared event.""" - # Query by rev reg ID async with profile.session() as session: notifications = await RevNotificationRecord.query_by_rev_reg_id( diff --git a/acapy_agent/protocols/routing/v1_0/manager.py b/acapy_agent/protocols/routing/v1_0/manager.py index 2b93dc2472..15dfd4d4f5 100644 --- a/acapy_agent/protocols/routing/v1_0/manager.py +++ b/acapy_agent/protocols/routing/v1_0/manager.py @@ -33,6 +33,7 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this manager + """ self._profile = profile if not profile: diff --git a/acapy_agent/protocols/routing/v1_0/messages/forward.py b/acapy_agent/protocols/routing/v1_0/messages/forward.py index ab455af073..464b264bea 100644 --- a/acapy_agent/protocols/routing/v1_0/messages/forward.py +++ b/acapy_agent/protocols/routing/v1_0/messages/forward.py @@ -30,6 +30,7 @@ def __init__( to (str): Recipient DID msg (str): Message content kwargs: Additional keyword arguments + """ super().__init__(**kwargs) self.to = to diff --git a/acapy_agent/protocols/routing/v1_0/models/route_record.py b/acapy_agent/protocols/routing/v1_0/models/route_record.py index e82990f221..f5b207ba5f 100644 --- a/acapy_agent/protocols/routing/v1_0/models/route_record.py +++ b/acapy_agent/protocols/routing/v1_0/models/route_record.py @@ -41,6 +41,7 @@ def __init__( wallet_id: The id of the wallet for the route. Used for multitenant relay recipient_key (str): recipient_key associated with record kwargs: additional args for BaseRecord + """ super().__init__(record_id, None, **kwargs) self.role = role or self.ROLE_SERVER @@ -137,7 +138,6 @@ def validate_fields(self, data, **kwargs): ValidationError: If any of the fields do not validate """ - if not (data.get("connection_id") or data.get("wallet_id")): raise ValidationError( "Either connection_id or wallet_id must be set for route" diff --git a/acapy_agent/protocols/trustping/v1_0/handlers/ping_response_handler.py b/acapy_agent/protocols/trustping/v1_0/handlers/ping_response_handler.py index 128987e566..3ca8424f0e 100644 --- a/acapy_agent/protocols/trustping/v1_0/handlers/ping_response_handler.py +++ b/acapy_agent/protocols/trustping/v1_0/handlers/ping_response_handler.py @@ -15,7 +15,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): responder: Responder used to reply """ - self._logger.debug("PingResponseHandler called with context: %s", context) assert isinstance(context.message, PingResponse) diff --git a/acapy_agent/protocols/trustping/v1_0/routes.py b/acapy_agent/protocols/trustping/v1_0/routes.py index fac9455a3a..1847e26f7c 100644 --- a/acapy_agent/protocols/trustping/v1_0/routes.py +++ b/acapy_agent/protocols/trustping/v1_0/routes.py @@ -76,13 +76,11 @@ async def connections_send_ping(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes([web.post("/connections/{conn_id}/send-ping", connections_send_ping)]) def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/resolver/base.py b/acapy_agent/resolver/base.py index e7b600e105..e16ff6b6a9 100644 --- a/acapy_agent/resolver/base.py +++ b/acapy_agent/resolver/base.py @@ -55,6 +55,7 @@ def __init__(self, did_document: dict, metadata: ResolutionMetadata): Args: did_document: DID Document resolved metadata: Resolving details + """ self.did_document = did_document self.metadata = metadata @@ -77,6 +78,7 @@ def __init__(self, type_: Optional[ResolverType] = None): Args: type_ (Type): Type of resolver, native or non-native + """ self.type = type_ or ResolverType.NON_NATIVE diff --git a/acapy_agent/resolver/default/indy.py b/acapy_agent/resolver/default/indy.py index 8d4aecf9d9..57d68b0214 100644 --- a/acapy_agent/resolver/default/indy.py +++ b/acapy_agent/resolver/default/indy.py @@ -35,7 +35,6 @@ def _routing_keys_as_did_key_urls(routing_keys: Sequence[str]) -> Sequence[str]: If a did:key is passed in, convert to a did:key URL. """ - did_key_urls = [] for routing_key in routing_keys: if not routing_key.startswith("did:key:"): diff --git a/acapy_agent/resolver/default/universal.py b/acapy_agent/resolver/default/universal.py index 1cc626e758..156e161007 100644 --- a/acapy_agent/resolver/default/universal.py +++ b/acapy_agent/resolver/default/universal.py @@ -49,7 +49,6 @@ def __init__( async def setup(self, context: InjectionContext): """Perform setup, populate supported method list, configuration.""" - # configure endpoint endpoint = context.settings.get_str("resolver.universal") if endpoint == "DEFAULT" or not endpoint: @@ -84,7 +83,6 @@ async def _resolve( service_accept: Optional[Sequence[Text]] = None, ) -> dict: """Resolve DID through remote universal resolver.""" - async with aiohttp.ClientSession(headers=self.__default_headers) as session: async with session.get(f"{self._endpoint}/identifiers/{did}") as resp: if resp.status == 200: diff --git a/acapy_agent/resolver/default/web.py b/acapy_agent/resolver/default/web.py index 0fd52fc506..b6679fb969 100644 --- a/acapy_agent/resolver/default/web.py +++ b/acapy_agent/resolver/default/web.py @@ -33,7 +33,6 @@ def __transform_to_url(self, did): according to https://w3c-ccg.github.io/did-method-web/#read-resolve """ - as_did = DID(did) method_specific_id = as_did.method_specific_id if ":" in method_specific_id: @@ -55,7 +54,6 @@ async def _resolve( service_accept: Optional[Sequence[Text]] = None, ) -> dict: """Resolve did:web DIDs.""" - url = self.__transform_to_url(did) async with aiohttp.ClientSession() as session: async with session.get(url) as response: diff --git a/acapy_agent/resolver/routes.py b/acapy_agent/resolver/routes.py index 3016aafbb7..dce70f1c77 100644 --- a/acapy_agent/resolver/routes.py +++ b/acapy_agent/resolver/routes.py @@ -27,7 +27,6 @@ class W3cDID(validate.Regexp): def __init__(self): """Initialize the instance.""" - super().__init__( W3cDID.PATTERN, error="Value {input} is not a w3c decentralized identifier (DID)", @@ -70,7 +69,6 @@ async def resolve_did(request: web.Request): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get( @@ -84,7 +82,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/revocation/indy.py b/acapy_agent/revocation/indy.py index 14fc941c9d..42392b3f2f 100644 --- a/acapy_agent/revocation/indy.py +++ b/acapy_agent/revocation/indy.py @@ -184,6 +184,7 @@ async def get_active_issuer_rev_reg_record( Args: cred_def_id: ID of the base credential definition + """ async with self._profile.session() as session: current = sorted( @@ -202,6 +203,7 @@ async def get_issuer_rev_reg_record(self, revoc_reg_id: str) -> IssuerRevRegReco Args: revoc_reg_id: ID of the revocation registry + """ async with self._profile.session() as session: return await IssuerRevRegRecord.retrieve_by_revoc_reg_id( diff --git a/acapy_agent/revocation/manager.py b/acapy_agent/revocation/manager.py index e1e2a3de7d..0a676b74c2 100644 --- a/acapy_agent/revocation/manager.py +++ b/acapy_agent/revocation/manager.py @@ -57,6 +57,7 @@ def __init__(self, profile: Profile): Args: profile: The profile instance for this revocation manager + """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -211,6 +212,7 @@ async def revoke_credential( Returns: Optional[dict]: The revocation entry response if publish is True and write_ledger is True, otherwise None. + """ issuer = self._profile.inject(IndyIssuer) revoc = IndyRevocation(self._profile) @@ -332,6 +334,7 @@ async def publish_pending_revocations( connection_id: connection identifier for endorser connection to use Returns: mapping from each revocation registry id to its cred rev ids published. + """ result = {} issuer = self._profile.inject(IndyIssuer) diff --git a/acapy_agent/revocation/models/issuer_cred_rev_record.py b/acapy_agent/revocation/models/issuer_cred_rev_record.py index cfd5e4404a..5c261a8afc 100644 --- a/acapy_agent/revocation/models/issuer_cred_rev_record.py +++ b/acapy_agent/revocation/models/issuer_cred_rev_record.py @@ -84,6 +84,7 @@ async def query_by_ids( cred_def_id: the cred def id by which to filter rev_reg_id: the rev reg id by which to filter state: a state value by which to filter + """ tag_filter = { **({"cred_def_id": cred_def_id} if cred_def_id else {}), diff --git a/acapy_agent/revocation/models/issuer_rev_reg_record.py b/acapy_agent/revocation/models/issuer_rev_reg_record.py index fe02445fa2..49c756a652 100644 --- a/acapy_agent/revocation/models/issuer_rev_reg_record.py +++ b/acapy_agent/revocation/models/issuer_rev_reg_record.py @@ -498,6 +498,7 @@ async def mark_pending(self, session: ProfileSession, cred_rev_id: str) -> None: Args: session: The profile session to use cred_rev_id: The credential revocation identifier for credential to revoke + """ if cred_rev_id not in self.pending_pub: self.pending_pub.append(cred_rev_id) @@ -513,6 +514,7 @@ async def clear_pending( Args: session: The profile session to use cred_rev_ids: Credential revocation identifiers to clear; default all + """ if self.pending_pub: if cred_rev_ids: @@ -552,6 +554,7 @@ async def query_by_cred_def_id( state: A state value to filter by negative_state: A state value to exclude limit: The maximum number of records to return + """ tag_filter = dict( filter( @@ -575,6 +578,7 @@ async def query_by_pending( Args: session: The profile session to use + """ return await cls.query( session=session, @@ -593,6 +597,7 @@ async def retrieve_by_revoc_reg_id( session: The profile session to use revoc_reg_id: The revocation registry ID for_update: Retrieve for update + """ tag_filter = {"revoc_reg_id": revoc_reg_id} return await cls.retrieve_by_tag_filter( diff --git a/acapy_agent/revocation/recover.py b/acapy_agent/revocation/recover.py index 52f3a53a89..5eeb1f59e3 100644 --- a/acapy_agent/revocation/recover.py +++ b/acapy_agent/revocation/recover.py @@ -29,7 +29,6 @@ class RevocRecoveryException(Exception): async def fetch_txns(genesis_txns, registry_id): """Fetch tails file and revocation registry information.""" - try: vdr_module = importlib.import_module("indy_vdr") credx_module = importlib.import_module("indy_credx") @@ -86,7 +85,6 @@ async def generate_ledger_rrrecovery_txn( genesis_txns, registry_id, set_revoked, cred_def, rev_reg_def_private ): """Generate a new ledger accum entry, based on wallet vs ledger revocation state.""" - new_delta = None ledger_data = await fetch_txns(genesis_txns, registry_id) diff --git a/acapy_agent/revocation/routes.py b/acapy_agent/revocation/routes.py index a48f896e32..9fc4826ed2 100644 --- a/acapy_agent/revocation/routes.py +++ b/acapy_agent/revocation/routes.py @@ -125,7 +125,6 @@ class CredRevRecordQueryStringSchema(OpenAPISchema): @validates_schema def validate_fields(self, data, **kwargs): """Validate schema fields - must have (rr-id and cr-id) xor cx-id.""" - rev_reg_id = data.get("rev_reg_id") cred_rev_id = data.get("cred_rev_id") cred_ex_id = data.get("cred_ex_id") @@ -170,7 +169,6 @@ class RevRegId(OpenAPISchema): @validates_schema def validate_fields(self, data, **kwargs): """Validate schema fields - must have either rr-id or cr-id.""" - rev_reg_id = data.get("rev_reg_id") cred_def_id = data.get("cred_def_id") @@ -1882,7 +1880,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/revocation/tests/test_routes.py b/acapy_agent/revocation/tests/test_routes.py index 8aaa6e2cc7..7cc16c0d17 100644 --- a/acapy_agent/revocation/tests/test_routes.py +++ b/acapy_agent/revocation/tests/test_routes.py @@ -1,8 +1,11 @@ +import json import os import shutil import unittest + import pytest from aiohttp.web import HTTPBadRequest, HTTPNotFound +from multidict import MultiDict from ...admin.request_context import AdminRequestContext from ...ledger.base import BaseLedger @@ -23,8 +26,6 @@ from .. import routes as test_module from ..manager import RevocationManager from ..models.issuer_rev_reg_record import IssuerRevRegRecord -from multidict import MultiDict -import json class TestRevocationRoutes(unittest.IsolatedAsyncioTestCase): diff --git a/acapy_agent/settings/routes.py b/acapy_agent/settings/routes.py index 777ed0a632..07098357e7 100644 --- a/acapy_agent/settings/routes.py +++ b/acapy_agent/settings/routes.py @@ -92,6 +92,7 @@ async def update_profile_settings(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] root_profile = context.root_profile or context.profile @@ -133,6 +134,7 @@ async def get_profile_settings(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] root_profile = context.root_profile or context.profile @@ -158,7 +160,6 @@ async def get_profile_settings(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.put("/settings", update_profile_settings), @@ -169,7 +170,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/acapy_agent/storage/askar.py b/acapy_agent/storage/askar.py index 607c6b927f..00c30a0e8c 100644 --- a/acapy_agent/storage/askar.py +++ b/acapy_agent/storage/askar.py @@ -29,6 +29,7 @@ def __init__(self, session: AskarProfileSession): Args: session: The Askar profile session to use + """ self._session = session @@ -148,6 +149,7 @@ async def find_record( type_filter: Filter string tag_query: Tags to query options: Dictionary of backend-specific options + """ for_update = bool(options and options.get("forUpdate")) try: @@ -189,6 +191,7 @@ async def find_paginated_records( Returns: A sequence of StorageRecord matching the filter and query parameters. + """ results = [] @@ -256,6 +259,7 @@ def __init__(self, profile: AskarProfile): Args: profile: The Askar profile instance to use + """ self._profile = profile diff --git a/acapy_agent/storage/base.py b/acapy_agent/storage/base.py index e065c32b88..d530c330dd 100644 --- a/acapy_agent/storage/base.py +++ b/acapy_agent/storage/base.py @@ -82,6 +82,7 @@ async def find_record( type_filter: Filter string tag_query: Tags to query options: Dictionary of backend-specific options + """ scan = self.search_records(type_filter, tag_query, options) results = await scan.fetch(2) @@ -114,6 +115,7 @@ async def find_paginated_records( Returns: A sequence of StorageRecord matching the filter and query parameters. + """ @abstractmethod @@ -133,6 +135,7 @@ async def find_all_records( order_by: An optional field by which to order the records. descending: Whether to order the records in descending order. options: Additional options for the query. + """ @abstractmethod @@ -146,6 +149,7 @@ async def delete_all_records( Args: type_filter: The type of records to filter by. tag_query: An optional dictionary of tag filter clauses. + """ diff --git a/acapy_agent/storage/vc_holder/base.py b/acapy_agent/storage/vc_holder/base.py index 5475de5738..084a7a9773 100644 --- a/acapy_agent/storage/vc_holder/base.py +++ b/acapy_agent/storage/vc_holder/base.py @@ -53,6 +53,7 @@ def build_type_or_schema_query(self, uri_list: Sequence[str]) -> dict: Args: uri_list: List of schema uri from input_descriptor + """ @abstractmethod diff --git a/acapy_agent/storage/vc_holder/vc_record.py b/acapy_agent/storage/vc_holder/vc_record.py index ea859c78e7..7544e75338 100644 --- a/acapy_agent/storage/vc_holder/vc_record.py +++ b/acapy_agent/storage/vc_holder/vc_record.py @@ -59,7 +59,6 @@ def serialize(self, as_string=False) -> dict: A dict representation of this model, or a JSON string if as_string is True """ - list_coercion = VCRecord(**dict(vars(self).items())) for k, v in vars(self).items(): if isinstance(v, set): diff --git a/acapy_agent/transport/inbound/base.py b/acapy_agent/transport/inbound/base.py index c41aac5102..f135b39e1b 100644 --- a/acapy_agent/transport/inbound/base.py +++ b/acapy_agent/transport/inbound/base.py @@ -36,6 +36,7 @@ def __init__( serialization. Defaults to None. root_profile (Profile, optional): The root profile for the transport. Defaults to None. + """ self._create_session = create_session self._max_message_size = max_message_size @@ -74,6 +75,7 @@ def create_session( can_respond: Flag indicating that the transport can send responses client_info: Request-specific client information wire_format: Optionally override the session wire format + """ return self._create_session( accept_undelivered=accept_undelivered, diff --git a/acapy_agent/transport/inbound/delivery_queue.py b/acapy_agent/transport/inbound/delivery_queue.py index d08ac30668..7d4e38a056 100644 --- a/acapy_agent/transport/inbound/delivery_queue.py +++ b/acapy_agent/transport/inbound/delivery_queue.py @@ -31,6 +31,7 @@ def older_than(self, compare_timestamp: float) -> bool: Args: compare_timestamp: The timestamp to compare + """ return self.timestamp < compare_timestamp @@ -46,7 +47,6 @@ def __init__(self) -> None: This uses an in memory structure to queue messages. """ - self.queue_by_key = {} self.ttl_seconds = 604800 # one week @@ -55,8 +55,8 @@ def expire_messages(self, ttl=None): Args: ttl: Optional. Allows override of configured ttl - """ + """ ttl_seconds = ttl or self.ttl_seconds horizon = time.time() - ttl_seconds for key in self.queue_by_key.keys(): @@ -71,6 +71,7 @@ def add_message(self, msg: OutboundMessage): Args: msg: The OutboundMessage to add + """ keys = set() if msg.target: @@ -88,6 +89,7 @@ def has_message_for_key(self, key: str): Args: key: The key to use for lookup + """ if key in self.queue_by_key and len(self.queue_by_key[key]): return True @@ -98,6 +100,7 @@ def message_count_for_key(self, key: str): Args: key: The key to use for lookup + """ if key in self.queue_by_key: return len(self.queue_by_key[key]) @@ -109,6 +112,7 @@ def get_one_message_for_key(self, key: str): Args: key: The key to use for lookup + """ if key in self.queue_by_key: return self.queue_by_key[key].pop(0).msg @@ -118,6 +122,7 @@ def inspect_all_messages_for_key(self, key: str): Args: key: The key to use for lookup + """ if key in self.queue_by_key: for wrapped_msg in self.queue_by_key[key]: @@ -129,6 +134,7 @@ def remove_message_for_key(self, key: str, msg: OutboundMessage): Args: key: The key to use for lookup msg: The message to remove from the queue + """ if key in self.queue_by_key: for wrapped_msg in self.queue_by_key[key]: diff --git a/acapy_agent/transport/inbound/manager.py b/acapy_agent/transport/inbound/manager.py index 0560f63097..e8e8927ce4 100644 --- a/acapy_agent/transport/inbound/manager.py +++ b/acapy_agent/transport/inbound/manager.py @@ -153,6 +153,7 @@ async def create_session( can_respond: Flag indicating that the transport can send responses client_info: An optional dict describing the client wire_format: Override the wire format for this session + """ if not wire_format: wire_format = self.profile.context.inject(BaseWireFormat) @@ -227,6 +228,7 @@ def process_undelivered(self, session: InboundSession): Args: session: The inbound session + """ if session and session.can_respond and self.undelivered_queue: for key in session.reply_verkeys: diff --git a/acapy_agent/transport/inbound/session.py b/acapy_agent/transport/inbound/session.py index 866f48df1f..08d71e389c 100644 --- a/acapy_agent/transport/inbound/session.py +++ b/acapy_agent/transport/inbound/session.py @@ -189,6 +189,7 @@ def process_inbound(self, message: InboundMessage): Args: message: The inbound message instance + """ receipt = message.receipt mode = self.reply_mode = ( diff --git a/acapy_agent/transport/inbound/ws.py b/acapy_agent/transport/inbound/ws.py index 5b3b1beddb..fbeb848a98 100644 --- a/acapy_agent/transport/inbound/ws.py +++ b/acapy_agent/transport/inbound/ws.py @@ -87,7 +87,6 @@ async def inbound_message_handler(self, request): The web response """ - ws = web.WebSocketResponse( autoping=True, heartbeat=self.heartbeat_interval, diff --git a/acapy_agent/transport/outbound/base.py b/acapy_agent/transport/outbound/base.py index f6b8b73fb0..5ab16cb2a7 100644 --- a/acapy_agent/transport/outbound/base.py +++ b/acapy_agent/transport/outbound/base.py @@ -111,6 +111,7 @@ async def handle_message( outbound_message: the outbound message to handle endpoint: URI endpoint for delivery metadata: Additional metadata associated with the payload + """ diff --git a/acapy_agent/transport/outbound/http.py b/acapy_agent/transport/outbound/http.py index 53b9b58429..232713b561 100644 --- a/acapy_agent/transport/outbound/http.py +++ b/acapy_agent/transport/outbound/http.py @@ -60,6 +60,7 @@ async def handle_message( endpoint: URI endpoint for delivery metadata: Additional metadata associated with the payload api_key: API key for the endpoint + """ if not endpoint: raise OutboundTransportError("No endpoint provided") diff --git a/acapy_agent/transport/outbound/manager.py b/acapy_agent/transport/outbound/manager.py index 2b8712eeb7..d8524735ac 100644 --- a/acapy_agent/transport/outbound/manager.py +++ b/acapy_agent/transport/outbound/manager.py @@ -224,6 +224,7 @@ async def enqueue_message(self, profile: Profile, outbound: OutboundMessage): Args: profile: The active profile for the request outbound: The outbound message to deliver + """ targets = [outbound.target] if outbound.target else (outbound.target_list or []) transport_id = None @@ -262,8 +263,8 @@ async def encode_outbound_message( profile: The active profile for the request outbound: The outbound message to deliver target: The outbound message target - """ + """ outbound_message = QueuedOutboundMessage(profile, outbound, target, None) if outbound_message.message.enc_payload: @@ -423,7 +424,6 @@ async def _process_loop(self): def encode_queued_message(self, queued: QueuedOutboundMessage) -> asyncio.Task: """Kick off encoding of a queued message.""" - transport = self.get_transport_instance(queued.transport_id) queued.task = self.task_queue.run( diff --git a/acapy_agent/transport/outbound/ws.py b/acapy_agent/transport/outbound/ws.py index 45376042fc..afc38b0e4f 100644 --- a/acapy_agent/transport/outbound/ws.py +++ b/acapy_agent/transport/outbound/ws.py @@ -46,6 +46,7 @@ async def handle_message( endpoint: URI endpoint for delivery metadata: Additional metadata associated with the payload api_key: API key for the endpoint + """ # aiohttp should automatically handle websocket sessions async with self.client_session.ws_connect(endpoint, headers=metadata) as ws: diff --git a/acapy_agent/transport/pack_format.py b/acapy_agent/transport/pack_format.py index 4c70143b1a..39221f5be7 100644 --- a/acapy_agent/transport/pack_format.py +++ b/acapy_agent/transport/pack_format.py @@ -29,7 +29,6 @@ def get_version_for_packed_msg(packed_msg: Union[str, bytes]): """Get the version of the packed message.""" - # Raise differnt errors? Not ValueError? protected_b64 = json.loads(packed_msg).get("protected") if not protected_b64: @@ -53,7 +52,6 @@ def get_version_for_packed_msg(packed_msg: Union[str, bytes]): def get_version_for_outbound_msg(outbound_msg: Union[str, bytes]): """Get the version of the packed message.""" - msg_json = json.loads(outbound_msg) if DIDCOMM_V2_ID in msg_json: @@ -89,7 +87,6 @@ async def parse_message( self, session: ProfileSession, message_body: Union[str, bytes] ) -> Tuple[dict, MessageReceipt]: """Pass an incoming message to the appropriately versioned PackWireFormat.""" - if session.profile.settings.get("experiment.didcomm_v2"): try: pack_format = self.get_for_packed_msg(message_body) @@ -119,7 +116,6 @@ async def encode_message( sender_key: str, ) -> Union[str, bytes]: """Pass an incoming message to the appropriately versioned PackWireFormat.""" - if session.profile.settings.get("experiment.didcomm_v2"): try: pack_format = self.get_for_outbound_msg(message_json) @@ -149,7 +145,6 @@ async def unpack( receipt: MessageReceipt, ): """Look up the wallet instance and perform the message unpack.""" - return await self.v1pack_format.unpack( session=session, message_body=message_body, receipt=receipt ) @@ -163,7 +158,6 @@ async def pack( sender_key: str, ): """Look up the wallet instance and perform the message pack.""" - return await self.v1pack_format.pack( session=session, message_json=message_json, @@ -195,7 +189,6 @@ async def parse_message( WireFormatParseError: If a wallet is required but can't be located """ - receipt = MessageReceipt() receipt.in_time = time_now() receipt.raw_message = message_body @@ -291,7 +284,6 @@ async def encode_message( MessageEncodeError: If the message could not be encoded """ - if sender_key and recipient_keys: message = await self.pack( session, message_json, recipient_keys, routing_keys, sender_key @@ -347,7 +339,6 @@ def get_recipient_keys(self, message_body: Union[str, bytes]) -> List[str]: RecipientKeysError: If the recipient keys could not be extracted """ - try: message_dict = json.loads(message_body) protected = json.loads(b64_to_str(message_dict["protected"], urlsafe=True)) diff --git a/acapy_agent/transport/v2_pack_format.py b/acapy_agent/transport/v2_pack_format.py index 92e26da698..da4008e0d3 100644 --- a/acapy_agent/transport/v2_pack_format.py +++ b/acapy_agent/transport/v2_pack_format.py @@ -32,7 +32,6 @@ async def parse_message( message_body: Union[str, bytes], ) -> Tuple[dict, MessageReceipt]: """Parse message.""" - messaging = session.inject(DIDCommMessaging) receipt = MessageReceipt() diff --git a/acapy_agent/transport/wire_format.py b/acapy_agent/transport/wire_format.py index ac7f446ce8..70c675150a 100644 --- a/acapy_agent/transport/wire_format.py +++ b/acapy_agent/transport/wire_format.py @@ -179,6 +179,5 @@ def get_recipient_keys(self, message_body: Union[str, bytes]) -> List[str]: RecipientKeysError: If the recipient keys could not be extracted """ - # JSON message cannot contain recipient keys return [] diff --git a/acapy_agent/utils/classloader.py b/acapy_agent/utils/classloader.py index aafcfc33ca..c1ef7e2f2c 100644 --- a/acapy_agent/utils/classloader.py +++ b/acapy_agent/utils/classloader.py @@ -41,7 +41,6 @@ def load_module( ModuleLoadError: If there was an error loading the module """ - if package: # preload parent package if not cls.load_module(package): @@ -98,7 +97,6 @@ def load_class( ModuleLoadError: If there was an error loading the module """ - if "." in class_name: # import module and find class mod_path, class_name = class_name.rsplit(".", 1) @@ -154,7 +152,6 @@ def load_subclass_of( ModuleLoadError: If there was an error loading the module """ - mod = cls.load_module(mod_path, package) if not mod: LOGGER.warning( diff --git a/acapy_agent/utils/endorsement_setup.py b/acapy_agent/utils/endorsement_setup.py index 24b29cf0db..56ba716846 100644 --- a/acapy_agent/utils/endorsement_setup.py +++ b/acapy_agent/utils/endorsement_setup.py @@ -22,7 +22,6 @@ class EndorsementSetupError(Exception): async def attempt_auto_author_with_endorser_setup(profile: Profile): """Automatically setup the author's endorser connection if possible.""" - if not is_author_role(profile): return diff --git a/acapy_agent/utils/multiformats/multibase.py b/acapy_agent/utils/multiformats/multibase.py index 5f9ee5c0ff..d39185ffbf 100644 --- a/acapy_agent/utils/multiformats/multibase.py +++ b/acapy_agent/utils/multiformats/multibase.py @@ -77,6 +77,7 @@ def encode(value: bytes, encoding: Union[Encoding, EncodingStr]) -> str: Returns: The encoded string + """ if isinstance(encoding, str): encoder = Encoding.from_name(encoding) @@ -96,6 +97,7 @@ def decode(value: str) -> bytes: Returns: The decoded byte string + """ encoding = value[0] encoded = value[1:] diff --git a/acapy_agent/utils/task_queue.py b/acapy_agent/utils/task_queue.py index 5780dd1a9d..9e9016ecf1 100644 --- a/acapy_agent/utils/task_queue.py +++ b/acapy_agent/utils/task_queue.py @@ -74,6 +74,7 @@ def __init__( ident: A string identifier for the task task_future: A future to be resolved to the asyncio Task queued_time: When the pending task was added to the queue + """ if not asyncio.iscoroutine(coro): raise ValueError(f"Expected coroutine, got {coro}") @@ -135,6 +136,7 @@ def __init__( max_active: The maximum number of tasks to automatically run timed: A flag indicating that timing should be collected for tasks trace_fn: A callback for all completed tasks + """ self.loop = asyncio.get_event_loop() self.active_tasks = [] @@ -188,6 +190,7 @@ def __bool__(self) -> bool: Return: True - the task queue exists even if there are no tasks + """ return True @@ -247,6 +250,7 @@ def add_pending(self, pending: PendingTask): Args: pending: The `PendingTask` to add to the task queue + """ if self.timed and not pending.queued_time: pending.queued_time = time.perf_counter() @@ -267,6 +271,7 @@ def add_active( task_complete: An optional callback to run on completion ident: A string identifier for the task timing: An optional dictionary of timing information + """ self.active_tasks.append(task) task.add_done_callback( diff --git a/acapy_agent/utils/testing.py b/acapy_agent/utils/testing.py index c785d9df3f..3563702740 100644 --- a/acapy_agent/utils/testing.py +++ b/acapy_agent/utils/testing.py @@ -65,11 +65,11 @@ def skip_on_jsonld_url_error(test_func): Returns: Wrapped test function that skips on JSON-LD URL resolution errors + """ def _handle_jsonld_error(e): """Check if exception is a JSON-LD URL resolution error and skip if so.""" - if isinstance(e, JsonLdError): error_str = str(e) # Check for specific JSON-LD URL resolution error patterns diff --git a/acapy_agent/utils/tracing.py b/acapy_agent/utils/tracing.py index cf9796ace4..47f5a744a5 100644 --- a/acapy_agent/utils/tracing.py +++ b/acapy_agent/utils/tracing.py @@ -88,7 +88,6 @@ def tracing_enabled(context, message) -> bool: def decode_inbound_message(message): """Return bundled message if appropriate.""" - if message and isinstance(message, OutboundMessage): if message.payload and isinstance(message.payload, AgentMessage): return message.payload @@ -144,7 +143,6 @@ def trace_event( True. """ - ret = time.perf_counter() if force_trace or tracing_enabled(context, message): diff --git a/acapy_agent/vc/data_integrity/models/options.py b/acapy_agent/vc/data_integrity/models/options.py index 2fe39a1377..4afb3943b3 100644 --- a/acapy_agent/vc/data_integrity/models/options.py +++ b/acapy_agent/vc/data_integrity/models/options.py @@ -33,7 +33,6 @@ def __init__( **kwargs, ) -> None: """Initialize the DataIntegrityProofOptions instance.""" - self.id = id self.type = type self.proof_purpose = proof_purpose @@ -210,7 +209,6 @@ class Meta: @post_dump(pass_original=True) def add_unknown_properties(self, data: dict, original, **kwargs): """Add back unknown properties before outputting.""" - data.update(original.extra) return data diff --git a/acapy_agent/vc/data_integrity/models/proof.py b/acapy_agent/vc/data_integrity/models/proof.py index ad17ff5f1b..6d3343097f 100644 --- a/acapy_agent/vc/data_integrity/models/proof.py +++ b/acapy_agent/vc/data_integrity/models/proof.py @@ -33,7 +33,6 @@ def __init__( **kwargs, ) -> None: """Initialize the DataIntegrityProof instance.""" - self.id = id self.type = type self.proof_purpose = proof_purpose @@ -212,7 +211,6 @@ class Meta: @post_dump(pass_original=True) def add_unknown_properties(self, data: dict, original, **kwargs): """Add back unknown properties before outputting.""" - data.update(original.extra) return data diff --git a/acapy_agent/vc/data_integrity/models/verification_response.py b/acapy_agent/vc/data_integrity/models/verification_response.py index 2e16eded09..b303f78eb7 100644 --- a/acapy_agent/vc/data_integrity/models/verification_response.py +++ b/acapy_agent/vc/data_integrity/models/verification_response.py @@ -23,7 +23,6 @@ def __init__( detail: Optional[str] = None, ) -> None: """Initialize the ProblemDetails instance.""" - self.type = type self.title = title self.detail = detail @@ -75,7 +74,6 @@ def __init__( problem_details: Optional[List[ProblemDetails]] = None, ) -> None: """Initialize the DataIntegrityVerificationResult instance.""" - self.verified = verified self.proof = proof self.problem_details = problem_details @@ -126,7 +124,6 @@ def __init__( results: Optional[List[DataIntegrityVerificationResult]] = None, ) -> None: """Initialize the DataIntegrityVerificationResponse instance.""" - self.verified = verified self.verified_document = verified_document self.results = results diff --git a/acapy_agent/vc/data_integrity/routes.py b/acapy_agent/vc/data_integrity/routes.py index d87da63474..186fc632b0 100644 --- a/acapy_agent/vc/data_integrity/routes.py +++ b/acapy_agent/vc/data_integrity/routes.py @@ -143,7 +143,6 @@ async def verify_di_secured_document(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.post("/vc/di/add-proof", add_di_proof), diff --git a/acapy_agent/vc/ld_proofs/document_loader.py b/acapy_agent/vc/ld_proofs/document_loader.py index c348228687..d11b1a213f 100644 --- a/acapy_agent/vc/ld_proofs/document_loader.py +++ b/acapy_agent/vc/ld_proofs/document_loader.py @@ -62,7 +62,6 @@ def _load_http_document(self, url: str, options: dict): # Async document loader can use await for cache and did resolver async def _load_async(self, url: str, options: dict): """Retrieve http(s) or did document.""" - # Resolve DIDs using did resolver if url.startswith("did:"): document = await self._load_did_document(url, options) @@ -101,7 +100,6 @@ async def load_document(self, url: str, options: dict): def __call__(self, url: str, options: dict): """Load JSON-LD Document.""" - loop = self._event_loop coroutine = self.load_document(url, options) document = loop.run_until_complete(coroutine) diff --git a/acapy_agent/vc/ld_proofs/ld_proofs.py b/acapy_agent/vc/ld_proofs/ld_proofs.py index 02269698a4..7af0b6eecd 100644 --- a/acapy_agent/vc/ld_proofs/ld_proofs.py +++ b/acapy_agent/vc/ld_proofs/ld_proofs.py @@ -68,7 +68,6 @@ async def verify( containing all of the errors that occurred during the verification process. """ - result = await ProofSet.verify( document=document, suites=suites, @@ -104,7 +103,6 @@ async def derive( dict: The document with derived proof(s). """ - result = await ProofSet.derive( document=document, reveal_document=reveal_document, diff --git a/acapy_agent/vc/ld_proofs/proof_set.py b/acapy_agent/vc/ld_proofs/proof_set.py index de43ebc749..219cf7ddab 100644 --- a/acapy_agent/vc/ld_proofs/proof_set.py +++ b/acapy_agent/vc/ld_proofs/proof_set.py @@ -245,7 +245,6 @@ async def _verify( in the suites lists. This means proofs that don't match on any of these WILL NOT be verified OR included in the proof result list. """ - # Matches proof purposes proof set to passed purpose. # Only proofs with a `proofPurpose` that match the purpose are verified # e.g.: diff --git a/acapy_agent/vc/ld_proofs/suites/bbs_bls_signature_2020.py b/acapy_agent/vc/ld_proofs/suites/bbs_bls_signature_2020.py index 585b1cc970..603f80e62b 100644 --- a/acapy_agent/vc/ld_proofs/suites/bbs_bls_signature_2020.py +++ b/acapy_agent/vc/ld_proofs/suites/bbs_bls_signature_2020.py @@ -207,7 +207,6 @@ async def verify_signature( bool: Whether the signature is valid for the data """ - if not (isinstance(proof.get("proofValue"), str)): raise LinkedDataProofException( 'The proof does not contain a valid "proofValue" property.' diff --git a/acapy_agent/vc/ld_proofs/suites/ecdsa_secp256r1_signature_2019.py b/acapy_agent/vc/ld_proofs/suites/ecdsa_secp256r1_signature_2019.py index 27d4022089..46b3be132d 100644 --- a/acapy_agent/vc/ld_proofs/suites/ecdsa_secp256r1_signature_2019.py +++ b/acapy_agent/vc/ld_proofs/suites/ecdsa_secp256r1_signature_2019.py @@ -32,6 +32,7 @@ def __init__( using a context different from security-v2). verification_method (str, optional): A key id URL to the paired public key. date (datetime, optional): Signing date to use. + """ super().__init__( verification_method=verification_method, @@ -79,7 +80,6 @@ async def verify_signature( bool: Whether the signature is valid for the data """ - if not (isinstance(proof.get("proofValue"), str)): raise LinkedDataProofException( 'The proof does not contain a valid "proofValue" property.' diff --git a/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2018.py b/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2018.py index abc812ee12..0363630585 100644 --- a/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2018.py +++ b/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2018.py @@ -29,6 +29,7 @@ def __init__( using a context different from security-v2). verification_method (str, optional): A key id URL to the paired public key. date (datetime, optional): Signing date to use. + """ super().__init__( algorithm="EdDSA", diff --git a/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2020.py b/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2020.py index 85df38bf52..e6c7a50e9c 100644 --- a/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2020.py +++ b/acapy_agent/vc/ld_proofs/suites/ed25519_signature_2020.py @@ -32,6 +32,7 @@ def __init__( using a context different from security-v2). verification_method (str, optional): A key id URL to the paired public key. date (datetime, optional): Signing date to use. + """ super().__init__( verification_method=verification_method, @@ -79,7 +80,6 @@ async def verify_signature( bool: Whether the signature is valid for the data """ - if not (isinstance(proof.get("proofValue"), str)): raise LinkedDataProofException( 'The proof does not contain a valid "proofValue" property.' diff --git a/acapy_agent/vc/ld_proofs/suites/jws_linked_data_signature.py b/acapy_agent/vc/ld_proofs/suites/jws_linked_data_signature.py index 10a4253e68..c1e2510d54 100644 --- a/acapy_agent/vc/ld_proofs/suites/jws_linked_data_signature.py +++ b/acapy_agent/vc/ld_proofs/suites/jws_linked_data_signature.py @@ -40,8 +40,8 @@ def __init__( using a context different from security-v2). verification_method (str, optional): A key id URL to the paired public key. date (datetime, optional): Signing date to use. Defaults to now - """ + """ super().__init__( verification_method=verification_method, proof=proof, @@ -66,7 +66,6 @@ async def sign(self, *, verify_data: bytes, proof: dict) -> dict: dict: The proof object with the added signature """ - header = {"alg": self.algorithm, "b64": False, "crit": ["b64"]} encoded_header = self._encode_header(header) diff --git a/acapy_agent/vc/ld_proofs/suites/linked_data_proof.py b/acapy_agent/vc/ld_proofs/suites/linked_data_proof.py index c6846168f2..296c890b5f 100644 --- a/acapy_agent/vc/ld_proofs/suites/linked_data_proof.py +++ b/acapy_agent/vc/ld_proofs/suites/linked_data_proof.py @@ -132,7 +132,6 @@ def _get_verification_method( self, *, proof: dict, document_loader: DocumentLoaderMethod ) -> dict: """Get verification method for proof.""" - verification_method = proof.get("verificationMethod") if isinstance(verification_method, dict): diff --git a/acapy_agent/vc/routes.py b/acapy_agent/vc/routes.py index 9977d90d5c..0c3bba6638 100644 --- a/acapy_agent/vc/routes.py +++ b/acapy_agent/vc/routes.py @@ -255,7 +255,6 @@ async def verify_presentation_route(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/vc/credentials", list_credentials_route, allow_head=False), diff --git a/acapy_agent/vc/vc_di/prove.py b/acapy_agent/vc/vc_di/prove.py index 0180908724..bc441f9b74 100644 --- a/acapy_agent/vc/vc_di/prove.py +++ b/acapy_agent/vc/vc_di/prove.py @@ -57,7 +57,6 @@ async def create_signed_anoncreds_presentation( dict: A verifiable presentation object """ - if not challenge: raise LinkedDataProofException( 'A "challenge" param is required when not providing a' @@ -104,6 +103,7 @@ async def _load_w3c_credentials(credentials: list) -> list: Returns: list: A list of W3C credentials + """ w3c_creds = [] for credential in credentials: @@ -133,6 +133,7 @@ async def create_rev_states( Returns: dict: A dictionary of revocation states + """ if not bool(rev_reg_defs and rev_reg_entries): return None @@ -184,8 +185,8 @@ async def prepare_data_for_presentation( Returns: tuple[dict[str, Any], list, list]: A tuple of the anoncreds proof request, the W3C credentials metadata, and the W3C credentials - """ + """ if not challenge: raise LinkedDataProofException("A challenge is required") @@ -330,6 +331,7 @@ def _extract_cred_idx(item_path: str) -> int: Returns: int: extracted index + """ match = re.search(r"\[(\d+)\]", item_path) if match: @@ -349,8 +351,8 @@ def _get_predicate_type_and_value(pred_filter: dict) -> Tuple[str, str]: Returns: Tuple[str, str]: predicate type and value - """ + """ supported_properties = { "exclusiveMinimum": ">", "exclusiveMaximum": "<", diff --git a/acapy_agent/vc/vc_di/verify.py b/acapy_agent/vc/vc_di/verify.py index 2c6616f4ec..4dc0152929 100644 --- a/acapy_agent/vc/vc_di/verify.py +++ b/acapy_agent/vc/vc_di/verify.py @@ -37,7 +37,6 @@ async def verify_signed_anoncredspresentation( indicates whether the verification was successful """ - # TODO: I think we should add some sort of options to authenticate the subject id # to the presentation verification method controller anoncreds_verifier = AnonCredsVerifier(profile) diff --git a/acapy_agent/vc/vc_ld/manager.py b/acapy_agent/vc/vc_ld/manager.py index a1f5cbe377..42d2fda198 100644 --- a/acapy_agent/vc/vc_ld/manager.py +++ b/acapy_agent/vc/vc_ld/manager.py @@ -3,13 +3,13 @@ from datetime import datetime, timezone from typing import Dict, List, Optional, Type, Union, cast -from acapy_agent.wallet.keys.manager import MultikeyManager, multikey_to_verkey from pyld import jsonld from pyld.jsonld import JsonLdProcessor from acapy_agent.vc.ld_proofs.suites.ecdsa_secp256r1_signature_2019 import ( EcdsaSecp256r1Signature2019, ) +from acapy_agent.wallet.keys.manager import MultikeyManager, multikey_to_verkey from ...core.profile import Profile from ...storage.vc_holder.base import VCHolder @@ -389,7 +389,6 @@ async def store_credential( cred_id: Optional[str] = None, ) -> VCRecord: """Store a verifiable credential.""" - # Saving expanded type as a cred_tag document_loader = self.profile.inject(DocumentLoader) expanded = jsonld.expand( @@ -456,7 +455,6 @@ async def verify_presentation( self, vp: VerifiablePresentation, options: LDProofVCOptions ) -> PresentationVerificationResult: """Verify a VP with a Linked Data Proof.""" - if not options.challenge: raise VcLdpManagerError("Challenge is required for verifying a VP") diff --git a/acapy_agent/vc/vc_ld/models/credential.py b/acapy_agent/vc/vc_ld/models/credential.py index 540e3c593d..13eb40b2b3 100644 --- a/acapy_agent/vc/vc_ld/models/credential.py +++ b/acapy_agent/vc/vc_ld/models/credential.py @@ -254,7 +254,6 @@ def credential_subject(self): @credential_subject.setter def credential_subject(self, credential_subject: Union[dict, List[dict]]): """Setter for credential subject.""" - uri_validator = Uri() subjects = ( @@ -438,7 +437,6 @@ class Meta: @post_dump(pass_original=True) def add_unknown_properties(self, data: dict, original, **kwargs): """Add back unknown properties before outputting.""" - data.update(original.extra) return data diff --git a/acapy_agent/vc/vc_ld/models/linked_data_proof.py b/acapy_agent/vc/vc_ld/models/linked_data_proof.py index 57853000c6..85150fe074 100644 --- a/acapy_agent/vc/vc_ld/models/linked_data_proof.py +++ b/acapy_agent/vc/vc_ld/models/linked_data_proof.py @@ -35,7 +35,6 @@ def __init__( **kwargs, ) -> None: """Initialize the LDProof instance.""" - self.type = type self.proof_purpose = proof_purpose self.verification_method = verification_method @@ -160,7 +159,6 @@ class Meta: @post_dump(pass_original=True) def add_unknown_properties(self, data: dict, original, **kwargs): """Add back unknown properties before outputting.""" - data.update(original.extra) return data diff --git a/acapy_agent/vc/vc_ld/models/options.py b/acapy_agent/vc/vc_ld/models/options.py index a939df56ac..326a7381d8 100644 --- a/acapy_agent/vc/vc_ld/models/options.py +++ b/acapy_agent/vc/vc_ld/models/options.py @@ -32,7 +32,6 @@ def __init__( credential_status: Optional[dict] = None, ) -> None: """Initialize the LDProofVCDetailOptions instance.""" - self.verification_method = verification_method self.proof_type = proof_type self.proof_purpose = proof_purpose diff --git a/acapy_agent/vc/vc_ld/models/presentation.py b/acapy_agent/vc/vc_ld/models/presentation.py index e288a77e84..e3f6dc32b9 100644 --- a/acapy_agent/vc/vc_ld/models/presentation.py +++ b/acapy_agent/vc/vc_ld/models/presentation.py @@ -156,7 +156,6 @@ def verifiable_credential(self): @verifiable_credential.setter def verifiable_credential(self, verifiable_credential: List[dict]): """Setter for verifiable credential.""" - self._verifiable_credential = verifiable_credential @property @@ -271,7 +270,6 @@ class Meta: @post_dump(pass_original=True) def add_unknown_properties(self, data: dict, original, **kwargs): """Add back unknown properties before outputting.""" - data.update(original.extra) return data diff --git a/acapy_agent/vc/vc_ld/prove.py b/acapy_agent/vc/vc_ld/prove.py index e20cad3a92..c0d226a7c2 100644 --- a/acapy_agent/vc/vc_ld/prove.py +++ b/acapy_agent/vc/vc_ld/prove.py @@ -123,7 +123,6 @@ async def derive_credential( dict: The derived credential. """ - # Validate credential structure errors = VerifiableCredentialSchema().validate(credential) if len(errors) > 0: diff --git a/acapy_agent/vc/vc_ld/tests/test_vc_ld.py b/acapy_agent/vc/vc_ld/tests/test_vc_ld.py index bfcd56ce32..e2ddb5a8b7 100644 --- a/acapy_agent/vc/vc_ld/tests/test_vc_ld.py +++ b/acapy_agent/vc/vc_ld/tests/test_vc_ld.py @@ -15,9 +15,14 @@ ) from ...ld_proofs.error import LinkedDataProofException from ...tests.document_loader import custom_document_loader -from ...vc_ld import create_presentation, derive_credential +from ...vc_ld import ( + create_presentation, + derive_credential, + sign_presentation, + verify_credential, + verify_presentation, +) 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/acapy_agent/vc/vc_ld/verify.py b/acapy_agent/vc/vc_ld/verify.py index 07f856d7b3..c60836e901 100644 --- a/acapy_agent/vc/vc_ld/verify.py +++ b/acapy_agent/vc/vc_ld/verify.py @@ -27,7 +27,6 @@ async def _verify_credential( purpose: Optional[ProofPurpose] = None, ) -> DocumentVerificationResult: """Verify credential structure, proof purpose and signature.""" - # Validate credential structure errors = VerifiableCredentialSchema().validate(credential) if len(errors) > 0: @@ -90,7 +89,6 @@ async def _verify_presentation( purpose: Optional[ProofPurpose] = None, ): """Verify presentation structure, credentials, proof purpose and signature.""" - if not purpose and not challenge: raise LinkedDataProofException( 'A "challenge" param is required for AuthenticationProofPurpose.' @@ -165,7 +163,6 @@ async def verify_presentation( indicates whether the verification was successful """ - # TODO: I think we should add some sort of options to authenticate the subject id # to the presentation verification method controller diff --git a/acapy_agent/wallet/anoncreds_upgrade.py b/acapy_agent/wallet/anoncreds_upgrade.py index 4646a838f8..154d5ea396 100644 --- a/acapy_agent/wallet/anoncreds_upgrade.py +++ b/acapy_agent/wallet/anoncreds_upgrade.py @@ -149,7 +149,6 @@ async def get_schema_upgrade_object( profile: Profile, schema_id: str, askar_schema ) -> SchemaUpgradeObj: """Get schema upgrade object.""" - async with profile.session() as session: schema_id = askar_schema.tags.get("schema_id") issuer_did = askar_schema.tags.get("schema_issuer_did") @@ -459,7 +458,6 @@ async def get_rev_reg_def_upgrade_objs( rev_list_upgrade_objs: list[RevListUpgradeObj], ) -> list[RevRegDefUpgradeObj]: """Get rev reg def upgrade objects.""" - rev_reg_def_upgrade_objs = [] async with profile.session() as session: storage = session.inject(BaseStorage) diff --git a/acapy_agent/wallet/askar.py b/acapy_agent/wallet/askar.py index f3c59df877..97ea0d5dfe 100644 --- a/acapy_agent/wallet/askar.py +++ b/acapy_agent/wallet/askar.py @@ -39,6 +39,7 @@ def __init__(self, session: AskarProfileSession): Args: session: The Askar profile session instance to use + """ self._session = session @@ -91,6 +92,7 @@ async def create_key( Raises: WalletDuplicateError: If the resulting verkey already exists in the wallet WalletError: If there is another backend error + """ if metadata is None: metadata = {} @@ -238,7 +240,6 @@ async def get_signing_key(self, verkey: str) -> KeyInfo: WalletError: If there is another backend error """ - if not verkey: raise WalletNotFoundError("No key identifier provided") key_entry = await self._session.handle.fetch_key(verkey) @@ -266,7 +267,6 @@ async def replace_signing_key_metadata(self, verkey: str, metadata: dict): WalletNotFoundError: if no keypair is associated with the verification key """ - # FIXME caller should always create a transaction first if not verkey: @@ -387,6 +387,7 @@ async def store_did(self, did_info: DIDInfo) -> DIDInfo: Returns: The stored `DIDInfo` + """ LOGGER.debug("Storing DID %s", did_info.did) try: @@ -582,7 +583,6 @@ async def set_public_did(self, did: Union[str, DIDInfo]) -> DIDInfo: The updated `DIDInfo` """ - if isinstance(did, str): try: item = await self._session.handle.fetch( diff --git a/acapy_agent/wallet/base.py b/acapy_agent/wallet/base.py index c92ecf6bd1..6b45929d5a 100644 --- a/acapy_agent/wallet/base.py +++ b/acapy_agent/wallet/base.py @@ -55,6 +55,7 @@ async def create_key( Raises: WalletDuplicateError: If the resulting verkey already exists in the wallet WalletError: If there is another backend error + """ @abstractmethod @@ -173,6 +174,7 @@ async def store_did(self, did_info: DIDInfo) -> DIDInfo: Returns: The stored `DIDInfo` + """ async def create_public_did( diff --git a/acapy_agent/wallet/crypto.py b/acapy_agent/wallet/crypto.py index ed6679aae5..7ccb25edc7 100644 --- a/acapy_agent/wallet/crypto.py +++ b/acapy_agent/wallet/crypto.py @@ -97,6 +97,7 @@ def did_is_self_certified(did: str, verkey: str) -> bool: Args: did: DID string verkey: VERKEY string + """ ABBREVIATED_VERKEY_REGEX = "^~[1-9A-HJ-NP-Za-km-z]{21,22}$" if re.search(ABBREVIATED_VERKEY_REGEX, verkey): diff --git a/acapy_agent/wallet/did_info.py b/acapy_agent/wallet/did_info.py index bc1554fddf..e0afb7bb0c 100644 --- a/acapy_agent/wallet/did_info.py +++ b/acapy_agent/wallet/did_info.py @@ -1,6 +1,6 @@ """KeyInfo, DIDInfo.""" -from typing import NamedTuple, Union, List, Optional +from typing import List, NamedTuple, Optional, Union from .did_method import DIDMethod from .key_type import KeyType diff --git a/acapy_agent/wallet/keys/manager.py b/acapy_agent/wallet/keys/manager.py index b5292ab9fc..56ae573c66 100644 --- a/acapy_agent/wallet/keys/manager.py +++ b/acapy_agent/wallet/keys/manager.py @@ -1,6 +1,9 @@ """Multikey class.""" import logging + +from pydid import VerificationMethod + from ...core.profile import ProfileSession from ...resolver.did_resolver import DIDResolver from ...utils.multiformats import multibase @@ -8,7 +11,6 @@ from ..base import BaseWallet from ..key_type import BLS12381G2, ED25519, P256, KeyType from ..util import b58_to_bytes, bytes_to_b58 -from pydid import VerificationMethod LOGGER = logging.getLogger(__name__) @@ -43,7 +45,6 @@ def multikey_to_verkey(multikey: str): """Transform multikey to verkey.""" - alg = key_type_from_multikey(multikey).key_type prefix_length = ALG_MAPPINGS[alg]["prefix_length"] public_bytes = bytes(bytearray(multibase.decode(multikey))[prefix_length:]) @@ -53,7 +54,6 @@ def multikey_to_verkey(multikey: str): def verkey_to_multikey(verkey: str, alg: str): """Transform verkey to multikey.""" - prefix_hex = ALG_MAPPINGS[alg]["prefix_hex"] prefixed_key_hex = f"{prefix_hex}{b58_to_bytes(verkey).hex()}" @@ -103,7 +103,6 @@ class MultikeyManager: def __init__(self, session: ProfileSession): """Initialize the MultikeyManager.""" - self.session: ProfileSession = session self.wallet: BaseWallet = session.inject(BaseWallet) @@ -142,7 +141,6 @@ def key_type_from_multikey(self, multikey: str) -> KeyType: async def kid_exists(self, kid: str): """Check if kid exists.""" - try: key = await self.wallet.get_key_by_kid(kid=kid) @@ -155,7 +153,6 @@ async def kid_exists(self, kid: str): async def multikey_exists(self, multikey: str): """Check if a multikey exists in the wallet.""" - try: key_info = await self.wallet.get_signing_key( verkey=multikey_to_verkey(multikey) @@ -170,7 +167,6 @@ async def multikey_exists(self, multikey: str): async def from_kid(self, kid: str): """Fetch a single key.""" - try: key_info = await self.wallet.get_key_by_kid(kid=kid) @@ -186,7 +182,6 @@ async def from_kid(self, kid: str): async def from_multikey(self, multikey: str): """Fetch a single key.""" - key_info = await self.wallet.get_signing_key(verkey=multikey_to_verkey(multikey)) return { @@ -198,7 +193,6 @@ async def from_multikey(self, multikey: str): async def create(self, seed: str = None, kid: str = None, alg: str = DEFAULT_ALG): """Create a new key pair.""" - if alg not in ALG_MAPPINGS: raise MultikeyManagerError( f"Unknown key algorithm, use one of {list(ALG_MAPPINGS.keys())}." diff --git a/acapy_agent/wallet/keys/routes.py b/acapy_agent/wallet/keys/routes.py index c35b02288c..db5f93259e 100644 --- a/acapy_agent/wallet/keys/routes.py +++ b/acapy_agent/wallet/keys/routes.py @@ -221,7 +221,6 @@ async def update_key(request: web.BaseRequest): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/wallet/keys/{multikey}", fetch_key, allow_head=False), diff --git a/acapy_agent/wallet/models/wallet_record.py b/acapy_agent/wallet/models/wallet_record.py index 93549be5fc..0743c65b55 100644 --- a/acapy_agent/wallet/models/wallet_record.py +++ b/acapy_agent/wallet/models/wallet_record.py @@ -100,7 +100,6 @@ def is_managed(self) -> bool: @property def requires_external_key(self) -> bool: """Accessor to check if the wallet requires an external key.""" - # Key not required for in_memory wallets if self.wallet_type == "in_memory": return False diff --git a/acapy_agent/wallet/routes.py b/acapy_agent/wallet/routes.py index a84c52caf7..16abcb042e 100644 --- a/acapy_agent/wallet/routes.py +++ b/acapy_agent/wallet/routes.py @@ -987,6 +987,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest): Args: request: aiohttp request object + """ context: AdminRequestContext = request["context"] @@ -1252,6 +1253,7 @@ async def wallet_sd_jwt_verify(request: web.BaseRequest): web.HTTPBadRequest: If there is an error with the JWS header or verification method. web.HTTPNotFound: If there is an error resolving the verification method. + """ context: AdminRequestContext = request["context"] body = await request.json() @@ -1421,7 +1423,6 @@ def register_events(event_bus: EventBus): async def on_register_nym_event(profile: Profile, event: Event): """Handle any events we need to support.""" - # after the nym record is written, promote to wallet public DID if is_author_role(profile) and profile.context.settings.get_value( "endorser.auto_promote_author_did" @@ -1489,7 +1490,6 @@ async def on_register_nym_event(profile: Profile, event: Event): async def register(app: web.Application): """Register routes.""" - app.add_routes( [ web.get("/wallet/did", wallet_did_list, allow_head=False), @@ -1512,7 +1512,6 @@ async def register(app: web.Application): def post_process_routes(app: web.Application): """Amend swagger API.""" - # Add top-level tags description if "tags" not in app._state["swagger_dict"]: app._state["swagger_dict"]["tags"] = [] diff --git a/poetry.lock b/poetry.lock index 83fce9126e..28fabe9075 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.2.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -1336,8 +1336,6 @@ python-versions = "*" groups = ["main"] files = [ {file = "jsonpath-ng-1.7.0.tar.gz", hash = "sha256:f6f5f7fd4e5ff79c785f1573b394043b39849fb2bb47bcead935d12b00beab3c"}, - {file = "jsonpath_ng-1.7.0-py2-none-any.whl", hash = "sha256:898c93fc173f0c336784a3fa63d7434297544b7198124a68f9a3ef9597b0ae6e"}, - {file = "jsonpath_ng-1.7.0-py3-none-any.whl", hash = "sha256:f3d7f9e848cba1b6da28c55b1c26ff915dc9e0b1ba7e752a53d6da8d5cbd00b6"}, ] [package.dependencies] @@ -1401,12 +1399,10 @@ files = [ {file = "lxml-6.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:219e0431ea8006e15005767f0351e3f7f9143e793e58519dc97fe9e07fae5563"}, {file = "lxml-6.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bd5913b4972681ffc9718bc2d4c53cde39ef81415e1671ff93e9aa30b46595e7"}, {file = "lxml-6.0.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:390240baeb9f415a82eefc2e13285016f9c8b5ad71ec80574ae8fa9605093cd7"}, - {file = "lxml-6.0.0-cp312-cp312-manylinux_2_27_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:d6e200909a119626744dd81bae409fc44134389e03fbf1d68ed2a55a2fb10991"}, {file = "lxml-6.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ca50bd612438258a91b5b3788c6621c1f05c8c478e7951899f492be42defc0da"}, {file = "lxml-6.0.0-cp312-cp312-manylinux_2_31_armv7l.whl", hash = "sha256:c24b8efd9c0f62bad0439283c2c795ef916c5a6b75f03c17799775c7ae3c0c9e"}, {file = "lxml-6.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:afd27d8629ae94c5d863e32ab0e1d5590371d296b87dae0a751fb22bf3685741"}, {file = "lxml-6.0.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:54c4855eabd9fc29707d30141be99e5cd1102e7d2258d2892314cf4c110726c3"}, - {file = "lxml-6.0.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:c907516d49f77f6cd8ead1322198bdfd902003c3c330c77a1c5f3cc32a0e4d16"}, {file = "lxml-6.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:36531f81c8214e293097cd2b7873f178997dae33d3667caaae8bdfb9666b76c0"}, {file = "lxml-6.0.0-cp312-cp312-win32.whl", hash = "sha256:690b20e3388a7ec98e899fd54c924e50ba6693874aa65ef9cb53de7f7de9d64a"}, {file = "lxml-6.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:310b719b695b3dd442cdfbbe64936b2f2e231bb91d998e99e6f0daf991a3eba3"}, @@ -1417,12 +1413,10 @@ files = [ {file = "lxml-6.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d18a25b19ca7307045581b18b3ec9ead2b1db5ccd8719c291f0cd0a5cec6cb81"}, {file = "lxml-6.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d4f0c66df4386b75d2ab1e20a489f30dc7fd9a06a896d64980541506086be1f1"}, {file = "lxml-6.0.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9f4b481b6cc3a897adb4279216695150bbe7a44c03daba3c894f49d2037e0a24"}, - {file = "lxml-6.0.0-cp313-cp313-manylinux_2_27_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8a78d6c9168f5bcb20971bf3329c2b83078611fbe1f807baadc64afc70523b3a"}, {file = "lxml-6.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ae06fbab4f1bb7db4f7c8ca9897dc8db4447d1a2b9bee78474ad403437bcc29"}, {file = "lxml-6.0.0-cp313-cp313-manylinux_2_31_armv7l.whl", hash = "sha256:1fa377b827ca2023244a06554c6e7dc6828a10aaf74ca41965c5d8a4925aebb4"}, {file = "lxml-6.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:1676b56d48048a62ef77a250428d1f31f610763636e0784ba67a9740823988ca"}, {file = "lxml-6.0.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:0e32698462aacc5c1cf6bdfebc9c781821b7e74c79f13e5ffc8bfe27c42b1abf"}, - {file = "lxml-6.0.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:4d6036c3a296707357efb375cfc24bb64cd955b9ec731abf11ebb1e40063949f"}, {file = "lxml-6.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:7488a43033c958637b1a08cddc9188eb06d3ad36582cebc7d4815980b47e27ef"}, {file = "lxml-6.0.0-cp313-cp313-win32.whl", hash = "sha256:5fcd7d3b1d8ecb91445bd71b9c88bdbeae528fefee4f379895becfc72298d181"}, {file = "lxml-6.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:2f34687222b78fff795feeb799a7d44eca2477c3d9d3a46ce17d51a4f383e32e"}, @@ -1782,8 +1776,6 @@ groups = ["main"] files = [ {file = "pillow-11.3.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:1b9c17fd4ace828b3003dfd1e30bff24863e0eb59b535e8f80194d9cc7ecf860"}, {file = "pillow-11.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:65dc69160114cdd0ca0f35cb434633c75e8e7fad4cf855177a05bf38678f73ad"}, - {file = "pillow-11.3.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7107195ddc914f656c7fc8e4a5e1c25f32e9236ea3ea860f257b0436011fddd0"}, - {file = "pillow-11.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:cc3e831b563b3114baac7ec2ee86819eb03caa1a2cef0b481a5675b59c4fe23b"}, {file = "pillow-11.3.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f1f182ebd2303acf8c380a54f615ec883322593320a9b00438eb842c1f37ae50"}, {file = "pillow-11.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4445fa62e15936a028672fd48c4c11a66d641d2c05726c7ec1f8ba6a572036ae"}, {file = "pillow-11.3.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:71f511f6b3b91dd543282477be45a033e4845a40278fa8dcdbfdb07109bf18f9"}, @@ -1793,8 +1785,6 @@ files = [ {file = "pillow-11.3.0-cp310-cp310-win_arm64.whl", hash = "sha256:819931d25e57b513242859ce1876c58c59dc31587847bf74cfe06b2e0cb22d2f"}, {file = "pillow-11.3.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:1cd110edf822773368b396281a2293aeb91c90a2db00d78ea43e7e861631b722"}, {file = "pillow-11.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9c412fddd1b77a75aa904615ebaa6001f169b26fd467b4be93aded278266b288"}, - {file = "pillow-11.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7d1aa4de119a0ecac0a34a9c8bde33f34022e2e8f99104e47a3ca392fd60e37d"}, - {file = "pillow-11.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:91da1d88226663594e3f6b4b8c3c8d85bd504117d043740a8e0ec449087cc494"}, {file = "pillow-11.3.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:643f189248837533073c405ec2f0bb250ba54598cf80e8c1e043381a60632f58"}, {file = "pillow-11.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:106064daa23a745510dabce1d84f29137a37224831d88eb4ce94bb187b1d7e5f"}, {file = "pillow-11.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cd8ff254faf15591e724dc7c4ddb6bf4793efcbe13802a4ae3e863cd300b493e"}, @@ -1804,8 +1794,6 @@ files = [ {file = "pillow-11.3.0-cp311-cp311-win_arm64.whl", hash = "sha256:30807c931ff7c095620fe04448e2c2fc673fcbb1ffe2a7da3fb39613489b1ddd"}, {file = "pillow-11.3.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fdae223722da47b024b867c1ea0be64e0df702c5e0a60e27daad39bf960dd1e4"}, {file = "pillow-11.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:921bd305b10e82b4d1f5e802b6850677f965d8394203d182f078873851dada69"}, - {file = "pillow-11.3.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:eb76541cba2f958032d79d143b98a3a6b3ea87f0959bbe256c0b5e416599fd5d"}, - {file = "pillow-11.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:67172f2944ebba3d4a7b54f2e95c786a3a50c21b88456329314caaa28cda70f6"}, {file = "pillow-11.3.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:97f07ed9f56a3b9b5f49d3661dc9607484e85c67e27f3e8be2c7d28ca032fec7"}, {file = "pillow-11.3.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:676b2815362456b5b3216b4fd5bd89d362100dc6f4945154ff172e206a22c024"}, {file = "pillow-11.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3e184b2f26ff146363dd07bde8b711833d7b0202e27d13540bfe2e35a323a809"}, @@ -1818,8 +1806,6 @@ files = [ {file = "pillow-11.3.0-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:7859a4cc7c9295f5838015d8cc0a9c215b77e43d07a25e460f35cf516df8626f"}, {file = "pillow-11.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec1ee50470b0d050984394423d96325b744d55c701a439d2bd66089bff963d3c"}, {file = "pillow-11.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7db51d222548ccfd274e4572fdbf3e810a5e66b00608862f947b163e613b67dd"}, - {file = "pillow-11.3.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:2d6fcc902a24ac74495df63faad1884282239265c6839a0a6416d33faedfae7e"}, - {file = "pillow-11.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f0f5d8f4a08090c6d6d578351a2b91acf519a54986c055af27e7a93feae6d3f1"}, {file = "pillow-11.3.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c37d8ba9411d6003bba9e518db0db0c58a680ab9fe5179f040b0463644bc9805"}, {file = "pillow-11.3.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:13f87d581e71d9189ab21fe0efb5a23e9f28552d5be6979e84001d3b8505abe8"}, {file = "pillow-11.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:023f6d2d11784a465f09fd09a34b150ea4672e85fb3d05931d89f373ab14abb2"}, @@ -1829,8 +1815,6 @@ files = [ {file = "pillow-11.3.0-cp313-cp313-win_arm64.whl", hash = "sha256:1904e1264881f682f02b7f8167935cce37bc97db457f8e7849dc3a6a52b99580"}, {file = "pillow-11.3.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:4c834a3921375c48ee6b9624061076bc0a32a60b5532b322cc0ea64e639dd50e"}, {file = "pillow-11.3.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:5e05688ccef30ea69b9317a9ead994b93975104a677a36a8ed8106be9260aa6d"}, - {file = "pillow-11.3.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1019b04af07fc0163e2810167918cb5add8d74674b6267616021ab558dc98ced"}, - {file = "pillow-11.3.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f944255db153ebb2b19c51fe85dd99ef0ce494123f21b9db4877ffdfc5590c7c"}, {file = "pillow-11.3.0-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1f85acb69adf2aaee8b7da124efebbdb959a104db34d3a2cb0f3793dbae422a8"}, {file = "pillow-11.3.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:05f6ecbeff5005399bb48d198f098a9b4b6bdf27b8487c7f38ca16eeb070cd59"}, {file = "pillow-11.3.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:a7bc6e6fd0395bc052f16b1a8670859964dbd7003bd0af2ff08342eb6e442cfe"}, @@ -1840,8 +1824,6 @@ files = [ {file = "pillow-11.3.0-cp313-cp313t-win_arm64.whl", hash = "sha256:8797edc41f3e8536ae4b10897ee2f637235c94f27404cac7297f7b607dd0716e"}, {file = "pillow-11.3.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:d9da3df5f9ea2a89b81bb6087177fb1f4d1c7146d583a3fe5c672c0d94e55e12"}, {file = "pillow-11.3.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:0b275ff9b04df7b640c59ec5a3cb113eefd3795a8df80bac69646ef699c6981a"}, - {file = "pillow-11.3.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0743841cabd3dba6a83f38a92672cccbd69af56e3e91777b0ee7f4dba4385632"}, - {file = "pillow-11.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:2465a69cf967b8b49ee1b96d76718cd98c4e925414ead59fdf75cf0fd07df673"}, {file = "pillow-11.3.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:41742638139424703b4d01665b807c6468e23e699e8e90cffefe291c5832b027"}, {file = "pillow-11.3.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:93efb0b4de7e340d99057415c749175e24c8864302369e05914682ba642e5d77"}, {file = "pillow-11.3.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7966e38dcd0fa11ca390aed7c6f20454443581d758242023cf36fcb319b1a874"}, @@ -1851,8 +1833,6 @@ files = [ {file = "pillow-11.3.0-cp314-cp314-win_arm64.whl", hash = "sha256:155658efb5e044669c08896c0c44231c5e9abcaadbc5cd3648df2f7c0b96b9a6"}, {file = "pillow-11.3.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:59a03cdf019efbfeeed910bf79c7c93255c3d54bc45898ac2a4140071b02b4ae"}, {file = "pillow-11.3.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f8a5827f84d973d8636e9dc5764af4f0cf2318d26744b3d902931701b0d46653"}, - {file = "pillow-11.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ee92f2fd10f4adc4b43d07ec5e779932b4eb3dbfbc34790ada5a6669bc095aa6"}, - {file = "pillow-11.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c96d333dcf42d01f47b37e0979b6bd73ec91eae18614864622d9b87bbd5bbf36"}, {file = "pillow-11.3.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4c96f993ab8c98460cd0c001447bff6194403e8b1d7e149ade5f00594918128b"}, {file = "pillow-11.3.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:41342b64afeba938edb034d122b2dda5db2139b9a4af999729ba8818e0056477"}, {file = "pillow-11.3.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:068d9c39a2d1b358eb9f245ce7ab1b5c3246c7c8c7d9ba58cfa5b43146c06e50"}, @@ -1862,8 +1842,6 @@ files = [ {file = "pillow-11.3.0-cp314-cp314t-win_arm64.whl", hash = "sha256:79ea0d14d3ebad43ec77ad5272e6ff9bba5b679ef73375ea760261207fa8e0aa"}, {file = "pillow-11.3.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:48d254f8a4c776de343051023eb61ffe818299eeac478da55227d96e241de53f"}, {file = "pillow-11.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7aee118e30a4cf54fdd873bd3a29de51e29105ab11f9aad8c32123f58c8f8081"}, - {file = "pillow-11.3.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:23cff760a9049c502721bdb743a7cb3e03365fafcdfc2ef9784610714166e5a4"}, - {file = "pillow-11.3.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:6359a3bc43f57d5b375d1ad54a0074318a0844d11b76abccf478c37c986d3cfc"}, {file = "pillow-11.3.0-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:092c80c76635f5ecb10f3f83d76716165c96f5229addbd1ec2bdbbda7d496e06"}, {file = "pillow-11.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cadc9e0ea0a2431124cde7e1697106471fc4c1da01530e679b2391c37d3fbb3a"}, {file = "pillow-11.3.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:6a418691000f2a418c9135a7cf0d797c1bb7d9a485e61fe8e7722845b95ef978"}, @@ -1873,15 +1851,11 @@ files = [ {file = "pillow-11.3.0-cp39-cp39-win_arm64.whl", hash = "sha256:6abdbfd3aea42be05702a8dd98832329c167ee84400a1d1f61ab11437f1717eb"}, {file = "pillow-11.3.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:3cee80663f29e3843b68199b9d6f4f54bd1d4a6b59bdd91bceefc51238bcb967"}, {file = "pillow-11.3.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:b5f56c3f344f2ccaf0dd875d3e180f631dc60a51b314295a3e681fe8cf851fbe"}, - {file = "pillow-11.3.0-pp310-pypy310_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e67d793d180c9df62f1f40aee3accca4829d3794c95098887edc18af4b8b780c"}, - {file = "pillow-11.3.0-pp310-pypy310_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d000f46e2917c705e9fb93a3606ee4a819d1e3aa7a9b442f6444f07e77cf5e25"}, {file = "pillow-11.3.0-pp310-pypy310_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:527b37216b6ac3a12d7838dc3bd75208ec57c1c6d11ef01902266a5a0c14fc27"}, {file = "pillow-11.3.0-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:be5463ac478b623b9dd3937afd7fb7ab3d79dd290a28e2b6df292dc75063eb8a"}, {file = "pillow-11.3.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:8dc70ca24c110503e16918a658b869019126ecfe03109b754c402daff12b3d9f"}, {file = "pillow-11.3.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:7c8ec7a017ad1bd562f93dbd8505763e688d388cde6e4a010ae1486916e713e6"}, {file = "pillow-11.3.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:9ab6ae226de48019caa8074894544af5b53a117ccb9d3b3dcb2871464c829438"}, - {file = "pillow-11.3.0-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:fe27fb049cdcca11f11a7bfda64043c37b30e6b91f10cb5bab275806c32f6ab3"}, - {file = "pillow-11.3.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:465b9e8844e3c3519a983d58b80be3f668e2a7a5db97f2784e7079fbc9f9822c"}, {file = "pillow-11.3.0-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5418b53c0d59b3824d05e029669efa023bbef0f3e92e75ec8428f3799487f361"}, {file = "pillow-11.3.0-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:504b6f59505f08ae014f724b6207ff6222662aab5cc9542577fb084ed0676ac7"}, {file = "pillow-11.3.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:c84d689db21a1c397d001aa08241044aa2069e7587b398c8cc63020390b1c1b8"}, @@ -2717,31 +2691,31 @@ test = ["hypothesis (>=6.22.0,<6.108.7)", "pytest (>=7.0.0)", "pytest-xdist (>=2 [[package]] name = "ruff" -version = "0.13.0" +version = "0.13.3" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" groups = ["dev"] files = [ - {file = "ruff-0.13.0-py3-none-linux_armv6l.whl", hash = "sha256:137f3d65d58ee828ae136a12d1dc33d992773d8f7644bc6b82714570f31b2004"}, - {file = "ruff-0.13.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:21ae48151b66e71fd111b7d79f9ad358814ed58c339631450c66a4be33cc28b9"}, - {file = "ruff-0.13.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:64de45f4ca5441209e41742d527944635a05a6e7c05798904f39c85bafa819e3"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2b2c653ae9b9d46e0ef62fc6fbf5b979bda20a0b1d2b22f8f7eb0cde9f4963b8"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4cec632534332062bc9eb5884a267b689085a1afea9801bf94e3ba7498a2d207"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dcd628101d9f7d122e120ac7c17e0a0f468b19bc925501dbe03c1cb7f5415b24"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:afe37db8e1466acb173bb2a39ca92df00570e0fd7c94c72d87b51b21bb63efea"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0f96a8d90bb258d7d3358b372905fe7333aaacf6c39e2408b9f8ba181f4b6ef2"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94b5e3d883e4f924c5298e3f2ee0f3085819c14f68d1e5b6715597681433f153"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:03447f3d18479df3d24917a92d768a89f873a7181a064858ea90a804a7538991"}, - {file = "ruff-0.13.0-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:fbc6b1934eb1c0033da427c805e27d164bb713f8e273a024a7e86176d7f462cf"}, - {file = "ruff-0.13.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:a8ab6a3e03665d39d4a25ee199d207a488724f022db0e1fe4002968abdb8001b"}, - {file = "ruff-0.13.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d2a5c62f8ccc6dd2fe259917482de7275cecc86141ee10432727c4816235bc41"}, - {file = "ruff-0.13.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b7b85ca27aeeb1ab421bc787009831cffe6048faae08ad80867edab9f2760945"}, - {file = "ruff-0.13.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:79ea0c44a3032af768cabfd9616e44c24303af49d633b43e3a5096e009ebe823"}, - {file = "ruff-0.13.0-py3-none-win32.whl", hash = "sha256:4e473e8f0e6a04e4113f2e1de12a5039579892329ecc49958424e5568ef4f768"}, - {file = "ruff-0.13.0-py3-none-win_amd64.whl", hash = "sha256:48e5c25c7a3713eea9ce755995767f4dcd1b0b9599b638b12946e892123d1efb"}, - {file = "ruff-0.13.0-py3-none-win_arm64.whl", hash = "sha256:ab80525317b1e1d38614addec8ac954f1b3e662de9d59114ecbf771d00cf613e"}, - {file = "ruff-0.13.0.tar.gz", hash = "sha256:5b4b1ee7eb35afae128ab94459b13b2baaed282b1fb0f472a73c82c996c8ae60"}, + {file = "ruff-0.13.3-py3-none-linux_armv6l.whl", hash = "sha256:311860a4c5e19189c89d035638f500c1e191d283d0cc2f1600c8c80d6dcd430c"}, + {file = "ruff-0.13.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:2bdad6512fb666b40fcadb65e33add2b040fc18a24997d2e47fee7d66f7fcae2"}, + {file = "ruff-0.13.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:fc6fa4637284708d6ed4e5e970d52fc3b76a557d7b4e85a53013d9d201d93286"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c9e6469864f94a98f412f20ea143d547e4c652f45e44f369d7b74ee78185838"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5bf62b705f319476c78891e0e97e965b21db468b3c999086de8ffb0d40fd2822"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:78cc1abed87ce40cb07ee0667ce99dbc766c9f519eabfd948ed87295d8737c60"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:4fb75e7c402d504f7a9a259e0442b96403fa4a7310ffe3588d11d7e170d2b1e3"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:17b951f9d9afb39330b2bdd2dd144ce1c1335881c277837ac1b50bfd99985ed3"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6052f8088728898e0a449f0dde8fafc7ed47e4d878168b211977e3e7e854f662"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc742c50f4ba72ce2a3be362bd359aef7d0d302bf7637a6f942eaa763bd292af"}, + {file = "ruff-0.13.3-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e5640349493b378431637019366bbd73c927e515c9c1babfea3e932f5e68e1d"}, + {file = "ruff-0.13.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:6b139f638a80eae7073c691a5dd8d581e0ba319540be97c343d60fb12949c8d0"}, + {file = "ruff-0.13.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:6b547def0a40054825de7cfa341039ebdfa51f3d4bfa6a0772940ed351d2746c"}, + {file = "ruff-0.13.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9cc48a3564423915c93573f1981d57d101e617839bef38504f85f3677b3a0a3e"}, + {file = "ruff-0.13.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1a993b17ec03719c502881cb2d5f91771e8742f2ca6de740034433a97c561989"}, + {file = "ruff-0.13.3-py3-none-win32.whl", hash = "sha256:f14e0d1fe6460f07814d03c6e32e815bff411505178a1f539a38f6097d3e8ee3"}, + {file = "ruff-0.13.3-py3-none-win_amd64.whl", hash = "sha256:621e2e5812b691d4f244638d693e640f188bacbb9bc793ddd46837cea0503dd2"}, + {file = "ruff-0.13.3-py3-none-win_arm64.whl", hash = "sha256:9e9e9d699841eaf4c2c798fa783df2fabc680b72059a02ca0ed81c460bc58330"}, + {file = "ruff-0.13.3.tar.gz", hash = "sha256:5b0ba0db740eefdfbcce4299f49e9eaefc643d4d007749d77d047c2bab19908e"}, ] [[package]] @@ -3090,4 +3064,4 @@ didcommv2 = ["didcomm-messaging"] [metadata] lock-version = "2.1" python-versions = "^3.12" -content-hash = "f210116cb95106b7b918f8ac2c06ff3585a14e8fcd479dea2426966cdac4fd86" +content-hash = "35af162401dda6b8a1baae49d2cf0bee2ceed1885e29a96888f3139cb35be624" diff --git a/pyproject.toml b/pyproject.toml index 2157194bf2..bf310ed536 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ didcomm-messaging = { version = "^0.1.1a0", optional = true } [tool.poetry.group.dev.dependencies] # Sync with version in .pre-commit-config.yaml and .github/workflows/format.yml -ruff = ">=0.12.10,<0.14.0" +ruff = "~=0.13.3" pre-commit = ">=4.1,<4.4" @@ -94,26 +94,33 @@ didcommv2 = ["didcomm-messaging"] aca-py = "acapy_agent.__main__:script_main" [tool.ruff] -lint.select = ["B006", "C", "D", "E", "F"] +lint.select = [ + "B006", # Check for uses of mutable objects as function arguments + "C90", # mccabe (code complexity) + "D", # pydocstyle (docstring style) + "E", # pycodestyle (style errors) + "F", # pyflakes (detect invalid Python code) + "I", # isort (import sorting) + # To be added later: + # "ANN", # flake8-annotations (type annotation checks) + # "ASYNC", # flake8-async (detect async code errors) + # "B", # flake8-bugbear (detect likely bugs) + # "N", # pep8-naming (naming conventions) + # "PL", # pylint (rich code analysis) + # "RUF", # ruff-specific rules + # "UP", # pyupgrade (upgrade syntax) + # "W", # pycodestyle warnings (style warnings) +] lint.ignore = [ - # Google Python Doc Style - "D203", - "D204", - "D213", - "D215", - "D400", - "D401", - "D404", - "D406", - "D407", - "D408", - "D409", - "D413", - "D202", # Allow blank line after docstring - "D104", # Don't require docstring in public package - # Things that we should fix, but are too much work right now - "C901", + # Comments describe the rule being ignored + "D104", # Require docstring in public package + "D203", # Use a blank line to separate the docstring from the class definition + "D213", # Multi-line docstring should start at the second line + "D400", # First line of docstring should end with a period + "D401", # First line of docstring should be in imperative mood + # Should be fixed later: + "C901", # Method is too complex ] include = ["acapy_agent/**/*.py"]