Replace (check and) del pattern with pop method

This commit is contained in:
NIC619
2019-11-20 23:06:37 +08:00
parent 74198c70b1
commit 19907e18ec
8 changed files with 20 additions and 34 deletions

View File

@ -50,8 +50,7 @@ class SecurityMultistream(ABC):
:param transport: the corresponding transportation to the ``protocol``.
"""
# If protocol is already added before, remove it and add it again.
if protocol in self.transports:
del self.transports[protocol]
self.transports.pop(protocol, None)
self.transports[protocol] = transport
# Note: None is added as the handler for the given protocol since
# we only care about selecting the protocol, not any handler function