@@ -686,17 +686,13 @@ def _process_self_signatures(self, user_id, signatures):
686686 devices = devices [user_id ]
687687 except SynapseError as e :
688688 failures [user_id ] = {
689- device : _exception_to_failure (e )
690- for device in signatures .keys ()
689+ device : _exception_to_failure (e ) for device in signatures .keys ()
691690 }
692691 return signature_list , failures
693692
694693 for device_id , device in signatures .items ():
695694 try :
696- if (
697- "signatures" not in device
698- or user_id not in device ["signatures" ]
699- ):
695+ if "signatures" not in device or user_id not in device ["signatures" ]:
700696 # no signature was sent
701697 raise SynapseError (
702698 400 , "Invalid signature" , Codes .INVALID_SIGNATURE
@@ -725,9 +721,7 @@ def _process_self_signatures(self, user_id, signatures):
725721 # signed by an unknown device, or the
726722 # device does not have the key
727723 raise SynapseError (
728- 400 ,
729- "Invalid signature" ,
730- Codes .INVALID_SIGNATURE ,
724+ 400 , "Invalid signature" , Codes .INVALID_SIGNATURE
731725 )
732726
733727 # get the key and check the signature
@@ -760,9 +754,9 @@ def _process_self_signatures(self, user_id, signatures):
760754 stored_device = devices [device_id ]["keys" ]
761755 except KeyError :
762756 raise SynapseError (404 , "Unknown device" , Codes .NOT_FOUND )
763- if self_signing_key_id in stored_device .get (
764- "signatures" , {}
765- ). get ( user_id , {}) :
757+ if self_signing_key_id in stored_device .get ("signatures" , {}). get (
758+ user_id , {}
759+ ):
766760 # we already have a signature on this device, so we
767761 # can skip it, since it should be exactly the same
768762 continue
@@ -776,9 +770,7 @@ def _process_self_signatures(self, user_id, signatures):
776770 (self_signing_key_id , user_id , device_id , signature )
777771 )
778772 except SynapseError as e :
779- failures .setdefault (user_id , {})[
780- device_id
781- ] = _exception_to_failure (e )
773+ failures .setdefault (user_id , {})[device_id ] = _exception_to_failure (e )
782774
783775 return signature_list , failures
784776
@@ -799,9 +791,7 @@ def _process_other_signatures(self, user_id, signatures):
799791 except SynapseError as e :
800792 failure = _exception_to_failure (e )
801793 for user , devicemap in signatures .items ():
802- failures [user ] = {
803- device_id : failure for device_id in devicemap .keys ()
804- }
794+ failures [user ] = {device_id : failure for device_id in devicemap .keys ()}
805795 return signature_list , failures
806796
807797 for user , devicemap in signatures .items ():
@@ -833,9 +823,7 @@ def _process_other_signatures(self, user_id, signatures):
833823 failure = _exception_to_failure (
834824 SynapseError (404 , "Unknown device" , Codes .NOT_FOUND )
835825 )
836- failures [user ] = {
837- device : failure for device in other_devices
838- }
826+ failures [user ] = {device : failure for device in other_devices }
839827
840828 if user_signing_key_id in stored_key .get ("signatures" , {}).get (
841829 user_id , {}
@@ -848,9 +836,7 @@ def _process_other_signatures(self, user_id, signatures):
848836 )
849837
850838 signature = key ["signatures" ][user_id ][user_signing_key_id ]
851- signature_list .append (
852- (user_signing_key_id , user , device_id , signature )
853- )
839+ signature_list .append ((user_signing_key_id , user , device_id , signature ))
854840 except SynapseError as e :
855841 failure = _exception_to_failure (e )
856842 if device_id is None :
0 commit comments