Skip to content

Commit

Permalink
Doc: can't sampled_from([])
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Feb 8, 2021
1 parent 5a73a8f commit e9ac4f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hypothesis-python/src/hypothesis/strategies/_internal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ def sampled_from(elements):
the list. So e.g. ``sampled_from([10, 1])`` will shrink by trying to replace
1 values with 10, and ``sampled_from([1, 10])`` will shrink by trying to
replace 10 values with 1.
It is an error to sample from an empty sequence, because returning :func:`nothing`
makes it too easy to silently drop parts of compound strategies. If you need
that behaviour, use ``sampled_from(seq) if seq else nothing()``.
"""
values = check_sample(elements, "sampled_from")
if not values:
Expand Down

0 comments on commit e9ac4f5

Please sign in to comment.