Skip to content

Commit 4729eb7

Browse files
authored
Fix Bugs with oci/layer.py (#166)
* Fix bug with __iter__() not returning Iterator * Fix bug with __delitem__() always raising KeyError * Fix bug with __setitem__() alwasy raising KeyError
1 parent 39d21a6 commit 4729eb7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/gardenlinux/oci/layer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def __getitem__(self, key):
9191

9292
if key == "annotations":
9393
return self._annotations
94-
95-
raise KeyError(
96-
f"'{self.__class__.__name__}' object is not subscriptable except for keys: {_SUPPORTED_MAPPING_KEYS}"
97-
)
94+
else:
95+
raise KeyError(
96+
f"'{self.__class__.__name__}' object is not subscriptable except for keys: {_SUPPORTED_MAPPING_KEYS}"
97+
)
9898

9999
def __iter__(self):
100100
"""
@@ -104,7 +104,7 @@ def __iter__(self):
104104
:since: 0.7.0
105105
"""
106106

107-
iter(_SUPPORTED_MAPPING_KEYS)
107+
return iter(_SUPPORTED_MAPPING_KEYS)
108108

109109
def __len__(self):
110110
"""
@@ -128,10 +128,10 @@ def __setitem__(self, key, value):
128128

129129
if key == "annotations":
130130
self._annotations = value
131-
132-
raise KeyError(
133-
f"'{self.__class__.__name__}' object is not subscriptable except for keys: {_SUPPORTED_MAPPING_KEYS}"
134-
)
131+
else:
132+
raise KeyError(
133+
f"'{self.__class__.__name__}' object is not subscriptable except for keys: {_SUPPORTED_MAPPING_KEYS}"
134+
)
135135

136136
@staticmethod
137137
def generate_metadata_from_file_name(file_name: PathLike | str, arch: str) -> dict:

0 commit comments

Comments
 (0)