Skip to content

Commit 6a01cfa

Browse files
committed
ISSUE-1503: fix: add Mapping abc and missing methods to DictWrapper
1 parent 97a2e7c commit 6a01cfa

File tree

1 file changed

+8
-2
lines changed
  • aws_lambda_powertools/utilities/data_classes

1 file changed

+8
-2
lines changed

aws_lambda_powertools/utilities/data_classes/common.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import base64
22
import json
3-
from typing import Any, Dict, Optional
3+
from typing import Any, Dict, Iterator, Mapping, Optional
44

55
from aws_lambda_powertools.shared.headers_serializer import BaseHeadersSerializer
66

77

8-
class DictWrapper:
8+
class DictWrapper(Mapping):
99
"""Provides a single read only access to a wrapper dict"""
1010

1111
def __init__(self, data: Dict[str, Any]):
@@ -21,6 +21,12 @@ def __eq__(self, other: Any) -> bool:
2121

2222
return self._data == other._data
2323

24+
def __iter__(self) -> Iterator:
25+
return iter(self._data)
26+
27+
def __len__(self) -> int:
28+
return len(self._data)
29+
2430
def get(self, key: str, default: Optional[Any] = None) -> Optional[Any]:
2531
return self._data.get(key, default)
2632

0 commit comments

Comments
 (0)