diff options
| author | robot-piglet <[email protected]> | 2025-12-16 13:56:34 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2025-12-16 14:19:15 +0300 |
| commit | 5d5ed092a63ec79ee5f56a015d75daf6de5bfeef (patch) | |
| tree | 3769d35fb64257d5d25d423633cb8f48d4d42007 /contrib/python | |
| parent | ab5e2ddaa96b3f6681fb3187c509872a2c7c5819 (diff) | |
Intermediate changes
commit_hash:01073d5debabb2b7da51639f6d5137155132d193
Diffstat (limited to 'contrib/python')
7 files changed, 107 insertions, 14 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA index 671b206e703..bdce51b3b1b 100644 --- a/contrib/python/hypothesis/py3/.dist-info/METADATA +++ b/contrib/python/hypothesis/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: hypothesis -Version: 6.148.3 +Version: 6.148.5 Summary: The property-based testing library for Python Author-email: "David R. MacIver and Zac Hatfield-Dodds" <[email protected]> License-Expression: MPL-2.0 @@ -60,8 +60,8 @@ Requires-Dist: dpcontracts>=0.4; extra == "dpcontracts" Provides-Extra: redis Requires-Dist: redis>=3.0.0; extra == "redis" Provides-Extra: crosshair -Requires-Dist: hypothesis-crosshair>=0.0.25; extra == "crosshair" -Requires-Dist: crosshair-tool>=0.0.97; extra == "crosshair" +Requires-Dist: hypothesis-crosshair>=0.0.26; extra == "crosshair" +Requires-Dist: crosshair-tool>=0.0.98; extra == "crosshair" Provides-Extra: zoneinfo Requires-Dist: tzdata>=2025.2; (sys_platform == "win32" or sys_platform == "emscripten") and extra == "zoneinfo" Provides-Extra: django @@ -71,10 +71,10 @@ Requires-Dist: watchdog>=4.0.0; extra == "watchdog" Provides-Extra: all Requires-Dist: black>=20.8b0; extra == "all" Requires-Dist: click>=7.0; extra == "all" -Requires-Dist: crosshair-tool>=0.0.97; extra == "all" +Requires-Dist: crosshair-tool>=0.0.98; extra == "all" Requires-Dist: django>=4.2; extra == "all" Requires-Dist: dpcontracts>=0.4; extra == "all" -Requires-Dist: hypothesis-crosshair>=0.0.25; extra == "all" +Requires-Dist: hypothesis-crosshair>=0.0.26; extra == "all" Requires-Dist: lark>=0.10.1; extra == "all" Requires-Dist: libcst>=0.3.16; extra == "all" Requires-Dist: numpy>=1.21.6; extra == "all" diff --git a/contrib/python/hypothesis/py3/hypothesis/control.py b/contrib/python/hypothesis/py3/hypothesis/control.py index ac8a3c48fb3..e08da3a5a57 100644 --- a/contrib/python/hypothesis/py3/hypothesis/control.py +++ b/contrib/python/hypothesis/py3/hypothesis/control.py @@ -14,7 +14,7 @@ import random from collections import defaultdict from collections.abc import Callable, Sequence from contextlib import contextmanager -from typing import Any, NoReturn, Optional +from typing import Any, Literal, NoReturn, Optional, overload from weakref import WeakKeyDictionary from hypothesis import Verbosity, settings @@ -49,7 +49,13 @@ def reject() -> NoReturn: raise UnsatisfiedAssumption(where) -def assume(condition: object) -> bool: +@overload +def assume(condition: Literal[False] | None) -> NoReturn: ... +@overload +def assume(condition: object) -> Literal[True]: ... + + +def assume(condition: object) -> Literal[True]: """Calling ``assume`` is like an :ref:`assert <python:assert>` that marks the example as bad, rather than failing the test. diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/_array_helpers.py b/contrib/python/hypothesis/py3/hypothesis/extra/_array_helpers.py index 67d22fa25a6..c688bc55089 100644 --- a/contrib/python/hypothesis/py3/hypothesis/extra/_array_helpers.py +++ b/contrib/python/hypothesis/py3/hypothesis/extra/_array_helpers.py @@ -22,11 +22,15 @@ from hypothesis.utils.conventions import UniqueIdentifier, not_set __all__ = [ "NDIM_MAX", + "_BIE", "BasicIndex", "BasicIndexStrategy", "BroadcastableShapes", "MutuallyBroadcastableShapesStrategy", "Shape", + "_BIENoEllipsis", + "_BIENoEllipsisNoNewaxis", + "_BIENoNewaxis", "array_shapes", "broadcastable_shapes", "check_argument", @@ -38,7 +42,15 @@ __all__ = [ Shape = tuple[int, ...] -BasicIndex = tuple[int | slice | None | EllipsisType, ...] + +# Type aliases for basic array index elements. Variants exist to accurately +# type the return value of basic_indices() based on allow_ellipsis/allow_newaxis. +_BIE = int | slice | None | EllipsisType +_BIENoEllipsis = int | slice | None +_BIENoNewaxis = int | slice | EllipsisType +_BIENoEllipsisNoNewaxis = int | slice + +BasicIndex = _BIE | tuple[_BIE, ...] class BroadcastableShapes(NamedTuple): diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py b/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py index 43380e28732..64f381b0eab 100644 --- a/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py +++ b/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py @@ -30,11 +30,15 @@ from hypothesis import strategies as st from hypothesis._settings import note_deprecation from hypothesis.errors import HypothesisException, InvalidArgument from hypothesis.extra._array_helpers import ( + _BIE, NDIM_MAX, BasicIndex, BasicIndexStrategy, BroadcastableShapes, Shape, + _BIENoEllipsis, + _BIENoEllipsisNoNewaxis, + _BIENoNewaxis, array_shapes, broadcastable_shapes, check_argument, @@ -1092,6 +1096,52 @@ mutually_broadcastable_shapes.__doc__ = f""" """ +@overload +def basic_indices( + shape: Shape, + *, + min_dims: int = 0, + max_dims: int | None = None, + allow_newaxis: Literal[False] = ..., + allow_ellipsis: Literal[False], +) -> st.SearchStrategy[ + _BIENoEllipsisNoNewaxis | tuple[_BIENoEllipsisNoNewaxis, ...] +]: ... + + +@overload +def basic_indices( + shape: Shape, + *, + min_dims: int = 0, + max_dims: int | None = None, + allow_newaxis: Literal[False] = ..., + allow_ellipsis: Literal[True] = ..., +) -> st.SearchStrategy[_BIENoNewaxis | tuple[_BIENoNewaxis, ...]]: ... + + +@overload +def basic_indices( + shape: Shape, + *, + min_dims: int = 0, + max_dims: int | None = None, + allow_newaxis: Literal[True], + allow_ellipsis: Literal[False], +) -> st.SearchStrategy[_BIENoEllipsis | tuple[_BIENoEllipsis, ...]]: ... + + +@overload +def basic_indices( + shape: Shape, + *, + min_dims: int = 0, + max_dims: int | None = None, + allow_newaxis: Literal[True], + allow_ellipsis: Literal[True] = ..., +) -> st.SearchStrategy[_BIE | tuple[_BIE, ...]]: ... + + @defines_strategy() def basic_indices( shape: Shape, diff --git a/contrib/python/hypothesis/py3/hypothesis/stateful.py b/contrib/python/hypothesis/py3/hypothesis/stateful.py index 185b71d9ad6..8026d2d1672 100644 --- a/contrib/python/hypothesis/py3/hypothesis/stateful.py +++ b/contrib/python/hypothesis/py3/hypothesis/stateful.py @@ -15,6 +15,7 @@ a single value. Notably, the set of steps available at any point may depend on the execution to date. """ + import collections import dataclasses import inspect @@ -35,7 +36,11 @@ from hypothesis._settings import ( ) from hypothesis.control import _current_build_context, current_build_context from hypothesis.core import TestFunc, given -from hypothesis.errors import InvalidArgument, InvalidDefinition +from hypothesis.errors import ( + FlakyStrategyDefinition, + InvalidArgument, + InvalidDefinition, +) from hypothesis.internal.compat import add_note, batched from hypothesis.internal.conjecture.engine import BUFFER_SIZE from hypothesis.internal.conjecture.junkdrawer import gc_cumulative_time @@ -95,7 +100,11 @@ class TestCaseProperty: # pragma: no cover raise AttributeError("Cannot delete TestCase") -def get_state_machine_test(state_machine_factory, *, settings=None, _min_steps=0): +def get_state_machine_test( + state_machine_factory, *, settings=None, _min_steps=0, _flaky_state=None +): + # This function is split out from run_state_machine_as_test so that + # HypoFuzz can get and call the test function directly. if settings is None: try: settings = state_machine_factory.TestCase.settings @@ -108,6 +117,7 @@ def get_state_machine_test(state_machine_factory, *, settings=None, _min_steps=0 # Because settings can vary via e.g. profiles, settings.stateful_step_count # overrides this argument and we don't bother cross-validating. raise InvalidArgument(f"_min_steps={_min_steps} must be non-negative.") + _flaky_state = _flaky_state or {} @settings @given(st.data()) @@ -161,6 +171,7 @@ def get_state_machine_test(state_machine_factory, *, settings=None, _min_steps=0 # Choose a rule to run, preferring an initialize rule if there are # any which have not been run yet. + _flaky_state["selecting_rule"] = True if machine._initialize_rules_to_run: init_rules = [ st.tuples(st.just(rule), st.fixed_dictionaries(rule.arguments)) @@ -170,6 +181,7 @@ def get_state_machine_test(state_machine_factory, *, settings=None, _min_steps=0 machine._initialize_rules_to_run.remove(rule) else: rule, data = cd.draw(machine._rules_strategy) + _flaky_state["selecting_rule"] = False draw_label = f"generate:rule:{rule.function.__name__}" cd.draw_times.setdefault(draw_label, 0.0) in_gctime = gc_cumulative_time() - start_gc @@ -250,10 +262,23 @@ def run_state_machine_as_test(state_machine_factory, *, settings=None, _min_step RuleBasedStateMachine when called with no arguments - it can be a class or a function. settings will be used to control the execution of the test. """ + flaky_state = {"selecting_rule": False} state_machine_test = get_state_machine_test( - state_machine_factory, settings=settings, _min_steps=_min_steps + state_machine_factory, + settings=settings, + _min_steps=_min_steps, + _flaky_state=flaky_state, ) - state_machine_test() + try: + state_machine_test() + except FlakyStrategyDefinition as err: + if flaky_state["selecting_rule"]: + add_note( + err, + "while selecting a rule to run. This is usually caused by " + "a flaky precondition, or a bundle that was unexpectedly empty.", + ) + raise class StateMachineMeta(type): diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py index 1b08ee8bf45..575a16dbe7a 100644 --- a/contrib/python/hypothesis/py3/hypothesis/version.py +++ b/contrib/python/hypothesis/py3/hypothesis/version.py @@ -8,5 +8,5 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at https://mozilla.org/MPL/2.0/. -__version_info__ = (6, 148, 3) +__version_info__ = (6, 148, 5) __version__ = ".".join(map(str, __version_info__)) diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make index 418f430ae2a..0e1c9af46c1 100644 --- a/contrib/python/hypothesis/py3/ya.make +++ b/contrib/python/hypothesis/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(6.148.3) +VERSION(6.148.5) LICENSE(MPL-2.0) |
