NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #384 most downloaded on PyPI
The property-based testing library for Python
Latest stable
6.170.17
Last release 2 days ago
20 Nov 2026
Ships on a steady schedule
a new release about every 9 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
1596 releases · first in 2013
Drag across the ruler to compare, or tap a release to open it.
This patch fixes some internal typos. There is no user-visible change.
This patch fixes some internal typos. There is no user-visible change.
This patch lays more groundwork for filter rewriting (2701). There is no user-visible change... yet.
This patch lays more groundwork for filter rewriting (2701). There is no user-visible change... yet.
This release registers the remaining builtin types, and teaches ~hypothesis.strategies.from_type to try resolving ~python:typing.ForwardRef and ~pytho
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This release registers the remaining builtin types, and teaches ~hypothesis.strategies.from_type to try resolving ~python:typing.ForwardRef and ~python:typing.Type references to built-in types.
This release registers the remaining builtin types, and teaches from_type() to try resolving ForwardRef and Type references to built-in types.
This release teaches ~hypothesis.stateful.RuleBasedStateMachine to avoid checking ~hypothesis.stateful.invariant\ s until all ~hypothesis.stateful.ini
This release teaches ~hypothesis.stateful.RuleBasedStateMachine to avoid checking ~hypothesis.stateful.invariants until all ~hypothesis.stateful.initialize rules have been run. You can enable checking of specific invariants for incompletely initialized machines by using @invariant(check_during_init=True) (2868).
In previous versions, it was possible if awkward to implement this behaviour using ~hypothesis.stateful.precondition and an auxiliary variable.
This release teaches RuleBasedStateMachine to avoid checking invariant() s until all initialize() rules have been run. You can enable checking of specific invariants for incompletely initialized machines by using @invariant(check_during_init=True) ( issue #2868 ).
In previous versions, it was possible if awkward to implement this behaviour using precondition() and an auxiliary variable.
This patch improves the error message when ~hypothesis.strategies.from_type fails to resolve a forward-reference inside a python:typing.Type such as T
This patch improves the error message when ~hypothesis.strategies.from_type fails to resolve a forward-reference inside a python:typing.Type such as Type["int"] (2565).
This patch improves the error message when from_type() fails to resolve a forward-reference inside a typing.Type such as Type["int"] ( issue #2565 ).
This release makes it an explicit error to apply ~hypothesis.stateful.invariant to a ~hypothesis.stateful.rule or ~hypothesis.stateful.initialize rule
This release makes it an explicit error to apply ~hypothesis.stateful.invariant to a ~hypothesis.stateful.rule or ~hypothesis.stateful.initialize rule in stateful testing. Such a combination had unclear semantics, especially in combination with ~hypothesis.stateful.precondition, and was never meant to be allowed (2681).
This release makes it an explicit error to apply invariant() to a rule() or initialize() rule in stateful testing . Such a combination had unclear semantics, especially in combination with precondition() , and was never meant to be allowed ( issue #2681 ).
This release adds |Phase.explain|, in which Hypothesis attempts to explain *why* your test failed by pointing to suspicious lines of code (i.e. those
This release adds |Phase.explain|, in which Hypothesis attempts to explain why your test failed by pointing to suspicious lines of code (i.e. those which were always, and only, run on failing inputs). We plan to include "generalising" failing examples in this phase in a future release (2192).
This patch fixes 2794, where nesting ~hypothesis.strategies.deferred strategies within ~hypothesis.strategies.recursive strategies could trigger an in
This patch fixes 2794, where nesting ~hypothesis.strategies.deferred strategies within ~hypothesis.strategies.recursive strategies could trigger an internal assertion. While it was always possible to get the same results from a more sensible strategy, the convoluted form now works too.
This patch fixes issue #2794 , where nesting deferred() strategies within recursive() strategies could trigger an internal assertion. While it was always possible to get the same results from a more sensible strategy, the convoluted form now works too.
This patch fixes several problems with mypy when --no-implicit-reexport _ was activated in user projects.
This patch fixes several problems with mypy when --no-implicit-reexport was activated in user projects.
Thanks to Nikita Sobolev for fixing 2884!
This patch fixes an exception that occurs when using type unions of the typing-extensions Literal backport on Python 3.6.
This patch fixes an exception that occurs when using type unions of the typing-extensions Literal backport on Python 3.6.
Thanks to Ben Anhalt for identifying and fixing this bug.
This release fixes stateful testing methods with multiple ~hypothesis.stateful.precondition decorators. Previously, only the outer-most precondition w
This release fixes stateful testing methods with multiple ~hypothesis.stateful.precondition decorators. Previously, only the outer-most precondition was checked (2681).
This release fixes stateful testing methods with multiple precondition() decorators. Previously, only the outer-most precondition was checked ( issue #2681 ).
This patch refactors some internals of ~hypothesis.stateful.RuleBasedStateMachine. There is no change to the public API or behaviour.
This patch refactors some internals of ~hypothesis.stateful.RuleBasedStateMachine. There is no change to the public API or behaviour.
This patch refactors some internals of RuleBasedStateMachine . There is no change to the public API or behaviour.
This patch moves some internal code, so that future work can avoid creating import cycles. There is no user-visible change.
This patch moves some internal code, so that future work can avoid creating import cycles. There is no user-visible change.
This patch enables ~hypothesis.strategies.register_type_strategy for subclasses of python:typing.TypedDict. Previously, ~hypothesis.strategies.from_ty
This patch enables ~hypothesis.strategies.register_type_strategy for subclasses of python:typing.TypedDict. Previously, ~hypothesis.strategies.from_type would ignore the registered strategy (2872).
Thanks to Ilya Lebedev for identifying and fixing this bug!
This patch enables register_type_strategy() for subclasses of typing.TypedDict . Previously, from_type() would ignore the registered strategy ( issue #2872 ).
Thanks to Ilya Lebedev for identifying and fixing this bug!
This release lays the groundwork for automatic rewriting of simple filters, for example converting integers().filter(lambda x: x > 9) to integers(min_
This release lays the groundwork for automatic rewriting of simple filters, for example converting integers().filter(lambda x: x > 9) to integers(min_value=10).
Note that this is not supported yet, and we will continue to recommend writing the efficient form directly wherever possible - predicate rewriting is provided mainly for the benefit of downstream libraries which would otherwise have to implement it for themselves (e.g. pandera and icontract-hypothesis). See 2701 for details.
The Hypothesis pytest plugin now requires pytest version 4.6 or later. If the plugin detects an earlier version of pytest, it will automatically deact
The Hypothesis pytest plugin now requires pytest version 4.6 or later. If the plugin detects an earlier version of pytest, it will automatically deactivate itself.
(4.6.x is the earliest pytest branch that still accepts community bugfixes.)
Hypothesis-based tests should continue to work in earlier versions of pytest, but enhanced integrations provided by the plugin (such as --hypothesis-show-statistics and other command-line flags) will no longer be available in obsolete pytest versions.
If you use pytest-html, Hypothesis now includes the summary statistics for each test in the HTML report, whether or not the --hypothesis-show-statisti
If you use pytest-html, Hypothesis now includes the summary statistics for each test in the HTML report, whether or not the --hypothesis-show-statistics argument was passed to show them in the command-line output.
This patch updates our automatic code formatting to use shed, which includes autoflake, black, isort, and pyupgrade (2780).
This patch updates our automatic code formatting to use shed, which includes autoflake, black, isort, and pyupgrade (2780).
This release teaches Hypothesis to distinguish between errors based on the __cause__ or __context__ of otherwise identical exceptions __, which is par
This release teaches Hypothesis to distinguish between errors based on the __cause__ or __context__ of otherwise identical exceptions, which is particularly useful when internal errors can be wrapped by a library-specific or semantically appropriate exception such as:
try:
do_the_thing(foo, timeout=10)
except Exception as err:
raise FooError("Failed to do the thing") from err
Earlier versions of Hypothesis only see the FooError, while we can now distinguish a FooError raised because of e.g. an internal assertion from one raised because of a TimeoutExceeded exception.
This release prevents a race condition inside ~hypothesis.strategies.recursive strategies. The race condition occurs when the same ~hypothesis.strateg
This release prevents a race condition inside ~hypothesis.strategies.recursive strategies. The race condition occurs when the same ~hypothesis.strategies.recursive strategy is shared among tests that are running in multiple threads (2717).
This release prevents a race condition inside recursive() strategies. The race condition occurs when the same recursive() strategy is shared among tests that are running in multiple threads ( issue #2717 ).
This patch improves the type annotations for ~hypothesis.strategies.one_of, by adding overloads to handle up to five distinct arguments as ~python:typ
This patch improves the type annotations for ~hypothesis.strategies.one_of, by adding overloads to handle up to five distinct arguments as ~python:typing.Union before falling back to ~python:typing.Any, as well as annotating the | (__or__) operator for strategies (2765).
This patch improves the type annotations for one_of() , by adding overloads to handle up to five distinct arguments as Union before falling back to Any , as well as annotating the | ( or ) operator for strategies ( issue #2765 ).
This release makes some small improvements to how filtered strategies work. It should improve the performance of shrinking filtered strategies, and ma
This release makes some small improvements to how filtered strategies work. It should improve the performance of shrinking filtered strategies, and may under some (probably rare) circumstances improve the diversity of generated examples.
This patch fixes an interaction where our test statistics handling made Pytest's --junit-xml output fail to validate against the strict xunit2 schema
This patch fixes an interaction where our test statistics handling made Pytest's --junit-xml output fail to validate against the strict xunit2 schema (1975).
There are no new features here, as we release those in minor versions. Instead, 6.0 is a chance for us to remove deprecated features (many already con…
Welcome to the next major version of Hypothesis!
There are no new features here, as we release those in minor versions. Instead, 6.0 is a chance for us to remove deprecated features (many already converted into no-ops), and turn a variety of warnings into errors.
If you were running on the last version of Hypothesis 5.x without any Hypothesis deprecation warnings, this will be a very boring upgrade. In fact, nothing will change for you at all.
Many functions now use 3102 keyword-only arguments where passing positional arguments was deprecated since 5.5.
hypothesis.extra.django.from_model no longer accepts model as a keyword argument, where it could conflict with fields named "model".
~hypothesis.strategies.randoms now defaults to use_true_random=False.
~hypothesis.strategies.complex_numbers no longer accepts min_magnitude=None; either use min_magnitude=0 or just omit the argument.
hypothesis.provisional.ip4_addr_strings and ip6_addr_strings are removed in favor of ip_addresses(v=...).map(str).
~hypothesis.strategies.register_type_strategy no longer accepts generic types with type arguments, which were always pretty badly broken.
Using function-scoped pytest fixtures is now a health-check error, instead of a warning.
Tip
The hypothesis codemod command can automatically refactor your code, particularly to convert positional to keyword arguments where those are now required.
This release adds the ~hypothesis.HealthCheck.function_scoped_fixture health check value, which can be used to suppress the existing warning that appe
This release adds the ~hypothesis.HealthCheck.function_scoped_fixture health check value, which can be used to suppress the existing warning that appears when @given is applied to a test that uses pytest function-scoped fixtures.
(This warning exists because function-scoped fixtures only run once per function, not once per example, which is usually unexpected and can cause subtle problems.)
When this warning becomes a health check error in a future release, suppressing it via Python warning settings will no longer be possible. In the rare case that once-per-function behaviour is intended, it will still be possible to use ~hypothesis.HealthCheck.function_scoped_fixture to opt out of the health check error for specific tests.
This release adds hypothesis.currently_in_test_context, which can be used to check whether the calling code is currently running inside an @given or s
This release adds hypothesis.currently_in_test_context, which can be used to check whether the calling code is currently running inside an @given or stateful test.
This is most useful for third-party integrations and assertion helpers which may wish to use ~hypothesis.assume or ~hypothesis.target, without also requiring that the helper only be used from property-based tests (2581).
This release upgrades the import logic for ghostwritten tests , handling many cases where imports would previously be missing or from unexpected locat
This release upgrades the import logic for ghostwritten tests, handling many cases where imports would previously be missing or from unexpected locations.
This release upgrades ~hypothesis.strategies.from_type, to infer strategies for type-annotated arguments even if they have defaults when it otherwise
This release upgrades ~hypothesis.strategies.from_type, to infer strategies for type-annotated arguments even if they have defaults when it otherwise falls back to ~hypothesis.strategies.builds (2708).
This release upgrades from_type() , to infer strategies for type-annotated arguments even if they have defaults when it otherwise falls back to builds() ( issue #2708 ).
This release adds the codemods extra, which you can use to check for and automatically fix issues such as use of deprecated Hypothesis APIs (2705).
This release adds the codemods extra, which you can use to check for and automatically fix issues such as use of deprecated Hypothesis APIs (2705).
This release adds the hypothesis[codemods] extra, which you can use to check for and automatically fix issues such as use of deprecated Hypothesis APIs ( issue #2705 ).
This patch fixes ~hypothesis.strategies.from_type with the typing-extensions Literal backport on Python 3.6.
This patch fixes ~hypothesis.strategies.from_type with the typing-extensions Literal backport on Python 3.6.
This patch fixes from_type() with the typing-extensions Literal backport on Python 3.6.
This patch fixes 2722, where certain orderings of ~hypothesis.strategies.register_type_strategy, ~python:typing.ForwardRef, and ~hypothesis.strategies
This patch fixes 2722, where certain orderings of ~hypothesis.strategies.register_type_strategy, ~python:typing.ForwardRef, and ~hypothesis.strategies.from_type could trigger an internal error.
This patch fixes issue #2722 , where certain orderings of register_type_strategy() , ForwardRef , and from_type() could trigger an internal error.
This patch makes some strategies for collections with a uniqueness constraint much more efficient, including dictionaries(keys=sampled_from(...), valu
This patch makes some strategies for collections with a uniqueness constraint much more efficient, including dictionaries(keys=sampled_from(...), values=..) and lists(tuples(sampled_from(...), ...), unique_by=lambda x: x[0]). (related to 2036)
This patch extends our faster special case for ~hypothesis.strategies.sampled_from elements in unique ~hypothesis.strategies.lists to account for chai
This patch extends our faster special case for ~hypothesis.strategies.sampled_from elements in unique ~hypothesis.strategies.lists to account for chains of .map(...) and .filter(...) calls (2036).
This patch extends our faster special case for sampled_from() elements in unique lists() to account for chains of .map(...) and .filter(...) calls ( issue #2036 ).
This patch improves the type annotations on ~hypothesis.assume and @reproduce_failure() .
This patch improves the type annotations on ~hypothesis.assume and @reproduce_failure().
This patch improves the type annotations on assume() and @reproduce_failure() .
This patch updates our copyright headers to include 2021. Happy new year!
This patch updates our copyright headers to include 2021. Happy new year!
This change fixes a documentation error in the ~hypothesis.settings.database setting.
This change fixes a documentation error in the ~hypothesis.settings.database setting.
The previous documentation suggested that callers could specify a database path string, or the special string ":memory:", but this setting has never actually allowed string arguments.
Permitted values are None, and instances of ~hypothesis.database.ExampleDatabase.
This patch fixes 2696, an internal error triggered when the @example decorator was used and the ~hypothesis.settings.verbosity setting was quiet.
This patch fixes 2696, an internal error triggered when the @example decorator was used and the ~hypothesis.settings.verbosity setting was quiet.
This patch fixes issue #2696 , an internal error triggered when the @example decorator was used and the verbosity setting was quiet .
This patch improves the error message from the ~hypothesis.extra.pandas.data_frames strategy when both the rows and columns arguments are given, but t
This patch improves the error message from the ~hypothesis.extra.pandas.data_frames strategy when both the rows and columns arguments are given, but there is a missing entry in rows and the corresponding column has no fill value (2678).
This patch improves the error message if ~hypothesis.strategies.builds is passed an ~python:enum.Enum which cannot be called without arguments, to sug
This patch improves the error message if ~hypothesis.strategies.builds is passed an ~python:enum.Enum which cannot be called without arguments, to suggest using ~hypothesis.strategies.sampled_from (2693).
This patch improves the error message if builds() is passed an Enum which cannot be called without arguments, to suggest using sampled_from() ( issue #2693 ).
This release adds new ~hypothesis.strategies.timezones and ~hypothesis.strategies.timezone_keys strategies (2630) based on the new python:zoneinfo mod
This release adds new ~hypothesis.strategies.timezones and ~hypothesis.strategies.timezone_keys strategies (2630) based on the new python:zoneinfo module in Python 3.9.
pip install hypothesis[zoneinfo] will ensure that you have the appropriate backports installed if you need them.
This release adds new timezones() and timezone_keys() strategies ( issue #2630 ) based on the new zoneinfo module in Python 3.9.
pip install hypothesis[zoneinfo] will ensure that you have the appropriate backports installed if you need them.
This patch fixes an internal error in ~hypothesis.strategies.datetimes with allow_imaginary=False where the timezones argument can generate tzinfo=Non
This patch fixes an internal error in ~hypothesis.strategies.datetimes with allow_imaginary=False where the timezones argument can generate tzinfo=None (2662).
This patch fixes an internal error in datetimes() with allow_imaginary=False where the timezones argument can generate tzinfo=None ( issue #2662 ).
This patch teaches hypothesis.extra.django.from_field to infer more efficient strategies by inspecting (not just filtering by) field validators for nu
This patch teaches hypothesis.extra.django.from_field to infer more efficient strategies by inspecting (not just filtering by) field validators for numeric and string fields (1116).
This patch refactors hypothesis.settings to use type-annotated keyword arguments instead of kwargs, which makes tab-completion much more useful - as w
This patch refactors hypothesis.settings to use type-annotated keyword arguments instead of **kwargs, which makes tab-completion much more useful - as well as type-checkers like mypy.
This patch teaches the ~hypothesis.extra.ghostwriter.magic ghostwriter to recognise "en/de" function roundtrips other than the common encode/decode pa
This patch teaches the ~hypothesis.extra.ghostwriter.magic ghostwriter to recognise "en/de" function roundtrips other than the common encode/decode pattern, such as encrypt/decrypt or, encipher/decipher.
This patch adds a performance optimisation to avoid saving redundant seeds when using the .fuzz_one_input hook .
This patch adds a performance optimisation to avoid saving redundant seeds when using the .fuzz_one_input hook.
This patch fixes 2657, where passing unicode patterns compiled with python:re.IGNORECASE to ~hypothesis.strategies.from_regex could trigger an interna
This patch fixes 2657, where passing unicode patterns compiled with python:re.IGNORECASE to ~hypothesis.strategies.from_regex could trigger an internal error when casefolding a character creates a longer string (e.g. "\u0130".lower() -> "i\u0370").
This patch fixes issue #2657 , where passing unicode patterns compiled with re.IGNORECASE to from_regex() could trigger an internal error when casefolding a character creates a longer string (e.g. "\u0130".lower() -> "i\u0370" ).
This patch adds a final fallback clause to our plugin logic to fail with a warning rather than error on Python < 3.8 when neither the importlib-metada
This patch adds a final fallback clause to our plugin logic to fail with a warning rather than error on Python < 3.8 when neither the importlib-metadata (preferred) or setuptools (fallback) packages are available.
This patch fixes ~hypothesis.provisional.urls strategy ensuring that ~ (tilde) is treated as one of the url-safe characters (2658).
This patch fixes ~hypothesis.provisional.urls strategy ensuring that ~ (tilde) is treated as one of the url-safe characters (2658).
This patch fixes urls() strategy ensuring that ~ (tilde) is treated as one of the url-safe characters ( issue #2658 ).
This patch improves our CLI help and documentation .
This patch improves our CLI help and documentation.
Hypothesis now shrinks examples where the error is raised while drawing from a strategy. This makes complicated custom strategies *much* easier to deb
Hypothesis now shrinks examples where the error is raised while drawing from a strategy. This makes complicated custom strategies much easier to debug, at the cost of a slowdown for use-cases where you catch and ignore such errors.
This release teaches ~hypothesis.strategies.from_type how to handle ~python:typing.ChainMap, ~python:typing.Counter, ~python:typing.Deque, ~python:typ
This release teaches ~hypothesis.strategies.from_type how to handle ~python:typing.ChainMap, ~python:typing.Counter, ~python:typing.Deque, ~python:typing.Generator, ~python:typing.Match, ~python:typing.OrderedDict, ~python:typing.Pattern, and ~python:collections.abc.Set (2654).
This release teaches from_type() how to handle ChainMap , Counter , Deque , Generator , Match , OrderedDict , Pattern , and Set ( issue #2654 ).
~hypothesis.strategies.from_type now knows how to resolve 585 parameterized standard collection types, which are new in Python 3.9 (2629).
~hypothesis.strategies.from_type now knows how to resolve 585 parameterized standard collection types, which are new in Python 3.9 (2629).
from_type() now knows how to resolve PEP 585 parameterized standard collection types, which are new in Python 3.9 ( issue #2629 ).
This patch fixes ~hypothesis.strategies.builds, so that when passed ~hypothesis.infer for an argument with a non-~python:typing.Optional type annotati
This patch fixes ~hypothesis.strategies.builds, so that when passed ~hypothesis.infer for an argument with a non-~python:typing.Optional type annotation and a default value of None to build a class which defines an explicit __signature__ attribute, either None or that type may be generated.
This is unlikely to happen unless you are using pydantic (2648).
This patch fixes builds() , so that when passed infer for an argument with a non- Optional type annotation and a default value of None to build a class which defines an explicit signature attribute, either None or that type may be generated.
This is unlikely to happen unless you are using pydantic ( issue #2648 ).
This release improves our support for @st.composite on a python:classmethod or python:staticmethod (2578).
This release improves our support for @st.composite on a python:classmethod or python:staticmethod (2578).
This release improves our support for @st.composite on a classmethod or staticmethod ( issue #2578 ).
This patch fixes ~hypothesis.strategies.from_type with Iterable[T] (2645).
This patch fixes ~hypothesis.strategies.from_type with Iterable[T] (2645).
This patch teaches the ~hypothesis.extra.ghostwriter.magic ghostwriter to recognise that pairs of functions like ~python:colorsys.rgb_to_hsv and ~pyth
This patch teaches the ~hypothesis.extra.ghostwriter.magic ghostwriter to recognise that pairs of functions like ~python:colorsys.rgb_to_hsv and ~python:colorsys.hsv_to_rgb should ~hypothesis.extra.ghostwriter.roundtrip.
This patch teaches the magic() ghostwriter to recognise that pairs of functions like rgb_to_hsv() and hsv_to_rgb() should roundtrip() .
This patch improves ~hypothesis.strategies.builds and ~hypothesis.strategies.from_type support for explicitly defined __signature__ attributes, from v
This patch improves ~hypothesis.strategies.builds and ~hypothesis.strategies.from_type support for explicitly defined __signature__ attributes, from version 5.8.3, to support generic types from the python:typing module.
Thanks to Rónán Carrigan for identifying and fixing this problem!
This patch improves builds() and from_type() support for explicitly defined signature attributes, from version 5.8.3 , to support generic types from the typing module.
Thanks to Rónán Carrigan for identifying and fixing this problem!
This patch fixes ~hypothesis.extra.lark.from_lark with version 0.10.1+ of the lark-parser package.
This patch fixes ~hypothesis.extra.lark.from_lark with version 0.10.1+ of the lark-parser package.
This patch fixes from_lark() with version 0.10.1+ of the lark-parser package.
This patch fixes some broken links in the ~hypothesis.extra.lark extra documentation.
This patch fixes some broken links in the ~hypothesis.extra.lark extra documentation.
This release adds a new ~hypothesis.extra.redis.RedisExampleDatabase, along with the ~hypothesis.database.ReadOnlyDatabase and ~hypothesis.database.Mu
This release adds a new ~hypothesis.extra.redis.RedisExampleDatabase, along with the ~hypothesis.database.ReadOnlyDatabase and ~hypothesis.database.MultiplexedDatabase helpers, to support team workflows where failing examples can be seamlessly shared between everyone on the team - and your CI servers or buildbots.
This release adds a new RedisExampleDatabase , along with the ReadOnlyDatabase and MultiplexedDatabase helpers, to support team workflows where failing examples can be seamlessly shared between everyone on the team - and your CI servers or buildbots.
One column per quarter.