Skip to content

Commit 1f6d09f

Browse files
committed
Remove dead code in uniq
Now that `unbool` creates a hashable, the fallback options for `uniq` are unnecessary.
1 parent 463e087 commit 1f6d09f

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

jsonschema/_utils.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import itertools
21
import json
32
import pkgutil
43
import re
@@ -198,26 +197,5 @@ def unbool(element, true=object(), false=object()):
198197
def uniq(container):
199198
"""
200199
Check if all of a container's elements are unique.
201-
202-
Successively tries first to rely that the elements are hashable, then
203-
falls back on them being sortable, and finally falls back on brute
204-
force.
205200
"""
206-
207-
try:
208-
return len(set(unbool(i) for i in container)) == len(container)
209-
except TypeError:
210-
try:
211-
sort = sorted(unbool(i) for i in container)
212-
sliced = itertools.islice(sort, 1, None)
213-
for i, j in zip(sort, sliced):
214-
if i == j:
215-
return False
216-
except (NotImplementedError, TypeError):
217-
seen = []
218-
for e in container:
219-
e = unbool(e)
220-
if e in seen:
221-
return False
222-
seen.append(e)
223-
return True
201+
return len(set(unbool(i) for i in container)) == len(container)

0 commit comments

Comments
 (0)