Skip to content

Commit f753f81

Browse files
authored
Merge pull request jamesls#310 from jamesls/sample-from-set
Fix DeprecationWarning for sampling from a set
2 parents 0a310bb + d6938e2 commit f753f81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fakeredis/_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ def spop(self, key, count=None):
19371937
if count is None:
19381938
if not key.value:
19391939
return None
1940-
item = random.sample(key.value, 1)[0]
1940+
item = random.sample(list(key.value), 1)[0]
19411941
key.value.remove(item)
19421942
key.updated()
19431943
return item
@@ -1956,10 +1956,10 @@ def srandmember(self, key, count=None):
19561956
if not key.value:
19571957
return None
19581958
else:
1959-
return random.sample(key.value, 1)[0]
1959+
return random.sample(list(key.value), 1)[0]
19601960
elif count >= 0:
19611961
count = min(count, len(key.value))
1962-
return random.sample(key.value, count)
1962+
return random.sample(list(key.value), count)
19631963
else:
19641964
items = list(key.value)
19651965
return [random.choice(items) for _ in range(-count)]

0 commit comments

Comments
 (0)