Skip to content

Commit 66241c3

Browse files
authored
Hash filter years. (#95)
1 parent 4add98b commit 66241c3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/can/signals.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ class Filter:
236236
to_year: Optional[int] = None
237237
years: Optional[Set[int]] = None
238238

239+
def __hash__(self) -> int:
240+
# Convert the years set to a frozenset to make it hashable
241+
years_tuple = frozenset(self.years) if self.years is not None else None
242+
return hash((self.from_year, self.to_year, years_tuple))
243+
239244
def matches(self, model_year: Optional[int]) -> bool:
240245
if model_year is not None:
241246
if self.from_year is not None and self.to_year is not None:

0 commit comments

Comments
 (0)