Skip to content

Commit 7436002

Browse files
TheTechmagedbluhm
authored andcommitted
chore: run black
Signed-off-by: Colton Wolkins (Indicio work address) <[email protected]>
1 parent abde3a0 commit 7436002

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

didcomm_messaging/quickstart.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
LOG = logging.getLogger(__name__)
2727

28+
2829
@attr.s(auto_attribs=True)
2930
class Message:
3031
"""Provide a nicer interface for messages than just Dictionaries"""
@@ -45,12 +46,12 @@ class Message:
4546

4647
# TODO: better implement/support these fields
4748
attachments: Optional[List[Attachment]] = None
48-
#from_prior: Optional[JWT] = None
49+
# from_prior: Optional[JWT] = None
4950

5051
# TODO: Add message validation for spec-defined fields
5152

5253
def __attrs_post_init__(self):
53-
#super().__init__(*args, **kwargs)
54+
# super().__init__(*args, **kwargs)
5455
if self.id is None:
5556
self.id = str(uuid.uuid4())
5657

@@ -81,13 +82,15 @@ class CompatibilityPrefixResolver(PrefixResolver):
8182
async def resolve_and_parse(self, did: str) -> DIDDocument:
8283
"""Resolve a DID and parse the DID document."""
8384
doc = await self.resolve(did)
84-
#return DIDDocument.deserialize(doc)
85+
# return DIDDocument.deserialize(doc)
8586
id_map = {}
87+
8688
def set_id(method):
8789
new_id = method["publicKeyMultibase"][1:9]
8890
id_map[method["id"]] = new_id
8991
method["id"] = did + "#" + new_id
9092
return method
93+
9194
doc["verificationMethod"] = [
9295
set_id(method) for method in doc["verificationMethod"]
9396
]
@@ -122,11 +125,9 @@ def generate_did():
122125
"type": "DIDCommMessaging",
123126
"serviceEndpoint": {
124127
"uri": "didcomm:transport/queue",
125-
"accept": [
126-
"didcomm/v2"
127-
],
128-
"routingKeys": []
129-
}
128+
"accept": ["didcomm/v2"],
129+
"routingKeys": [],
130+
},
130131
}
131132
],
132133
)
@@ -155,7 +156,9 @@ async def setup_default(did, did_secrets, enable_compatibility_prefix=False):
155156
# At present, the PrefixResolver is used to determine which library should
156157
# be used to convert a DID into a DIDDocument.
157158
if enable_compatibility_prefix:
158-
resolver = CompatibilityPrefixResolver({"did:peer:2": Peer2(), "did:peer:4": Peer4()})
159+
resolver = CompatibilityPrefixResolver(
160+
{"did:peer:2": Peer2(), "did:peer:4": Peer4()}
161+
)
159162
else:
160163
resolver = PrefixResolver({"did:peer:2": Peer2(), "did:peer:4": Peer4()})
161164

@@ -165,9 +168,7 @@ async def setup_default(did, did_secrets, enable_compatibility_prefix=False):
165168
# message to a single target, however. If the message needs to be forwarded
166169
# (because the recipient is behind a relay), then those messages will need
167170
# to be handled by the RoutingService.
168-
packer = PackagingService(
169-
resolver, crypto, secrets
170-
)
171+
packer = PackagingService(resolver, crypto, secrets)
171172

172173
# The RoutingService handles the routing of messages through relays. When a
173174
# message needs to be forwarded, the RoutingService will handle wrapping
@@ -196,7 +197,13 @@ async def setup_default(did, did_secrets, enable_compatibility_prefix=False):
196197
# DIDCommMessaging handles the orchestration of each individual service,
197198
# ensuring that messages get packed and delivered via a simple and straight
198199
# forward interface.
199-
DMP = DIDCommMessaging(crypto=crypto, secrets=secrets, resolver=resolver, packaging=packer, routing=router)
200+
DMP = DIDCommMessaging(
201+
crypto=crypto,
202+
secrets=secrets,
203+
resolver=resolver,
204+
packaging=packer,
205+
routing=router,
206+
)
200207

201208
return DMP
202209

@@ -296,18 +303,18 @@ async def setup_relay(
296303
# Send a message to the relay informing it of our new endpoint that people
297304
# should contact us by
298305
message = Message(
299-
type="https://didcomm.org/coordinate-mediation/3.0/recipient-update",
300-
id=str(uuid.uuid4()),
301-
body={
302-
"updates": [
303-
{
304-
"recipient_did": new_did,
305-
"action": "add",
306-
},
307-
],
308-
},
309-
frm=my_did,
310-
to=[relay_did],
306+
type="https://didcomm.org/coordinate-mediation/3.0/recipient-update",
307+
id=str(uuid.uuid4()),
308+
body={
309+
"updates": [
310+
{
311+
"recipient_did": new_did,
312+
"action": "add",
313+
},
314+
],
315+
},
316+
frm=my_did,
317+
to=[relay_did],
311318
)
312319
message = await send_http_message(dmp, my_did, message, target=relay_did)
313320

@@ -363,7 +370,7 @@ async def fetch_relayed_messages(
363370
await callback(msg)
364371

365372
if msg.type == "https://didcomm.org/basicmessage/2.0/message":
366-
logmsg = msg.body['content'].replace('\n', ' ').replace('\r', '')
373+
logmsg = msg.body["content"].replace("\n", " ").replace("\r", "")
367374
logger.info(f"Got message: {logmsg}")
368375

369376
message = Message(

0 commit comments

Comments
 (0)