Skip to content

Commit

Permalink
Modernized collections to literal comprehensions syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Nov 10, 2022
1 parent c092c15 commit 94f505f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pgpy/packet/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions pgpy/pgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 94f505f

Please sign in to comment.