Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

libs: Normalize FuncDict and FuncSet util collections key and value callables #102

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/faebryk/libs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,16 +1010,14 @@ def __init__(
def __contains__(self, item: T):
return item in self._keys[self._hasher(item)]

@property
def keys(self) -> Iterator[T]:
yield from chain.from_iterable(self._keys.values())

@property
def values(self) -> Iterator[U]:
yield from chain.from_iterable(self._values.values())

def __iter__(self) -> Iterator[T]:
yield from self.keys
yield from self.keys()

def __len__(self) -> int:
return sum(len(v) for v in self._values.values())
Expand Down Expand Up @@ -1054,7 +1052,7 @@ def __delitem__(self, key: T):

def items(self) -> Iterable[tuple[T, U]]:
"""Iter key-value pairs as items, just like a dict."""
yield from zip(self.keys, self.values)
yield from zip(self.keys(), self.values())

def __repr__(self) -> str:
return (
Expand Down