Hypothesis

Latest version: v6.122.3

Safety actively analyzes 688587 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 103 of 210

5.1.3

Not secure
------------------

This release converts the type hint comments on our public API to
:pep:`484` type annotations.

Thanks to Ivan Levkivskyi for :pypi:`com2ann` - with the refactoring
tools from :ref:`5.0.1 <v5.0.1>` it made this process remarkably easy!

5.1.2

Not secure
------------------

This patch makes :func:`~hypothesis.stateful.multiple` iterable, so that
output like ``a, b = state.some_rule()`` is actually executable and
can be used to reproduce failing examples.

Thanks to Vincent Michel for reporting and fixing :issue:`2311`!

5.1.1

Not secure
------------------

This patch contains many small refactorings to replace our Python 2
compatibility functions with their native Python 3 equivalents.
Since Hypothesis is now Python 3 only, there is no user-visible change.

5.1.0

Not secure
------------------

This release teaches :func:`~hypothesis.strategies.from_type` how to generate
:class:`python:datetime.timezone`. As a result, you can now generate
:class:`python:datetime.tzinfo` objects without having :pypi:`pytz` installed.

If your tests specifically require :pypi:`pytz` timezones, you should be using
:func:`hypothesis.extra.pytz.timezones` instead of ``st.from_type(tzinfo)``.

5.0.1

Not secure
------------------

This patch contains mostly-automated refactorings to remove code
that we only needed to support Python 2. Since Hypothesis is now
Python 3 only (hurray!), there is no user-visible change.

Our sincere thanks to the authors of :pypi:`autoflake`, :pypi:`black`,
:pypi:`isort`, and :pypi:`pyupgrade`, who have each and collectively
made this kind of update enormously easier.

5.0.0

Not secure
------------------

Welcome to the next major version of Hypothesis!

There are no new features here, as we release those in minor versions.
Instead, 5.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 4.x *without any
Hypothesis deprecation warnings*, this will be a very boring upgrade.
**In fact, nothing will change for you at all.**

.. note::
This release drops support for Python 2, which has passed
`its end of life date <https://devguide.python.org/#status-of-python-branches>`__.
The `Python 3 Statement <https://python3statement.github.io>`__ outlines our
reasons, and lists many other packages that have made the same decision.

``pip install hypothesis`` should continue to give you the latest compatible version.
If you have somehow ended up with Hypothesis 5.0 on Python 2, you need to update your
packaging stack to ``pip >= 9.0`` and ``setuptools >= 24.2`` - see `here for details
<https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires>`__.
Then ``pip uninstall hypothesis && pip install hypothesis`` will get you back to
a compatible version.


Strategies
~~~~~~~~~~
- :func:`~hypothesis.strategies.integers` bounds must be equal to an integer,
though they can still be other types.
- If :func:`~hypothesis.strategies.fractions` is passed a ``max_denominator``,
the bounds must have at most that denominator.
- :func:`~hypothesis.strategies.floats` bounds must be exactly representable as a
floating-point number with the given ``width``. If not, the error message
includes the nearest such number.
- :func:`sampled_from([]) <hypothesis.strategies.sampled_from>` is now an error.
- The values from the ``elements`` and ``fill`` strategies for
:func:`hypothesis.extra.numpy.arrays` must be losslessly representable in an
array of the given dtype.
- The ``min_size`` and ``max_size`` arguments to all collection strategies must
be of type :class:`python:int` (or ``max_size`` may be ``None``).

Miscellaneous
~~~~~~~~~~~~~
- The ``.example()`` method of strategies (intended for interactive
exploration) no longer takes a ``random`` argument.
- It is now an error to apply :obj:`example <hypothesis.example>`,
:func:`seed <hypothesis.seed>`, or :func:`reproduce_failure <hypothesis.reproduce_failure>`
without also applying :func:`given <hypothesis.given>`.
- You may pass either the ``target`` or ``targets`` argument to stateful rules, but not both.
- :obj:`~hypothesis.settings.deadline` must be ``None`` (to disable), a
:class:`~python:datetime.timedelta`, or an integer or float number of milliseconds.
- Both of :obj:`~hypothesis.settings.derandomize` and
:obj:`~hypothesis.settings.print_blob` must be either ``True`` or ``False``,
where they previously accepted other values.
- :obj:`~hypothesis.settings.stateful_step_count` must be at least one.
- :obj:`~hypothesis.settings.max_examples` must be at least one.
To disable example generation, use the :obj:`~hypothesis.settings.phases` setting.

Removals
~~~~~~~~
- ``hypothesis.stateful.GenericStateMachine`` in favor of :class:`hypothesis.stateful.RuleBasedStateMachine`
- ``hypothesis.extra.django.models.models`` in favor of :func:`hypothesis.extra.django.from_model`
and ``hypothesis.extra.django.models.add_default_field_mapping`` in favor of
:func:`hypothesis.extra.django.register_field_strategy`
- ``hypothesis.HealthCheck.hung_test``, without replacement
- ``hypothesis.settings.buffer``, without replacement
- ``hypothesis.PrintSettings``, because :obj:`hypothesis.settings.print_blob` takes ``True`` or ``False``
- ``hypothesis.settings.timeout``, in favor of :obj:`hypothesis.settings.deadline`
- ``hypothesis.unlimited`` without replacement (only only useful as argument to ``timeout``)

Hypothesis 4.x
==============

Page 103 of 210

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.