summaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-02-11 10:55:54 +0300
committerrobot-piglet <[email protected]>2026-02-11 11:24:08 +0300
commit9b5f29efa00bba424cd32471a95ececc583fe046 (patch)
tree58936c6fc2147c49fc2a4aec657f63fb6f789336 /contrib/python/hypothesis
parentdf75a44af0e3c0cfce907e22f61d6c91fc3bbc39 (diff)
Intermediate changes
commit_hash:721c786fcb8a37574bec0881ae2194859f790fae
Diffstat (limited to 'contrib/python/hypothesis')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/database.py6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py102
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/providers.py2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
6 files changed, 66 insertions, 54 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 9b0ea14cc8e..fefdd240c7d 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.151.0
+Version: 6.151.2
Summary: The property-based testing library for Python
Author-email: "David R. MacIver and Zac Hatfield-Dodds" <[email protected]>
License-Expression: MPL-2.0
@@ -61,7 +61,7 @@ Provides-Extra: redis
Requires-Dist: redis>=3.0.0; extra == "redis"
Provides-Extra: crosshair
Requires-Dist: hypothesis-crosshair>=0.0.27; extra == "crosshair"
-Requires-Dist: crosshair-tool>=0.0.101; extra == "crosshair"
+Requires-Dist: crosshair-tool>=0.0.102; extra == "crosshair"
Provides-Extra: zoneinfo
Requires-Dist: tzdata>=2025.3; (sys_platform == "win32" or sys_platform == "emscripten") and extra == "zoneinfo"
Provides-Extra: django
@@ -71,7 +71,7 @@ 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.101; extra == "all"
+Requires-Dist: crosshair-tool>=0.0.102; extra == "all"
Requires-Dist: django>=4.2; extra == "all"
Requires-Dist: dpcontracts>=0.4; extra == "all"
Requires-Dist: hypothesis-crosshair>=0.0.27; extra == "all"
diff --git a/contrib/python/hypothesis/py3/hypothesis/database.py b/contrib/python/hypothesis/py3/hypothesis/database.py
index 4fbddd29021..eae2f579cb0 100644
--- a/contrib/python/hypothesis/py3/hypothesis/database.py
+++ b/contrib/python/hypothesis/py3/hypothesis/database.py
@@ -580,7 +580,9 @@ class DirectoryBasedExampleDatabase(ExampleDatabase):
_metakeys_hash = self._metakeys_hash
_broadcast_change = self._broadcast_change
- class Handler(FileSystemEventHandler):
+ class Handler(
+ FileSystemEventHandler
+ ): # pragma: no cover # skipped in test_database.py for now
def on_created(_self, event: FileCreatedEvent | DirCreatedEvent) -> None:
# we only registered for the file creation event
assert not isinstance(event, DirCreatedEvent)
@@ -1274,7 +1276,7 @@ def _choices_from_bytes(buffer: bytes, /) -> tuple[ChoiceT, ...]:
parts.append(bool(size))
continue
if size == 0b11111:
- (offset, size) = _unpack_uleb128(buffer[idx:])
+ offset, size = _unpack_uleb128(buffer[idx:])
idx += offset
chunk = buffer[idx : idx + size]
idx += size
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
index 531797c7ab0..22a0e7ec8f7 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
@@ -9,13 +9,12 @@
# obtain one at https://mozilla.org/MPL/2.0/.
import importlib
-import inspect
import math
import threading
import time
from collections import defaultdict
from collections.abc import Callable, Generator, Sequence
-from contextlib import AbstractContextManager, contextmanager, nullcontext, suppress
+from contextlib import AbstractContextManager, contextmanager, nullcontext
from dataclasses import dataclass, field
from datetime import timedelta
from enum import Enum
@@ -70,7 +69,6 @@ from hypothesis.internal.escalation import InterestingOrigin
from hypothesis.internal.healthcheck import fail_health_check
from hypothesis.internal.observability import Observation, with_observability_callback
from hypothesis.reporting import base_report, report, verbose_report
-from hypothesis.utils.deprecation import note_deprecation
# In most cases, the following constants are all Final. However, we do allow users
# to monkeypatch all of these variables, which means we cannot annotate them as
@@ -241,24 +239,8 @@ class DiscardObserver(DataObserver):
def realize_choices(data: ConjectureData, *, for_failure: bool) -> None:
- # backwards-compatibility with backends without for_failure, can remove
- # in a few months
- kwargs = {}
- if for_failure:
- if "for_failure" in inspect.signature(data.provider.realize).parameters:
- kwargs["for_failure"] = True
- else:
- note_deprecation(
- f"{type(data.provider).__qualname__}.realize does not have the "
- "for_failure parameter. This will be an error in future versions "
- "of Hypothesis. (If you installed this backend from a separate "
- "package, upgrading that package may help).",
- has_codemod=False,
- since="2025-05-07",
- )
-
for node in data.nodes:
- value = data.provider.realize(node.value, **kwargs)
+ value = data.provider.realize(node.value, for_failure=for_failure)
expected_type = {
"string": str,
"float": float,
@@ -275,7 +257,7 @@ def realize_choices(data: ConjectureData, *, for_failure: bool) -> None:
constraints = cast(
ChoiceConstraintsT,
{
- k: data.provider.realize(v, **kwargs)
+ k: data.provider.realize(v, for_failure=for_failure)
for k, v in node.constraints.items()
},
)
@@ -522,12 +504,9 @@ class ConjectureRunner:
self.call_count += 1
interrupted = False
- try:
- self.__stoppable_test_function(data)
- except KeyboardInterrupt:
- interrupted = True
- raise
- except BackendCannotProceed as exc:
+ def _backend_cannot_proceed(
+ exc: BackendCannotProceed, data: ConjectureData
+ ) -> None:
if exc.scope in ("verified", "exhausted"):
self._switch_to_hypothesis_provider = True
if exc.scope == "verified":
@@ -553,16 +532,35 @@ class ConjectureRunner:
# But we check self.valid_examples == 0 to determine whether to raise
# Unsatisfiable, and that would throw this check off.
self.invalid_examples += 1
+ data.cannot_proceed_scope = exc.scope
+ # this fiddly bit of control flow is to work around `return` being
+ # disallowed in `finally` blocks as of python 3.14. Otherwise, we would
+ # just return in the _backend_cannot_proceed branch.
+ finally_early_return = False
+
+ try:
+ self.__stoppable_test_function(data)
+ except KeyboardInterrupt:
+ interrupted = True
+ raise
+ except BackendCannotProceed as exc:
+ _backend_cannot_proceed(exc, data)
# skip the post-test-case tracking; we're pretending this never happened
interrupted = True
- data.cannot_proceed_scope = exc.scope
data.freeze()
return
except BaseException:
data.freeze()
if self.settings.backend != "hypothesis":
- realize_choices(data, for_failure=True)
+ try:
+ realize_choices(data, for_failure=True)
+ except BackendCannotProceed as exc:
+ _backend_cannot_proceed(exc, data)
+ # skip the post-test-case tracking; we're pretending this
+ # never happened
+ interrupted = True
+ return
self.save_choices(data.choices)
raise
finally:
@@ -573,22 +571,35 @@ class ConjectureRunner:
data.freeze()
if self.settings.backend != "hypothesis":
- realize_choices(data, for_failure=data.status is Status.INTERESTING)
+ try:
+ realize_choices(
+ data, for_failure=data.status is Status.INTERESTING
+ )
+ except BackendCannotProceed as exc:
+ _backend_cannot_proceed(exc, data)
+ finally_early_return = True
- call_stats: CallStats = {
- "status": data.status.name.lower(),
- "runtime": data.finish_time - data.start_time,
- "drawtime": math.fsum(data.draw_times.values()),
- "gctime": data.gc_finish_time - data.gc_start_time,
- "events": sorted(
- k if v == "" else f"{k}: {v}" for k, v in data.events.items()
- ),
- }
- self.stats_per_test_case.append(call_stats)
+ if not finally_early_return:
+ call_stats: CallStats = {
+ "status": data.status.name.lower(),
+ "runtime": data.finish_time - data.start_time,
+ "drawtime": math.fsum(data.draw_times.values()),
+ "gctime": data.gc_finish_time - data.gc_start_time,
+ "events": sorted(
+ k if v == "" else f"{k}: {v}"
+ for k, v in data.events.items()
+ ),
+ }
+ self.stats_per_test_case.append(call_stats)
- self._cache(data)
- if data.misaligned_at is not None: # pragma: no branch # coverage bug?
- self.misaligned_count += 1
+ self._cache(data)
+ if (
+ data.misaligned_at is not None
+ ): # pragma: no branch # coverage bug?
+ self.misaligned_count += 1
+
+ if finally_early_return:
+ return
self.debug_data(data)
@@ -1214,8 +1225,7 @@ class ConjectureRunner:
# a novel prefix, ask the backend for an input.
if not self.using_hypothesis_backend:
data = self.new_conjecture_data([])
- with suppress(BackendCannotProceed):
- self.test_function(data)
+ self.test_function(data)
continue
self._current_phase = "generate"
@@ -1409,7 +1419,7 @@ class ConjectureRunner:
# case (1): duplicate the choices in start1:start2.
attempt = data.choices[:start2] + data.choices[start1:]
else:
- (start, end) = self.random.choice([(start1, end1), (start2, end2)])
+ start, end = self.random.choice([(start1, end1), (start2, end2)])
replacement = data.choices[start:end]
# We attempt to replace both the examples with
# whichever choice we made. Note that this might end
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/providers.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/providers.py
index 14064ed985e..f8e51a5d5d4 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/providers.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/providers.py
@@ -755,7 +755,7 @@ class HypothesisProvider(PrimitiveProvider):
# split constants into two pools, so we still have a good chance to draw
# global constants even if there are many local constants.
- (global_constants, local_constants) = CONSTANTS_CACHE[key]
+ global_constants, local_constants = CONSTANTS_CACHE[key]
constants_lists = ([global_constants] if global_constants else []) + (
[local_constants] if local_constants else []
)
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index ccf10bfaaa6..a6c6132bb7b 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, 151, 0)
+__version_info__ = (6, 151, 2)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 60d4b15be6b..422507d0d73 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.151.0)
+VERSION(6.151.2)
LICENSE(MPL-2.0)