aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-07-22 10:46:30 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-07-22 10:54:42 +0300
commit7a8bf49265109474e1529e1f9fb790e684a0771d (patch)
tree91857ad44d11d7b18e29b03d11229253de05cf05
parent909db7ce4fefbfe2687e8e7e3341f69def6b57d1 (diff)
downloadydb-7a8bf49265109474e1529e1f9fb790e684a0771d.tar.gz
Intermediate changes
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA10
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/core.py4
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py42
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py17
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py5
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
7 files changed, 65 insertions, 17 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 8ec8c1803d..8c732599ab 100644
--- a/contrib/python/hypothesis/py3/.dist-info/METADATA
+++ b/contrib/python/hypothesis/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: hypothesis
-Version: 6.105.0
+Version: 6.105.1
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
@@ -41,10 +41,10 @@ Requires-Dist: exceptiongroup >=1.0.0 ; python_version < "3.11"
Provides-Extra: all
Requires-Dist: black >=19.10b0 ; extra == 'all'
Requires-Dist: click >=7.0 ; extra == 'all'
-Requires-Dist: crosshair-tool >=0.0.58 ; extra == 'all'
+Requires-Dist: crosshair-tool >=0.0.59 ; extra == 'all'
Requires-Dist: django >=3.2 ; extra == 'all'
Requires-Dist: dpcontracts >=0.4 ; extra == 'all'
-Requires-Dist: hypothesis-crosshair >=0.0.6 ; extra == 'all'
+Requires-Dist: hypothesis-crosshair >=0.0.7 ; extra == 'all'
Requires-Dist: lark >=0.10.1 ; extra == 'all'
Requires-Dist: libcst >=0.3.16 ; extra == 'all'
Requires-Dist: numpy >=1.17.3 ; extra == 'all'
@@ -63,8 +63,8 @@ Requires-Dist: rich >=9.0.0 ; extra == 'cli'
Provides-Extra: codemods
Requires-Dist: libcst >=0.3.16 ; extra == 'codemods'
Provides-Extra: crosshair
-Requires-Dist: hypothesis-crosshair >=0.0.6 ; extra == 'crosshair'
-Requires-Dist: crosshair-tool >=0.0.58 ; extra == 'crosshair'
+Requires-Dist: hypothesis-crosshair >=0.0.7 ; extra == 'crosshair'
+Requires-Dist: crosshair-tool >=0.0.59 ; extra == 'crosshair'
Provides-Extra: dateutil
Requires-Dist: python-dateutil >=1.4 ; extra == 'dateutil'
Provides-Extra: django
diff --git a/contrib/python/hypothesis/py3/hypothesis/core.py b/contrib/python/hypothesis/py3/hypothesis/core.py
index 51710a2e1f..69593c463b 100644
--- a/contrib/python/hypothesis/py3/hypothesis/core.py
+++ b/contrib/python/hypothesis/py3/hypothesis/core.py
@@ -1119,6 +1119,10 @@ class StateForActualGivenExecution:
self.settings.backend != "hypothesis"
and not getattr(runner, "_switch_to_hypothesis_provider", False)
)
+ data._observability_args = data.provider.realize(
+ data._observability_args
+ )
+ self._string_repr = data.provider.realize(self._string_repr)
tc = make_testcase(
start_timestamp=self._start_timestamp,
test_name_or_nodeid=self.test_identifier,
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
index 960a61cc98..42ceead825 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
@@ -1206,19 +1206,35 @@ class PrimitiveProvider(abc.ABC):
# Non-hypothesis providers probably want to set a lifetime of test_function.
lifetime = "test_function"
+ # Solver-based backends such as hypothesis-crosshair use symbolic values
+ # which record operations performed on them in order to discover new paths.
+ # If avoid_realization is set to True, hypothesis will avoid interacting with
+ # ir values (symbolics) returned by the provider in any way that would force the
+ # solver to narrow the range of possible values for that symbolic.
+ #
+ # Setting this to True disables some hypothesis features, such as
+ # DataTree-based deduplication, and some internal optimizations, such as
+ # caching kwargs. Only enable this if it is necessary for your backend.
+ avoid_realization = False
+
def __init__(self, conjecturedata: Optional["ConjectureData"], /) -> None:
self._cd = conjecturedata
- def post_test_case_hook(self, value: IRType) -> IRType:
- # hook for providers to modify values returned by draw_* after a full
- # test case concludes. Originally exposed for crosshair to reify its
- # symbolic values into actual values.
- # I'm not tied to this exact function name or design.
- return value
-
def per_test_case_context_manager(self):
return contextlib.nullcontext()
+ def realize(self, value: T) -> T:
+ """
+ Called whenever hypothesis requires a concrete (non-symbolic) value from
+ a potentially symbolic value. Hypothesis will not check that `value` is
+ symbolic before calling `realize`, so you should handle the case where
+ `value` is non-symbolic.
+
+ The returned value should be non-symbolic.
+ """
+
+ return value
+
@abc.abstractmethod
def draw_boolean(
self,
@@ -1888,6 +1904,14 @@ AVAILABLE_PROVIDERS = {
}
+# eventually we'll want to expose this publicly, but for now it lives as psuedo-internal.
+def realize(value: object) -> object:
+ from hypothesis.control import current_build_context
+
+ context = current_build_context()
+ return context.data.provider.realize(value)
+
+
class ConjectureData:
@classmethod
def for_buffer(
@@ -2280,6 +2304,10 @@ class ConjectureData:
def _pooled_kwargs(self, ir_type, kwargs):
"""Memoize common dictionary objects to reduce memory pressure."""
+ # caching runs afoul of nondeterminism checks
+ if self.provider.avoid_realization:
+ return kwargs
+
key = []
for k, v in kwargs.items():
if ir_type == "float" and k in ["min_value", "max_value"]:
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
index b9914bd0dd..6e818f341a 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
@@ -30,6 +30,7 @@ from typing import (
Set,
Tuple,
Union,
+ cast,
overload,
)
@@ -56,6 +57,7 @@ from hypothesis.internal.conjecture.data import (
Example,
HypothesisProvider,
InterestingOrigin,
+ IRKWargsType,
IRNode,
Overrun,
PrimitiveProvider,
@@ -455,7 +457,7 @@ class ConjectureRunner:
self.stats_per_test_case.append(call_stats)
if self.settings.backend != "hypothesis":
for node in data.examples.ir_tree_nodes:
- value = data.provider.post_test_case_hook(node.value)
+ value = data.provider.realize(node.value)
expected_type = {
"string": str,
"float": float,
@@ -466,10 +468,19 @@ class ConjectureRunner:
if type(value) is not expected_type:
raise HypothesisException(
f"expected {expected_type} from "
- f"{data.provider.post_test_case_hook.__qualname__}, "
- f"got {type(value)} ({value!r})"
+ f"{data.provider.realize.__qualname__}, "
+ f"got {type(value)}"
)
+
+ kwargs = cast(
+ IRKWargsType,
+ {
+ k: data.provider.realize(v)
+ for k, v in node.kwargs.items()
+ },
+ )
node.value = value
+ node.kwargs = kwargs
self._cache(data)
if data.invalid_at is not None: # pragma: no branch # coverage bug?
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py
index 066c2b6581..d60eabea9b 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py
@@ -65,10 +65,15 @@ def clear_cache() -> None:
def cacheable(fn: "T") -> "T":
+ from hypothesis.control import _current_build_context
from hypothesis.strategies._internal.strategies import SearchStrategy
@proxies(fn)
def cached_strategy(*args, **kwargs):
+ context = _current_build_context.value
+ if context is not None and context.data.provider.avoid_realization:
+ return fn(*args, **kwargs)
+
try:
kwargs_cache_key = {(k, convert_value(v)) for k, v in kwargs.items()}
except TypeError:
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index d94d798ba2..1883646c33 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, 105, 0)
+__version_info__ = (6, 105, 1)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 648c900671..13e5954430 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.105.0)
+VERSION(6.105.1)
LICENSE(MPL-2.0)