Skip to content

Commit 79875a3

Browse files
committed
style: reformat using ruff
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
1 parent aba8ae2 commit 79875a3

8 files changed

Lines changed: 13 additions & 19 deletions

File tree

didcomm_messaging/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""DIDComm Messaging."""
2+
23
from dataclasses import dataclass
34
import json
45
from typing import Generic, Optional, List

didcomm_messaging/crypto/backend/askar.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Askar backend for DIDComm Messaging."""
2+
23
from collections import OrderedDict
34
import hashlib
45
import json
@@ -133,9 +134,7 @@ def kid(self) -> str:
133134
class AskarCryptoService(CryptoService[AskarKey, AskarSecretKey]):
134135
"""CryptoService backend implemented using Askar."""
135136

136-
async def ecdh_es_encrypt(
137-
self, to_keys: Sequence[AskarKey], message: bytes
138-
) -> bytes:
137+
async def ecdh_es_encrypt(self, to_keys: Sequence[AskarKey], message: bytes) -> bytes:
139138
"""Encode a message into DIDComm v2 anonymous encryption."""
140139
builder = JweBuilder(with_flatten_recipients=False)
141140

@@ -225,9 +224,7 @@ async def ecdh_es_decrypt(
225224
"A256CBC-HS512",
226225
"XC20P",
227226
):
228-
raise CryptoServiceError(
229-
f"Unsupported ECDH-ES content encryption: {enc_alg}"
230-
)
227+
raise CryptoServiceError(f"Unsupported ECDH-ES content encryption: {enc_alg}")
231228

232229
epk_header = recip.header.get("epk")
233230
if not epk_header:
@@ -239,9 +236,7 @@ async def ecdh_es_decrypt(
239236
raise CryptoServiceError("Error loading ephemeral key")
240237

241238
try:
242-
cek = ecdh.EcdhEs(
243-
alg_id, None, wrapper.apv_bytes
244-
).receiver_unwrap_key( # type: ignore
239+
cek = ecdh.EcdhEs(alg_id, None, wrapper.apv_bytes).receiver_unwrap_key( # type: ignore
245240
wrap_alg,
246241
enc_alg,
247242
epk,

didcomm_messaging/crypto/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""CryptoService and SecretsManager interfaces for DIDComm Messaging."""
22

3-
43
from abc import ABC, abstractmethod
54
from typing import Generic, Mapping, Optional, Sequence, TypeVar, Union
65

didcomm_messaging/crypto/jwe.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ def _deserialize(cls, parsed: Mapping[str, Any]) -> "JweEnvelope": # noqa: C901
256256
try:
257257
protected: dict = json.loads(from_b64url(protected_b64))
258258
except json.JSONDecodeError:
259-
raise ValueError(
260-
"Invalid JWE: invalid JSON for protected headers"
261-
) from None
259+
raise ValueError("Invalid JWE: invalid JSON for protected headers") from None
262260
unprotected = parsed.get("unprotected") or {}
263261
if protected.keys() & unprotected.keys():
264262
raise ValueError("Invalid JWE: duplicate header")

didcomm_messaging/packaging.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""PackagingService interface."""
22

3-
43
from dataclasses import dataclass
54
import hashlib
65
from typing import Generic, Literal, Optional, Sequence, Tuple, Union
@@ -179,9 +178,7 @@ async def pack(
179178
await self.recip_for_kid_or_default_for_did(crypto, resolver, kid)
180179
for kid in to
181180
]
182-
sender_kid = (
183-
await self.default_sender_kid_for_did(resolver, frm) if frm else None
184-
)
181+
sender_kid = await self.default_sender_kid_for_did(resolver, frm) if frm else None
185182
sender_key = await secrets.get_secret_by_kid(sender_kid) if sender_kid else None
186183
if frm and not sender_key:
187184
raise PackagingServiceError("No sender key found")

didcomm_messaging/quickstart.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Quickstart helpers for beginner users of DIDComm."""
2+
23
from typing import (
34
Optional,
45
Dict,

tests/crypto/test_askar_x_authlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test compabibility between Askar and Authlib."""
2+
23
import json
34
from aries_askar import Key, KeyAlg
45
from authlib.jose import OKPKey
@@ -42,8 +43,9 @@ def bob_authlib_key(bob_askar_key: Key):
4243

4344
@pytest.fixture
4445
def alice(alice_askar_key: Key, alice_authlib_key: OKPKey):
45-
yield AskarSecretKey(alice_askar_key, ALICE_KID), AuthlibKey(
46-
alice_authlib_key, ALICE_KID
46+
yield (
47+
AskarSecretKey(alice_askar_key, ALICE_KID),
48+
AuthlibKey(alice_authlib_key, ALICE_KID),
4749
)
4850

4951

tests/test_packaging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test PackagingService."""
2+
23
import pytest
34

45
from aries_askar import Key, KeyAlg

0 commit comments

Comments
 (0)