Skip to content

Commit 8612298

Browse files
Add support for new Ruff checks
1 parent 1d9b8b1 commit 8612298

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

aws_lambda_powertools/utilities/data_classes/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def __getitem__(self, k):
7171
def __setitem__(self, k, v):
7272
super().__setitem__(k.lower(), v)
7373

74+
def __hash__(self):
75+
# Convert the dictionary to a frozenset of tuples (key, value)
76+
# where all keys are lowercase
77+
items = frozenset((k.lower(), v) for k, v in self.items())
78+
return hash(items)
79+
7480

7581
class DictWrapper(Mapping):
7682
"""Provides a single read only access to a wrapper dict"""
@@ -154,6 +160,9 @@ def raw_event(self) -> dict[str, Any]:
154160
"""The original raw event dict"""
155161
return self._data
156162

163+
def __hash__(self):
164+
return hash(self._data)
165+
157166

158167
class BaseProxyEvent(DictWrapper):
159168
@property

ruff.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ lint.ignore = [
3939
"PLC1901", # Compare-to-empty-string - disabled temporarily
4040
"PYI024",
4141
"A005",
42-
"TC006" # https://docs.astral.sh/ruff/rules/runtime-cast-value/
42+
"TC006", # https://docs.astral.sh/ruff/rules/runtime-cast-value/
43+
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
4344
]
4445

4546
# Exclude files and directories

0 commit comments

Comments
 (0)