]>
crepu.dev Git - config.git/blob - djavu-asus/emacs/elpy/rpc-venv/lib/python3.11/site-packages/setuptools/_itertools.py
b8bf6d210aec669b6b948942eda1db953e8725fa
1 from setuptools
.extern
.more_itertools
import consume
# noqa: F401
4 # copied from jaraco.itertools 6.1
5 def ensure_unique(iterable
, key
=lambda x
: x
):
7 Wrap an iterable to raise a ValueError if non-unique values are encountered.
9 >>> list(ensure_unique('abc'))
11 >>> consume(ensure_unique('abca'))
12 Traceback (most recent call last):
14 ValueError: Duplicate element 'a' encountered.
18 for element
in iterable
:
21 raise ValueError(f
"Duplicate element {element!r} encountered.")