From 94f505f379d4ab8ccf85aff4c2ef73708301fa43 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Thu, 3 Nov 2022 14:52:22 +0300 Subject: [PATCH] Modernized collections to literal comprehensions syntax --- pgpy/packet/fields.py | 2 +- pgpy/pgp.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pgpy/packet/fields.py b/pgpy/packet/fields.py index 226d3507..87fd83fe 100644 --- a/pgpy/packet/fields.py +++ b/pgpy/packet/fields.py @@ -173,7 +173,7 @@ def __delitem__(self, key): raise NotImplementedError def __contains__(self, key): - return key in set(k for k, _ in itertools.chain(self._hashed_sp, self._unhashed_sp)) + return key in {k for k, _ in itertools.chain(self._hashed_sp, self._unhashed_sp)} def __copy__(self): sp = SubPackets() diff --git a/pgpy/pgp.py b/pgpy/pgp.py index 1530723c..5f9ba4f5 100644 --- a/pgpy/pgp.py +++ b/pgpy/pgp.py @@ -232,7 +232,7 @@ def notation(self): """ A ``dict`` of notation data in this signature, if any. Otherwise, an empty ``dict``. """ - return dict((nd.name, nd.value) for nd in self._signature.subpackets['NotationData']) + return {nd.name: nd.value for nd in self._signature.subpackets['NotationData']} @property def policy_uri(self): @@ -690,7 +690,7 @@ def signers(self): """ This will be a set of all of the key ids which have signed this User ID or Attribute. """ - return set(s.signer for s in self.__sig__) + return {s.signer for s in self.__sig__} @property def hashdata(self): @@ -867,7 +867,7 @@ def dash_escape(text): @property def encrypters(self): """A ``set`` containing all key ids (if any) to which this message was encrypted.""" - return set(m.encrypter for m in self._sessionkeys if isinstance(m, PKESessionKey)) + return {m.encrypter for m in self._sessionkeys if isinstance(m, PKESessionKey)} @property def filename(self): @@ -930,7 +930,7 @@ def signatures(self): @property def signers(self): """A ``set`` containing all key ids (if any) which have signed this message.""" - return set(m.signer for m in self._signatures) + return {m.signer for m in self._signatures} @property def type(self): @@ -987,7 +987,7 @@ def __str__(self): u"{signature:s}" # only add a Hash: header if we actually have at least one signature - hashes = set(s.hash_algorithm.name for s in self.signatures) + hashes = {s.hash_algorithm.name for s in self.signatures} hhdr = 'Hash: {hashes:s}\n'.format(hashes=','.join(sorted(hashes))) if hashes else '' return tmpl.format(hhdr=hhdr, @@ -2663,7 +2663,7 @@ def _add_alias(self, alias, pkid): self._aliases[-1][alias] = pkid # this is a duplicate alias->key link; ignore it - elif alias in self and pkid in set(m[alias] for m in self._aliases if alias in m): + elif alias in self and pkid in {m[alias] for m in self._aliases if alias in m}: pass # pragma: no cover # this is an alias that already exists, but points to a key that is not already referenced by it