aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2023-08-30 07:20:08 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2023-08-30 07:20:08 +0300
commit379bf7a6cd7fb7b7c3684c834e20b8d4fe1170ae (patch)
tree8aa5d7fd5500bbaec064fc15c02a299f725a9c83
parentci: add pytest-github-actions-annotate-failures for test (diff)
downloadsnakeoil-379bf7a6cd7fb7b7c3684c834e20b8d4fe1170ae.tar.gz
snakeoil-379bf7a6cd7fb7b7c3684c834e20b8d4fe1170ae.tar.bz2
snakeoil-379bf7a6cd7fb7b7c3684c834e20b8d4fe1170ae.zip
mappings: small refactor
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/snakeoil/mappings.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/snakeoil/mappings.py b/src/snakeoil/mappings.py
index d4ac221d..f3663571 100644
--- a/src/snakeoil/mappings.py
+++ b/src/snakeoil/mappings.py
@@ -298,7 +298,7 @@ class ProtectedDict(DictMixin):
raise KeyError(key)
def keys(self):
- for k in self.new.keys():
+ for k in self.new:
yield k
for k in self.orig.keys():
if k not in self.blacklist and k not in self.new:
@@ -320,14 +320,14 @@ class ImmutableDict(Mapping):
elif isinstance(data, Mapping):
mapping = data
elif isinstance(data, DictMixin):
- mapping = {k: v for k, v in data.items()}
+ mapping = dict(data.items())
elif data is None:
mapping = {}
else:
try:
- mapping = {k: v for k, v in data}
- except TypeError as e:
- raise TypeError(f"unsupported data format: {e}")
+ mapping = dict(data)
+ except TypeError as exc:
+ raise TypeError(f"unsupported data format: {exc}")
object.__setattr__(self, "_dict", mapping)
def __getitem__(self, key):
@@ -362,8 +362,8 @@ class OrderedFrozenSet(Set):
def __init__(self, iterable=()):
try:
self._dict = ImmutableDict({x: None for x in iterable})
- except TypeError as e:
- raise TypeError("not iterable") from e
+ except TypeError as exc:
+ raise TypeError("not iterable") from exc
def __contains__(self, key):
return key in self._dict
@@ -419,8 +419,8 @@ class OrderedSet(OrderedFrozenSet, MutableSet):
def __init__(self, iterable=()):
try:
self._dict = {x: None for x in iterable}
- except TypeError as e:
- raise TypeError("not iterable") from e
+ except TypeError as exc:
+ raise TypeError("not iterable") from exc
def add(self, value):
self._dict[value] = None