diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 1f7584e464..9e46bea486 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -17,5 +17,5 @@ jobs: - name: Ruff Format and Lint Check uses: chartboost/ruff-action@v1 with: - version: 0.8.0 + version: 0.9.1 args: "format --check" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2cc9bec01f..3210d931ae 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.8.1 + rev: v0.9.1 hooks: # Run the linter - id: ruff diff --git a/acapy_agent/anoncreds/issuer.py b/acapy_agent/anoncreds/issuer.py index 6dc3fababa..3d6948cf0e 100644 --- a/acapy_agent/anoncreds/issuer.py +++ b/acapy_agent/anoncreds/issuer.py @@ -196,7 +196,7 @@ async def create_and_register_schema( ) if schemas: raise AnonCredsSchemaAlreadyExists( - f"Schema with {name}: {version} " f"already exists for {issuer_id}", + f"Schema with {name}: {version} already exists for {issuer_id}", schemas[0].name, AnonCredsSchema.deserialize(schemas[0].value_json), ) diff --git a/acapy_agent/anoncreds/revocation.py b/acapy_agent/anoncreds/revocation.py index e9cc88293f..ad96dfe4cc 100644 --- a/acapy_agent/anoncreds/revocation.py +++ b/acapy_agent/anoncreds/revocation.py @@ -345,8 +345,7 @@ async def set_active_registry(self, rev_reg_def_id: str): ) if not entry: raise AnonCredsRevocationError( - f"{CATEGORY_REV_REG_DEF} with id " - f"{rev_reg_def_id} could not be found" + f"{CATEGORY_REV_REG_DEF} with id {rev_reg_def_id} could not be found" ) if entry.tags["active"] == json.dumps(True): diff --git a/acapy_agent/anoncreds/verifier.py b/acapy_agent/anoncreds/verifier.py index 849c44ab5b..daeaeef7ce 100644 --- a/acapy_agent/anoncreds/verifier.py +++ b/acapy_agent/anoncreds/verifier.py @@ -205,9 +205,7 @@ async def check_timestamps( ) elif uuid in unrevealed_attrs: # nothing to do, attribute value is not revealed - msgs.append( - f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}" - ) + msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}") elif uuid not in self_attested: raise ValueError( f"Presentation attributes mismatch requested attribute {uuid}" @@ -236,8 +234,7 @@ async def check_timestamps( < non_revoc_intervals[uuid].get("to", now) ): msgs.append( - f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::" - f"{uuid}" + f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}" ) LOGGER.warning( f"Timestamp {timestamp} from ledger for item" @@ -266,7 +263,7 @@ async def check_timestamps( < non_revoc_intervals[uuid].get("to", now) ): msgs.append( - f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::" f"{uuid}" + f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}" ) LOGGER.warning( f"Best-effort timestamp {timestamp} " @@ -333,9 +330,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list: elif uuid in unrevealed_attrs: # unrevealed attribute, nothing to do pres_req_attr_spec = {} - msgs.append( - f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}" - ) + msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}") elif uuid in self_attested: if not req_attr.get("restrictions"): continue diff --git a/acapy_agent/config/argparse.py b/acapy_agent/config/argparse.py index 87a67aeaf7..bf911a2a5a 100644 --- a/acapy_agent/config/argparse.py +++ b/acapy_agent/config/argparse.py @@ -269,8 +269,7 @@ def add_arguments(self, parser: ArgumentParser): action="store_true", env_var="ACAPY_DEBUG_CREDENTIALS", help=( - "Enable additional logging around credential exchanges. " - "Default: false." + "Enable additional logging around credential exchanges. Default: false." ), ) parser.add_argument( @@ -278,15 +277,14 @@ def add_arguments(self, parser: ArgumentParser): action="store_true", env_var="ACAPY_DEBUG_PRESENTATIONS", help=( - "Enable additional logging around presentation exchanges. " - "Default: false." + "Enable additional logging around presentation exchanges. Default: false." ), ) parser.add_argument( "--debug-webhooks", action="store_true", env_var="ACAPY_DEBUG_WEBHOOKS", - help=("Emit protocol state object as webhook. " "Default: false."), + help=("Emit protocol state object as webhook. Default: false."), ) parser.add_argument( "--invite", @@ -416,8 +414,7 @@ def add_arguments(self, parser: ArgumentParser): action="store_true", env_var="ACAPY_AUTO_STORE_CREDENTIAL", help=( - "Automatically store an issued credential upon receipt. " - "Default: false." + "Automatically store an issued credential upon receipt. Default: false." ), ) parser.add_argument( @@ -425,8 +422,7 @@ def add_arguments(self, parser: ArgumentParser): action="store_true", env_var="ACAPY_AUTO_VERIFY_PRESENTATION", help=( - "Automatically verify a presentation when it is received. " - "Default: false." + "Automatically verify a presentation when it is received. Default: false." ), ) diff --git a/acapy_agent/config/ledger.py b/acapy_agent/config/ledger.py index 7d7acb1e7e..e8a4791e38 100644 --- a/acapy_agent/config/ledger.py +++ b/acapy_agent/config/ledger.py @@ -220,7 +220,7 @@ async def select_aml_tty(taa_info, provision: bool = False) -> Optional[str]: num_mechanisms = {} for idx, opt in enumerate(found): num_mechanisms[str(idx + 1)] = opt - opts.append(f" {idx+1}. {allow_opts[opt]}") + opts.append(f" {idx + 1}. {allow_opts[opt]}") opts.append(" X. Skip the transaction author agreement") opts_text = "\nPlease select an option:\n" + "\n".join(opts) + "\n[1]> " diff --git a/acapy_agent/connections/base_manager.py b/acapy_agent/connections/base_manager.py index fedd0b7242..549a394a19 100644 --- a/acapy_agent/connections/base_manager.py +++ b/acapy_agent/connections/base_manager.py @@ -1026,8 +1026,7 @@ async def resolve_inbound_connection( receipt.recipient_did_public = True except InjectionError: self._logger.warning( - "Cannot resolve recipient verkey, no wallet defined by " - "context: %s", + "Cannot resolve recipient verkey, no wallet defined by context: %s", receipt.recipient_verkey, ) except WalletNotFoundError: diff --git a/acapy_agent/indy/models/tests/test_pres_preview.py b/acapy_agent/indy/models/tests/test_pres_preview.py index b616639845..2e7570a85f 100644 --- a/acapy_agent/indy/models/tests/test_pres_preview.py +++ b/acapy_agent/indy/models/tests/test_pres_preview.py @@ -88,7 +88,7 @@ "name": "player", "restrictions": [ {{ - "cred_def_id": "{CD_ID['score']}" + "cred_def_id": "{CD_ID["score"]}" }} ] }}, @@ -96,7 +96,7 @@ "name": "screenCapture", "restrictions": [ {{ - "cred_def_id": "{CD_ID['score']}" + "cred_def_id": "{CD_ID["score"]}" }} ] }} @@ -108,7 +108,7 @@ "p_value": 1000000, "restrictions": [ {{ - "cred_def_id": "{CD_ID['score']}" + "cred_def_id": "{CD_ID["score"]}" }} ] }} @@ -125,7 +125,7 @@ "names": ["player", "screenCapture"], "restrictions": [ {{ - "cred_def_id": "{CD_ID['score']}" + "cred_def_id": "{CD_ID["score"]}" }} ] }}, @@ -133,7 +133,7 @@ "names": ["member", "since"], "restrictions": [ {{ - "cred_def_id": "{CD_ID['membership']}" + "cred_def_id": "{CD_ID["membership"]}" }} ] }} diff --git a/acapy_agent/indy/verifier.py b/acapy_agent/indy/verifier.py index 2a2bb0f243..3bb790593f 100644 --- a/acapy_agent/indy/verifier.py +++ b/acapy_agent/indy/verifier.py @@ -211,9 +211,7 @@ async def check_timestamps( ) elif uuid in unrevealed_attrs: # nothing to do, attribute value is not revealed - msgs.append( - f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}" - ) + msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}") elif uuid not in self_attested: raise ValueError( f"Presentation attributes mismatch requested attribute {uuid}" @@ -242,8 +240,7 @@ async def check_timestamps( < non_revoc_intervals[uuid].get("to", now) ): msgs.append( - f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::" - f"{uuid}" + f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}" ) LOGGER.warning( f"Timestamp {timestamp} from ledger for item" @@ -272,7 +269,7 @@ async def check_timestamps( < non_revoc_intervals[uuid].get("to", now) ): msgs.append( - f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::" f"{uuid}" + f"{PresVerifyMsg.TSTMP_OUT_NON_REVOC_INTRVAL.value}::{uuid}" ) LOGGER.warning( f"Best-effort timestamp {timestamp} " @@ -339,9 +336,7 @@ async def pre_verify(self, pres_req: dict, pres: dict) -> list: elif uuid in unrevealed_attrs: # unrevealed attribute, nothing to do pres_req_attr_spec = {} - msgs.append( - f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::" f"{uuid}" - ) + msgs.append(f"{PresVerifyMsg.CT_UNREVEALED_ATTRIBUTES.value}::{uuid}") elif uuid in self_attested: if not req_attr.get("restrictions"): continue diff --git a/acapy_agent/ledger/base.py b/acapy_agent/ledger/base.py index ffafe3bb31..576d591a0a 100644 --- a/acapy_agent/ledger/base.py +++ b/acapy_agent/ledger/base.py @@ -700,8 +700,7 @@ async def send_schema_anoncreds( ) if schema_info: LOGGER.warning( - "Schema already exists on ledger. Returning details." - " Error: %s", + "Schema already exists on ledger. Returning details. Error: %s", e, ) raise LedgerObjectAlreadyExistsError( diff --git a/acapy_agent/messaging/decorators/signature_decorator.py b/acapy_agent/messaging/decorators/signature_decorator.py index ed7a217611..4d980d2f22 100644 --- a/acapy_agent/messaging/decorators/signature_decorator.py +++ b/acapy_agent/messaging/decorators/signature_decorator.py @@ -120,8 +120,8 @@ def __str__(self): """Get a string representation of this class.""" return ( f"{self.__class__.__name__}" - + f"(signature_type='{self.signature_type,}', " - + f"signature='{self.signature,}', " + + f"(signature_type='{(self.signature_type,)}', " + + f"signature='{(self.signature,)}', " + f"sig_data='{self.sig_data}', signer='{self.signer}')" ) diff --git a/acapy_agent/messaging/jsonld/create_verify_data.py b/acapy_agent/messaging/jsonld/create_verify_data.py index a2ed01712b..1ec1ef7502 100644 --- a/acapy_agent/messaging/jsonld/create_verify_data.py +++ b/acapy_agent/messaging/jsonld/create_verify_data.py @@ -94,7 +94,7 @@ def create_verify_data(data, signature_options, document_loader=None): ) dropped = set(data.keys()) - set(for_diff.keys()) raise DroppedAttributeError( - f"{dropped} attributes dropped. " "Provide definitions in context to correct." + f"{dropped} attributes dropped. Provide definitions in context to correct." ) # Check proof for dropped attributes attr = [ diff --git a/acapy_agent/messaging/jsonld/tests/__init__.py b/acapy_agent/messaging/jsonld/tests/__init__.py index caed66d51c..c231a33645 100644 --- a/acapy_agent/messaging/jsonld/tests/__init__.py +++ b/acapy_agent/messaging/jsonld/tests/__init__.py @@ -13,7 +13,7 @@ "issuer": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), "issuanceDate": "2020-03-10T04:24:12.164Z", "credentialSubject": { - "id": ("did:key:" "z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), + "id": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), "degree": { "type": "BachelorDegree", "name": "Bachelor of Science and Arts", @@ -244,7 +244,7 @@ "issuer": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), "issuanceDate": "2020-03-10T04:24:12.164Z", "credentialSubject": { - "id": ("did:key:" "z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), + "id": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), "degree": { "type": "BachelorDegree", "name": "Bachelor of Science and Arts", @@ -365,7 +365,7 @@ "issuer": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), "issuanceDate": "2020-03-10T04:24:12.164Z", "credentialSubject": { - "id": ("did:key:" "z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), + "id": ("did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd"), "degree": { "type": "BachelorDegree", "name": "Bachelor of Science and Arts", diff --git a/acapy_agent/messaging/valid.py b/acapy_agent/messaging/valid.py index 879a0bd255..cb706deab0 100644 --- a/acapy_agent/messaging/valid.py +++ b/acapy_agent/messaging/valid.py @@ -223,9 +223,7 @@ class JSONWebToken(Regexp): """Validate JSON Web Token.""" EXAMPLE = ( - "eyJhbGciOiJFZERTQSJ9." - "eyJhIjogIjAifQ." - "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk" + "eyJhbGciOiJFZERTQSJ9.eyJhIjogIjAifQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk" ) PATTERN = r"^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]+$" @@ -926,7 +924,7 @@ def __call__(self, value): uri_validator(subject["id"]) except ValidationError: raise ValidationError( - f'credential subject id {subject["id"]} must be URI' + f"credential subject id {subject['id']} must be URI" ) from None return value diff --git a/acapy_agent/multitenant/admin/routes.py b/acapy_agent/multitenant/admin/routes.py index 8ebea184a7..c89b302914 100644 --- a/acapy_agent/multitenant/admin/routes.py +++ b/acapy_agent/multitenant/admin/routes.py @@ -314,8 +314,7 @@ class RemoveWalletRequestSchema(OpenAPISchema): wallet_key = fields.Str( metadata={ "description": ( - "Master key used for key derivation. Only required for" - " unmanaged wallets." + "Master key used for key derivation. Only required for unmanaged wallets." ), "example": "MySecretKey123", } @@ -328,8 +327,7 @@ class CreateWalletTokenRequestSchema(OpenAPISchema): wallet_key = fields.Str( metadata={ "description": ( - "Master key used for key derivation. Only required for" - " unmanaged wallets." + "Master key used for key derivation. Only required for unmanaged wallets." ), "example": "MySecretKey123", } diff --git a/acapy_agent/protocols/connections/v1_0/manager.py b/acapy_agent/protocols/connections/v1_0/manager.py index 9d7c0bf86d..3767c76998 100644 --- a/acapy_agent/protocols/connections/v1_0/manager.py +++ b/acapy_agent/protocols/connections/v1_0/manager.py @@ -559,7 +559,7 @@ async def receive_request( if not connection: if not self.profile.settings.get("requests_through_public_did"): raise ConnectionManagerError( - "Unsolicited connection requests to " "public DID is not enabled" + "Unsolicited connection requests to public DID is not enabled" ) connection = ConnRecord() connection.invitation_key = connection_key diff --git a/acapy_agent/protocols/connections/v1_0/messages/connection_response.py b/acapy_agent/protocols/connections/v1_0/messages/connection_response.py index 8bf11eae21..aeb9512314 100644 --- a/acapy_agent/protocols/connections/v1_0/messages/connection_response.py +++ b/acapy_agent/protocols/connections/v1_0/messages/connection_response.py @@ -9,8 +9,7 @@ from ..models.connection_detail import ConnectionDetail, ConnectionDetailSchema HANDLER_CLASS = ( - f"{PROTOCOL_PACKAGE}.handlers." - "connection_response_handler.ConnectionResponseHandler" + f"{PROTOCOL_PACKAGE}.handlers.connection_response_handler.ConnectionResponseHandler" ) diff --git a/acapy_agent/protocols/coordinate_mediation/v1_0/message_types.py b/acapy_agent/protocols/coordinate_mediation/v1_0/message_types.py index c1b0596d7e..869116665f 100644 --- a/acapy_agent/protocols/coordinate_mediation/v1_0/message_types.py +++ b/acapy_agent/protocols/coordinate_mediation/v1_0/message_types.py @@ -29,8 +29,7 @@ KEYLIST_QUERY: f"{PROTOCOL_PACKAGE}.messages.keylist_query.KeylistQuery", KEYLIST_UPDATE: f"{PROTOCOL_PACKAGE}.messages.keylist_update.KeylistUpdate", KEYLIST_UPDATE_RESPONSE: ( - f"{PROTOCOL_PACKAGE}." - "messages.keylist_update_response.KeylistUpdateResponse" + f"{PROTOCOL_PACKAGE}.messages.keylist_update_response.KeylistUpdateResponse" ), MEDIATE_DENY: f"{PROTOCOL_PACKAGE}.messages.mediate_deny.MediationDeny", MEDIATE_GRANT: f"{PROTOCOL_PACKAGE}.messages.mediate_grant.MediationGrant", 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 f264b26e99..747b4a9f11 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 @@ -9,7 +9,7 @@ from ..message_types import PROBLEM_REPORT, PROTOCOL_PACKAGE HANDLER_CLASS = ( - f"{PROTOCOL_PACKAGE}.handlers" ".problem_report_handler.CMProblemReportHandler" + f"{PROTOCOL_PACKAGE}.handlers.problem_report_handler.CMProblemReportHandler" ) LOGGER = logging.getLogger(__name__) diff --git a/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_request.py b/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_request.py index 3cd83db2d7..ddfd731e13 100644 --- a/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_request.py +++ b/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_request.py @@ -82,8 +82,7 @@ def test_type(self): assert self.request._type == DIDCommPrefix.qualify_current(DIDX_REQUEST) @mock.patch( - "acapy_agent.protocols.didexchange.v1_0.messages." - "request.DIDXRequestSchema.load" + "acapy_agent.protocols.didexchange.v1_0.messages.request.DIDXRequestSchema.load" ) def test_deserialize(self, mock_request_schema_load): """ @@ -97,8 +96,7 @@ def test_deserialize(self, mock_request_schema_load): assert request is mock_request_schema_load.return_value @mock.patch( - "acapy_agent.protocols.didexchange.v1_0.messages." - "request.DIDXRequestSchema.dump" + "acapy_agent.protocols.didexchange.v1_0.messages.request.DIDXRequestSchema.dump" ) def test_serialize(self, mock_request_schema_dump): """ diff --git a/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_response.py b/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_response.py index 5743bb669f..3ebd0ec342 100644 --- a/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_response.py +++ b/acapy_agent/protocols/didexchange/v1_0/messages/tests/test_response.py @@ -76,8 +76,7 @@ def test_type(self): assert self.response._type == DIDCommPrefix.qualify_current(DIDX_RESPONSE) @mock.patch( - "acapy_agent.protocols.didexchange.v1_0.messages." - "response.DIDXResponseSchema.load" + "acapy_agent.protocols.didexchange.v1_0.messages.response.DIDXResponseSchema.load" ) def test_deserialize(self, mock_response_schema_load): """ @@ -91,8 +90,7 @@ def test_deserialize(self, mock_response_schema_load): assert response is mock_response_schema_load.return_value @mock.patch( - "acapy_agent.protocols.didexchange.v1_0.messages." - "response.DIDXResponseSchema.dump" + "acapy_agent.protocols.didexchange.v1_0.messages.response.DIDXResponseSchema.dump" ) def test_serialize(self, mock_response_schema_dump): """ diff --git a/acapy_agent/protocols/endorse_transaction/v1_0/manager.py b/acapy_agent/protocols/endorse_transaction/v1_0/manager.py index 91597cfbbe..5e85ce6ce6 100644 --- a/acapy_agent/protocols/endorse_transaction/v1_0/manager.py +++ b/acapy_agent/protocols/endorse_transaction/v1_0/manager.py @@ -316,7 +316,7 @@ async def create_endorse_response( endorsed_msg = json.dumps(ledger_response) else: raise TransactionManagerError( - f"Invalid goal code for transaction record:" f" {txn_goal_code}" + f"Invalid goal code for transaction record: {txn_goal_code}" ) # need to return the endorsed msg or else the ledger will reject the diff --git a/acapy_agent/protocols/introduction/v0_1/messages/tests/test_forward_invitation.py b/acapy_agent/protocols/introduction/v0_1/messages/tests/test_forward_invitation.py index 65e999ee43..07a16ea3d4 100644 --- a/acapy_agent/protocols/introduction/v0_1/messages/tests/test_forward_invitation.py +++ b/acapy_agent/protocols/introduction/v0_1/messages/tests/test_forward_invitation.py @@ -34,7 +34,7 @@ def test_type(self): assert self.invitation._type == DIDCommPrefix.qualify_current(FORWARD_INVITATION) @mock.patch( - f"{PROTOCOL_PACKAGE}.messages." "forward_invitation.ForwardInvitationSchema.load" + f"{PROTOCOL_PACKAGE}.messages.forward_invitation.ForwardInvitationSchema.load" ) def test_deserialize(self, mock_invitation_schema_load): """ @@ -48,7 +48,7 @@ def test_deserialize(self, mock_invitation_schema_load): assert invitation is mock_invitation_schema_load.return_value @mock.patch( - f"{PROTOCOL_PACKAGE}.messages." "forward_invitation.ForwardInvitationSchema.dump" + f"{PROTOCOL_PACKAGE}.messages.forward_invitation.ForwardInvitationSchema.dump" ) def test_serialize(self, mock_invitation_schema_dump): """ diff --git a/acapy_agent/protocols/introduction/v0_1/messages/tests/test_invitation_request.py b/acapy_agent/protocols/introduction/v0_1/messages/tests/test_invitation_request.py index 306b45c99e..65e0dd57c9 100644 --- a/acapy_agent/protocols/introduction/v0_1/messages/tests/test_invitation_request.py +++ b/acapy_agent/protocols/introduction/v0_1/messages/tests/test_invitation_request.py @@ -26,7 +26,7 @@ def test_type(self): assert self.request._type == DIDCommPrefix.qualify_current(INVITATION_REQUEST) @mock.patch( - f"{PROTOCOL_PACKAGE}.messages." "invitation_request.InvitationRequestSchema.load" + f"{PROTOCOL_PACKAGE}.messages.invitation_request.InvitationRequestSchema.load" ) def test_deserialize(self, mock_invitation_schema_load): """ @@ -40,7 +40,7 @@ def test_deserialize(self, mock_invitation_schema_load): assert request is mock_invitation_schema_load.return_value @mock.patch( - f"{PROTOCOL_PACKAGE}.messages." "invitation_request.InvitationRequestSchema.dump" + f"{PROTOCOL_PACKAGE}.messages.invitation_request.InvitationRequestSchema.dump" ) def test_serialize(self, mock_invitation_schema_dump): """ diff --git a/acapy_agent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py b/acapy_agent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py index 4276d06480..c88ed6a561 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py +++ b/acapy_agent/protocols/issue_credential/v1_0/messages/tests/test_credential_request.py @@ -70,7 +70,7 @@ def test_type(self): ) @mock.patch( - f"{PROTOCOL_PACKAGE}.messages." "credential_request.CredentialRequestSchema.load" + f"{PROTOCOL_PACKAGE}.messages.credential_request.CredentialRequestSchema.load" ) def test_deserialize(self, mock_credential_request_schema_load): """ @@ -84,7 +84,7 @@ def test_deserialize(self, mock_credential_request_schema_load): assert credential_request is mock_credential_request_schema_load.return_value @mock.patch( - f"{PROTOCOL_PACKAGE}.messages." "credential_request.CredentialRequestSchema.dump" + f"{PROTOCOL_PACKAGE}.messages.credential_request.CredentialRequestSchema.dump" ) def test_serialize(self, mock_credential_request_schema_dump): """ diff --git a/acapy_agent/protocols/issue_credential/v1_0/routes.py b/acapy_agent/protocols/issue_credential/v1_0/routes.py index 1b5581a51b..8afe893a5f 100644 --- a/acapy_agent/protocols/issue_credential/v1_0/routes.py +++ b/acapy_agent/protocols/issue_credential/v1_0/routes.py @@ -477,8 +477,7 @@ async def credential_exchange_retrieve(request: web.BaseRequest): @docs( tags=["issue-credential v1.0"], summary=( - "Create a credential record without " - "sending (generally for use with Out-Of-Band)" + "Create a credential record without sending (generally for use with Out-Of-Band)" ), deprecated=True, ) diff --git a/acapy_agent/protocols/issue_credential/v2_0/messages/tests/test_cred_problem_report.py b/acapy_agent/protocols/issue_credential/v2_0/messages/tests/test_cred_problem_report.py index a1b6bc31d1..47b91020da 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/messages/tests/test_cred_problem_report.py +++ b/acapy_agent/protocols/issue_credential/v2_0/messages/tests/test_cred_problem_report.py @@ -29,8 +29,7 @@ def test_init_type(self): assert prob._type == DIDCommPrefix.qualify_current(CRED_20_PROBLEM_REPORT) @mock.patch( - f"{PROTOCOL_PACKAGE}.messages.cred_problem_report." - "V20CredProblemReportSchema.load" + f"{PROTOCOL_PACKAGE}.messages.cred_problem_report.V20CredProblemReportSchema.load" ) def test_deserialize(self, mock_load): """Test deserialization.""" @@ -48,8 +47,7 @@ def test_deserialize(self, mock_load): assert prob is mock_load.return_value @mock.patch( - f"{PROTOCOL_PACKAGE}.messages.cred_problem_report." - "V20CredProblemReportSchema.dump" + f"{PROTOCOL_PACKAGE}.messages.cred_problem_report.V20CredProblemReportSchema.dump" ) def test_serialize(self, mock_dump): """Test serialization.""" diff --git a/acapy_agent/protocols/issue_credential/v2_0/routes.py b/acapy_agent/protocols/issue_credential/v2_0/routes.py index de7c61f2e0..f1517cc0ed 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/routes.py +++ b/acapy_agent/protocols/issue_credential/v2_0/routes.py @@ -698,8 +698,7 @@ async def credential_exchange_retrieve(request: web.BaseRequest): @docs( tags=["issue-credential v2.0"], summary=( - "Create a credential record without " - "sending (generally for use with Out-Of-Band)" + "Create a credential record without sending (generally for use with Out-Of-Band)" ), ) @request_schema(V20IssueCredSchemaCore()) diff --git a/acapy_agent/protocols/out_of_band/v1_0/message_types.py b/acapy_agent/protocols/out_of_band/v1_0/message_types.py index 4160d99349..181bdff7e0 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/message_types.py +++ b/acapy_agent/protocols/out_of_band/v1_0/message_types.py @@ -26,7 +26,7 @@ INVITATION: f"{PROTOCOL_PACKAGE}.messages.invitation.Invitation", MESSAGE_REUSE: f"{PROTOCOL_PACKAGE}.messages.reuse.HandshakeReuse", MESSAGE_REUSE_ACCEPT: ( - f"{PROTOCOL_PACKAGE}.messages" ".reuse_accept.HandshakeReuseAccept" + f"{PROTOCOL_PACKAGE}.messages.reuse_accept.HandshakeReuseAccept" ), PROBLEM_REPORT: f"{PROTOCOL_PACKAGE}.messages.problem_report.OOBProblemReport", } diff --git a/acapy_agent/protocols/out_of_band/v1_0/messages/reuse_accept.py b/acapy_agent/protocols/out_of_band/v1_0/messages/reuse_accept.py index def92b3c0b..9e44b41254 100644 --- a/acapy_agent/protocols/out_of_band/v1_0/messages/reuse_accept.py +++ b/acapy_agent/protocols/out_of_band/v1_0/messages/reuse_accept.py @@ -8,8 +8,7 @@ from ..message_types import DEFAULT_VERSION, MESSAGE_REUSE_ACCEPT, PROTOCOL_PACKAGE HANDLER_CLASS = ( - f"{PROTOCOL_PACKAGE}.handlers" - ".reuse_accept_handler.HandshakeReuseAcceptMessageHandler" + f"{PROTOCOL_PACKAGE}.handlers.reuse_accept_handler.HandshakeReuseAcceptMessageHandler" ) diff --git a/acapy_agent/protocols/present_proof/dif/pres_exch.py b/acapy_agent/protocols/present_proof/dif/pres_exch.py index 677151954d..33f39d71ac 100644 --- a/acapy_agent/protocols/present_proof/dif/pres_exch.py +++ b/acapy_agent/protocols/present_proof/dif/pres_exch.py @@ -595,8 +595,7 @@ class Meta: data_key="schema", metadata={ "description": ( - "Accepts a list of schema or a dict containing filters like" - " oneof_filter." + "Accepts a list of schema or a dict containing filters like oneof_filter." ), "example": { "oneof_filter": [ diff --git a/acapy_agent/protocols/present_proof/v1_0/messages/presentation_request.py b/acapy_agent/protocols/present_proof/v1_0/messages/presentation_request.py index 0eb44ca721..d639eb3caf 100644 --- a/acapy_agent/protocols/present_proof/v1_0/messages/presentation_request.py +++ b/acapy_agent/protocols/present_proof/v1_0/messages/presentation_request.py @@ -12,8 +12,7 @@ from ..message_types import PRESENTATION_REQUEST, PROTOCOL_PACKAGE HANDLER_CLASS = ( - f"{PROTOCOL_PACKAGE}.handlers." - "presentation_request_handler.PresentationRequestHandler" + f"{PROTOCOL_PACKAGE}.handlers.presentation_request_handler.PresentationRequestHandler" ) diff --git a/acapy_agent/protocols/present_proof/v2_0/messages/pres_problem_report.py b/acapy_agent/protocols/present_proof/v2_0/messages/pres_problem_report.py index 1cdc6b2a30..61ae9a11e8 100644 --- a/acapy_agent/protocols/present_proof/v2_0/messages/pres_problem_report.py +++ b/acapy_agent/protocols/present_proof/v2_0/messages/pres_problem_report.py @@ -8,8 +8,7 @@ from ..message_types import PRES_20_PROBLEM_REPORT, PROTOCOL_PACKAGE HANDLER_CLASS = ( - f"{PROTOCOL_PACKAGE}.handlers.pres_problem_report_handler." - "V20PresProblemReportHandler" + f"{PROTOCOL_PACKAGE}.handlers.pres_problem_report_handler.V20PresProblemReportHandler" ) diff --git a/acapy_agent/protocols/present_proof/v2_0/messages/tests/test_pres_problem_report.py b/acapy_agent/protocols/present_proof/v2_0/messages/tests/test_pres_problem_report.py index 10b197b5e0..df8b1d581c 100644 --- a/acapy_agent/protocols/present_proof/v2_0/messages/tests/test_pres_problem_report.py +++ b/acapy_agent/protocols/present_proof/v2_0/messages/tests/test_pres_problem_report.py @@ -23,8 +23,7 @@ def test_init_type(self): assert prob._type == DIDCommPrefix.qualify_current(PRES_20_PROBLEM_REPORT) @mock.patch( - f"{PROTOCOL_PACKAGE}.messages.pres_problem_report." - "V20PresProblemReportSchema.load" + f"{PROTOCOL_PACKAGE}.messages.pres_problem_report.V20PresProblemReportSchema.load" ) def test_deserialize(self, mock_load): """Test deserialization.""" @@ -42,8 +41,7 @@ def test_deserialize(self, mock_load): assert prob is mock_load.return_value @mock.patch( - f"{PROTOCOL_PACKAGE}.messages.pres_problem_report." - "V20PresProblemReportSchema.dump" + f"{PROTOCOL_PACKAGE}.messages.pres_problem_report.V20PresProblemReportSchema.dump" ) def test_serialize(self, mock_dump): """Test serialization.""" diff --git a/acapy_agent/revocation/manager.py b/acapy_agent/revocation/manager.py index b97731b369..880c51e840 100644 --- a/acapy_agent/revocation/manager.py +++ b/acapy_agent/revocation/manager.py @@ -148,7 +148,7 @@ async def _get_endorsement_txn_for_revocation( ) except StorageNotFoundError: raise RevocationManagerError( - "No endorser connection record found " f"for id: {endorser_conn_id}" + f"No endorser connection record found for id: {endorser_conn_id}" ) endorser_info = await connection_record.metadata_get(session, "endorser_info") endorser_did = endorser_info["endorser_did"] diff --git a/acapy_agent/revocation/models/issuer_rev_reg_record.py b/acapy_agent/revocation/models/issuer_rev_reg_record.py index bed21031a2..ae10137695 100644 --- a/acapy_agent/revocation/models/issuer_rev_reg_record.py +++ b/acapy_agent/revocation/models/issuer_rev_reg_record.py @@ -400,7 +400,7 @@ async def fix_ledger_entry( LOGGER.debug(f"Fixed entry recs count = {rec_count}") LOGGER.debug(f"Rev reg entry value: {self.revoc_reg_entry.value}") - LOGGER.debug(f'Rev reg delta: {rev_reg_delta.get("value")}') + LOGGER.debug(f"Rev reg delta: {rev_reg_delta.get('value')}") # No update required if no discrepancies if rec_count == 0: diff --git a/acapy_agent/transport/pack_format.py b/acapy_agent/transport/pack_format.py index a4400c0dfe..4c70143b1a 100644 --- a/acapy_agent/transport/pack_format.py +++ b/acapy_agent/transport/pack_format.py @@ -80,9 +80,9 @@ def get_for_packed_msg(self, packed_msg: Union[str, bytes]) -> BaseWireFormat: DIDCommVersion.v1: self.v1pack_format, DIDCommVersion.v2: self.v2pack_format, }[get_version_for_packed_msg(packed_msg)] - assert ( - format - ), "self.v2_pack_format will be set when --experimental-didcomm-v2 is set" + assert format, ( + "self.v2_pack_format will be set when --experimental-didcomm-v2 is set" + ) return pack_format async def parse_message( diff --git a/acapy_agent/utils/endorsement_setup.py b/acapy_agent/utils/endorsement_setup.py index 685cdda3e6..0b733a706b 100644 --- a/acapy_agent/utils/endorsement_setup.py +++ b/acapy_agent/utils/endorsement_setup.py @@ -76,8 +76,7 @@ async def attempt_auto_author_with_endorser_setup(profile: Profile): ) else: raise EndorsementSetupError( - "Failed to establish endorser connection, invalid " - "invitation format." + "Failed to establish endorser connection, invalid invitation format." ) # configure the connection role and info (don't need to wait for the connection) diff --git a/acapy_agent/vc/data_integrity/cryptosuites/eddsa_jcs_2022.py b/acapy_agent/vc/data_integrity/cryptosuites/eddsa_jcs_2022.py index 69daaa9334..b0520aa8be 100644 --- a/acapy_agent/vc/data_integrity/cryptosuites/eddsa_jcs_2022.py +++ b/acapy_agent/vc/data_integrity/cryptosuites/eddsa_jcs_2022.py @@ -71,12 +71,12 @@ def proof_configuration(self, options: DataIntegrityProofOptions): https://www.w3.org/TR/vc-di-eddsa/#proof-configuration-eddsa-jcs-2022. """ proof_config = options - assert ( - proof_config.type == "DataIntegrityProof" - ), 'Expected proof.type to be "DataIntegrityProof' - assert ( - proof_config.cryptosuite == "eddsa-jcs-2022" - ), 'Expected proof.cryptosuite to be "eddsa-jcs-2022' + assert proof_config.type == "DataIntegrityProof", ( + 'Expected proof.type to be "DataIntegrityProof' + ) + assert proof_config.cryptosuite == "eddsa-jcs-2022", ( + 'Expected proof.cryptosuite to be "eddsa-jcs-2022' + ) if proof_config.created: assert datetime.fromisoformat(proof_config.created) @@ -93,12 +93,12 @@ def transformation( https://www.w3.org/TR/vc-di-eddsa/#transformation-eddsa-jcs-2022. """ - assert ( - options.type == "DataIntegrityProof" - ), "Expected proof.type to be `DataIntegrityProof`" - assert ( - options.cryptosuite == "eddsa-jcs-2022" - ), "Expected proof.cryptosuite to be `eddsa-jcs-2022`" + assert options.type == "DataIntegrityProof", ( + "Expected proof.type to be `DataIntegrityProof`" + ) + assert options.cryptosuite == "eddsa-jcs-2022", ( + "Expected proof.cryptosuite to be `eddsa-jcs-2022`" + ) return self._canonicalize(unsecured_document) diff --git a/acapy_agent/vc/ld_proofs/document_loader.py b/acapy_agent/vc/ld_proofs/document_loader.py index 521de31036..c348228687 100644 --- a/acapy_agent/vc/ld_proofs/document_loader.py +++ b/acapy_agent/vc/ld_proofs/document_loader.py @@ -70,8 +70,7 @@ async def _load_async(self, url: str, options: dict): document = self._load_http_document(url, options) else: raise LinkedDataProofException( - "Unrecognized url format. Must start with " - "'did:', 'http://' or 'https://'" + "Unrecognized url format. Must start with 'did:', 'http://' or 'https://'" ) return document diff --git a/acapy_agent/vc/ld_proofs/purposes/authentication_proof_purpose.py b/acapy_agent/vc/ld_proofs/purposes/authentication_proof_purpose.py index ef6a24787a..7a107b6100 100644 --- a/acapy_agent/vc/ld_proofs/purposes/authentication_proof_purpose.py +++ b/acapy_agent/vc/ld_proofs/purposes/authentication_proof_purpose.py @@ -50,13 +50,13 @@ def validate( if proof.get("challenge") != self.challenge: raise LinkedDataProofException( f"The challenge is not as expected; challenge=" - f'{proof.get("challenge")}, expected={self.challenge}' + f"{proof.get('challenge')}, expected={self.challenge}" ) if self.domain and (proof.get("domain") != self.domain): raise LinkedDataProofException( f"The domain is not as expected; " - f'domain={proof.get("domain")}, expected={self.domain}' + f"domain={proof.get('domain')}, expected={self.domain}" ) return super().validate( diff --git a/acapy_agent/wallet/anoncreds_upgrade.py b/acapy_agent/wallet/anoncreds_upgrade.py index 3335c5ae29..f0d5c421dc 100644 --- a/acapy_agent/wallet/anoncreds_upgrade.py +++ b/acapy_agent/wallet/anoncreds_upgrade.py @@ -675,7 +675,7 @@ async def finish_upgrade_by_updating_profile_or_shutting_down( await upgrade_subwallet(profile) await finish_upgrade(profile) LOGGER.info( - f"""Upgrade of subwallet {profile.settings.get('wallet.name')} has completed. Profile is now askar-anoncreds""" # noqa: E501 + f"""Upgrade of subwallet {profile.settings.get("wallet.name")} has completed. Profile is now askar-anoncreds""" # noqa: E501 ) else: await finish_upgrade(profile) @@ -702,7 +702,7 @@ async def check_upgrade_completion_loop(profile: Profile, is_subwallet=False): await upgrade_subwallet(profile) await finish_upgrade(profile) LOGGER.info( - f"""Upgrade of subwallet {profile.settings.get('wallet.name')} has completed. Profile is now askar-anoncreds""" # noqa: E501 + f"""Upgrade of subwallet {profile.settings.get("wallet.name")} has completed. Profile is now askar-anoncreds""" # noqa: E501 ) return LOGGER.info( diff --git a/acapy_agent/wallet/routes.py b/acapy_agent/wallet/routes.py index 4e05a147fe..67130c4b0f 100644 --- a/acapy_agent/wallet/routes.py +++ b/acapy_agent/wallet/routes.py @@ -1410,8 +1410,7 @@ async def on_register_nym_event(profile: Profile, event: Event): except StorageError as err: # log the error, but continue LOGGER.exception( - "Error accepting endorser invitation/configuring endorser" - " connection: %s", + "Error accepting endorser invitation/configuring endorser connection: %s", err, ) return diff --git a/acapy_agent/wallet/tests/test_sd_jwt.py b/acapy_agent/wallet/tests/test_sd_jwt.py index 1ee2040776..41d9ac2ff2 100644 --- a/acapy_agent/wallet/tests/test_sd_jwt.py +++ b/acapy_agent/wallet/tests/test_sd_jwt.py @@ -119,7 +119,7 @@ async def test_sign_with_did_key_and_verify(self): for disclosure in signed.split("~")[1:-1]: # Decode the disclosures - padded = f"{disclosure}{'=' * divmod(len(disclosure),4)[1]}" + padded = f"{disclosure}{'=' * divmod(len(disclosure), 4)[1]}" decoded = json.loads(urlsafe_b64decode(padded).decode("utf-8")) # Add the disclosures associated with the claims to be revealed if decoded[1] in revealed: diff --git a/pyproject.toml b/pyproject.toml index ca4e279697..8adb9dfb31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,10 +70,11 @@ didcomm-messaging = { version = "^0.1.1a0", optional = true } canonicaljson = "^2.0.0" [tool.poetry.group.dev.dependencies] -pre-commit = "~3.8.0" -# Sync with version in .pre-commit-config.yaml +# Sync with version in .pre-commit-config.yaml and .github/workflows/format.yml ruff = "0.9.1" +pre-commit = "~3.8.0" + sphinx = "^5.3.0" sphinx-rtd-theme = ">=0.4.3"