diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst index aa603dd5bf..2a2eaaddc6 100644 --- a/hypothesis-python/RELEASE.rst +++ b/hypothesis-python/RELEASE.rst @@ -1,5 +1,6 @@ RELEASE_TYPE: minor -Deprecate use of :func:`~hypothesis.assume` and ``reject()`` +This release deprecates use of :func:`~hypothesis.assume` and ``reject()`` outside of property-based tests, because these functions work by raising a -special exception (:issue:`3743`). +special exception (:issue:`3743`). It also fixes some type annotations +(:issue:`3753`). diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/core.py b/hypothesis-python/src/hypothesis/strategies/_internal/core.py index 0fd76b03cd..a01fc7486e 100644 --- a/hypothesis-python/src/hypothesis/strategies/_internal/core.py +++ b/hypothesis-python/src/hypothesis/strategies/_internal/core.py @@ -122,6 +122,7 @@ from hypothesis.strategies._internal.shared import SharedStrategy from hypothesis.strategies._internal.strategies import ( Ex, + Ex_Inv, SampledFromStrategy, T, one_of, @@ -1136,7 +1137,7 @@ def builds( @cacheable @defines_strategy(never_lazy=True) -def from_type(thing: Type[Ex]) -> SearchStrategy[Ex]: +def from_type(thing: Type[Ex_Inv]) -> SearchStrategy[Ex_Inv]: """Looks up the appropriate search strategy for the given type. ``from_type`` is used internally to fill in missing arguments to diff --git a/whole-repo-tests/test_mypy.py b/whole-repo-tests/test_mypy.py index 39bac0fedc..f75f04eb67 100644 --- a/whole-repo-tests/test_mypy.py +++ b/whole-repo-tests/test_mypy.py @@ -126,6 +126,10 @@ def convert_lines(): "tuples(text(), text(), text(), text(), text(), text())", "tuple[Any, ...]", ), + ( + "from_type(type).flatmap(from_type).filter(lambda x: not isinstance(x, int))", + "Ex_Inv`-1", + ), ], ) def test_revealed_types(tmpdir, val, expect):