Repository: HypothesisWorks/hypothesis

Issue:
hypothesis.strategies.lists fails for elements=None and max_size=0
According to the documentation [here](https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.lists),

> If max_size is 0 then elements may be None and only the empty list will be drawn

However, when `elements=None` and `max_size=0`, an uncaught excaption is raised:
```python
>>> import hypothesis
>>> hypothesis.strategies.lists(elements=None, max_size=0).example()
Traceback (most recent call last):
...
hypothesis.errors.InvalidArgument: Expected SearchStrategy but got elements=None (type=NoneType)
```
fix #1968 and #2046: documentation
added `` `` to some of the arguments listed in dictionaries text
Add hyperlinks to unlinked cross-references in docs
I'm writing this one up for @djarecka, so per our usual policy it's hers for a week - after that we'll accept other pull requests or requests to reserve it again.

We would like our docs to be easy to explore, and that means hyperlinks.  However, not all references to other strategies (or other functions, or standard library types) are cross-references.  Compare for example [`datetimes()`](https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.datetimes) (lots of links) with [`dictionaries()`](https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.dictionaries) (unlinked *lists*).

These links should use [Sphinx "roles"](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html), typically `:func:` (or `:class:`, or `:obj:` for any other object).  For example:

```
:func:`hypothesis.note`  # renders "hypothesis.note()"
:func:`~hypothesis.strategies.builds`  # renders "builds()"
:obj:`@given <hypothesis.given>`  # renders "@given"
:class:`python:slice`  # renders "slice" with link upstream (grep "intersphinx" for details)
```


Discussion:
Ah, a docs bug! That should read 

> If max_size is 0, only the empty list will be drawn.

You can instead use the `nothing()` strategy, which will always lead to empty lists, or with max_size=0 literally any strategy will work. 

Hi @Zac-HD , sorry but really didn't have time last week after I came back to Boston. Will try to do it, but of course if anyone wants to work on it, it's fine :)
Reserving this one for @SamBackwell, for the usual one week period 😄 
@SamBackwell let me know if you want to work through this one when we catch up :-) 
Useful [cheat sheet here](https://thomas-cokelaer.info/tutorials/sphinx/rest_syntax.html). 


Happy to work on this one. 

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/_strategies.py b/hypothesis-python/src/hypothesis/_strategies.py
--- a/hypothesis-python/src/hypothesis/_strategies.py
+++ b/hypothesis-python/src/hypothesis/_strategies.py
@@ -723,14 +723,13 @@ def lists(
     # type: (...) -> SearchStrategy[List[Ex]]
     """Returns a list containing values drawn from elements with length in the
     interval [min_size, max_size] (no bounds in that direction if these are
-    None). If max_size is 0 then elements may be None and only the empty list
-    will be drawn.
+    None). If max_size is 0, only the empty list will be drawn.
 
-    If unique is True (or something that evaluates to True), we compare direct
+    If ``unique`` is True (or something that evaluates to True), we compare direct
     object equality, as if unique_by was ``lambda x: x``. This comparison only
     works for hashable types.
 
-    If unique_by is not None it must be a callable or tuple of callables
+    If ``unique_by`` is not None it must be a callable or tuple of callables
     returning a hashable type when given a value drawn from elements. The
     resulting list will satisfy the condition that for ``i`` != ``j``,
     ``unique_by(result[i])`` != ``unique_by(result[j])``.
@@ -904,10 +903,11 @@ def dictionaries(
     # type: (...) -> SearchStrategy[Dict[Ex, T]]
     # Describing the exact dict_class to Mypy drops the key and value types,
     # so we report Dict[K, V] instead of Mapping[Any, Any] for now.  Sorry!
-    """Generates dictionaries of type dict_class with keys drawn from the keys
-    argument and values drawn from the values argument.
+    """Generates dictionaries of type ``dict_class`` with keys drawn from the ``keys``
+    argument and values drawn from the ``values`` argument.
 
-    The size parameters have the same interpretation as for lists.
+    The size parameters have the same interpretation as for
+    :func:`~hypothesis.strategies.lists`.
 
     Examples from this strategy shrink by trying to remove keys from the
     generated dictionary, and by shrinking each generated key and value.
@@ -1043,7 +1043,7 @@ def text(
 ):
     # type: (...) -> SearchStrategy[Text]
     """Generates values of a unicode text type (unicode on python 2, str on
-    python 3) with values drawn from alphabet, which should be an iterable of
+    python 3) with values drawn from ``alphabet``, which should be an iterable of
     length one strings or a strategy generating such strings.
 
     The default alphabet strategy can generate the full unicode range but
@@ -1051,7 +1051,7 @@ def text(
     encoding.  You can use :func:`~hypothesis.strategies.characters` without
     arguments to find surrogate-related bugs such as :bpo:`34454`.
 
-    min_size and max_size have the usual interpretations.
+    ``min_size`` and ``max_size`` have the usual interpretations.
     Note that Python measures string length by counting codepoints: U+00C5
     ``Å`` is a single character, while U+0041 U+030A ``Å`` is two - the ``A``,
     and a combining ring above.
@@ -1445,13 +1445,13 @@ def fractions(
     # type: (...) -> SearchStrategy[Fraction]
     """Returns a strategy which generates Fractions.
 
-    If min_value is not None then all generated values are no less than
-    min_value.  If max_value is not None then all generated values are no
-    greater than max_value.  min_value and max_value may be anything accepted
+    If ``min_value`` is not None then all generated values are no less than
+    ``min_value``.  If ``max_value`` is not None then all generated values are no
+    greater than ``max_value``.  ``min_value`` and ``max_value`` may be anything accepted
     by the :class:`~fractions.Fraction` constructor.
 
-    If max_denominator is not None then the denominator of any generated
-    values is no greater than max_denominator. Note that max_denominator must
+    If ``max_denominator`` is not None then the denominator of any generated
+    values is no greater than ``max_denominator``. Note that ``max_denominator`` must
     be None or a positive integer.
 
     Examples from this strategy shrink towards smaller denominators, then


Test patch: