Skip to content

Commit

Permalink
fix: Provide a sequence to random.sample
Browse files Browse the repository at this point in the history
The sample function used to automatically convert sets to sequences but
that is no longer supported starting in 3.11 so we have to do it
manually.

Reference: https://docs.python.org/3/library/random.html#random.sample
  • Loading branch information
feanil committed Mar 15, 2024
1 parent 208560d commit ec86f91
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xmodule/library_content_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def make_selection(cls, selected, children, max_count, mode):
pool = valid_block_keys - selected_keys
if mode == "random":
num_to_add = min(len(pool), num_to_add)
added_block_keys = set(rand.sample(pool, num_to_add))
added_block_keys = set(rand.sample(list(pool), num_to_add))
# We now have the correct n random children to show for this user.
else:
raise NotImplementedError("Unsupported mode.")
Expand Down

0 comments on commit ec86f91

Please sign in to comment.