diff options
| author | robot-piglet <[email protected]> | 2026-01-19 00:00:54 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-01-19 00:11:20 +0300 |
| commit | cae3f9f6576d6aa87791d2e22e045a050a1355d6 (patch) | |
| tree | 03f2c10ce10b20270e108314a49ccdfb0d270a2a /contrib/python/hypothesis/py3 | |
| parent | e82928ef7c266e68b2048122ce2f57e8ed8897f2 (diff) | |
Intermediate changes
commit_hash:edcb5a6f7829e68a74e542de2d3cdd437a1afbe4
Diffstat (limited to 'contrib/python/hypothesis/py3')
9 files changed, 39 insertions, 19 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA index 82a438e542b..4e971deb7c3 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.9 +Version: 6.148.11 Summary: The property-based testing library for Python Author-email: "David R. MacIver and Zac Hatfield-Dodds" <[email protected]> License-Expression: MPL-2.0 diff --git a/contrib/python/hypothesis/py3/hypothesis/core.py b/contrib/python/hypothesis/py3/hypothesis/core.py index 66fb9fcba1d..ba59d9e4b63 100644 --- a/contrib/python/hypothesis/py3/hypothesis/core.py +++ b/contrib/python/hypothesis/py3/hypothesis/core.py @@ -1566,8 +1566,8 @@ class StateForActualGivenExecution: # which is to be interpreted as "there are no more failures *other # than what we already reported*". Do not report this as unsound. unsound_backend=( - runner._verified_by - if runner._verified_by and not runner._backend_found_failure + runner._verified_by_backend + if runner._verified_by_backend and not runner._backend_found_failure else None ), ) diff --git a/contrib/python/hypothesis/py3/hypothesis/errors.py b/contrib/python/hypothesis/py3/hypothesis/errors.py index 6cfabe6db96..0e8fa889df8 100644 --- a/contrib/python/hypothesis/py3/hypothesis/errors.py +++ b/contrib/python/hypothesis/py3/hypothesis/errors.py @@ -290,6 +290,7 @@ class SmallSearchSpaceWarning(HypothesisWarning): CannotProceedScopeT = Literal["verified", "exhausted", "discard_test_case", "other"] +_valid_cannot_proceed_scopes = CannotProceedScopeT.__args__ # type: ignore class BackendCannotProceed(HypothesisException): @@ -317,4 +318,9 @@ class BackendCannotProceed(HypothesisException): """ def __init__(self, scope: CannotProceedScopeT = "other", /) -> None: + if scope not in _valid_cannot_proceed_scopes: + raise InvalidArgument( + f"Got scope={scope}, but expected one of " + f"{_valid_cannot_proceed_scopes!r}" + ) self.scope = scope diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py b/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py index e9aeb8cf693..ef793634e9a 100644 --- a/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py +++ b/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py @@ -491,11 +491,16 @@ def _get_params(func: Callable) -> dict[str, inspect.Parameter]: # we're out of ideas and should just re-raise the exception. raise else: - # If the params we got look like an uninformative placeholder, try fallbacks. P = inspect.Parameter placeholder = [("args", P.VAR_POSITIONAL), ("kwargs", P.VAR_KEYWORD)] - if [(p.name, p.kind) for p in params] == placeholder: - params = _get_params_ufunc(func) or _get_params_builtin_fn(func) or params + if ufunc_params := _get_params_ufunc(func): + # If func is a ufunc, prefer _get_params_ufunc over get_signature, + # as the latter includes keyword arguments we aren't well-equipped + # to ghostwrite. + params = ufunc_params + elif [(p.name, p.kind) for p in params] == placeholder: + # If the params we got look like an uninformative placeholder, try fallbacks. + params = _get_params_builtin_fn(func) or params return _params_to_dict(params) diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py b/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py index 64f381b0eab..e78b0dd15d2 100644 --- a/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py +++ b/contrib/python/hypothesis/py3/hypothesis/extra/numpy.py @@ -1433,7 +1433,9 @@ def _from_type(thing: type[Ex]) -> st.SearchStrategy[Ex] | None: st.recursive(st.tuples(base_strat, base_strat), st.tuples), ) - if origin in [np.ndarray, _SupportsArray]: + # note: get_origin(np.typing.NDArray[np.int64]) is np.ndarray in numpy < 2.5.0, + # but is np.typing.NDArray in numpy >= 2.5.0. Support both here. + if origin in [np.typing.NDArray, np.ndarray, _SupportsArray]: dtype = _dtype_from_args(args) return arrays(dtype, array_shapes(max_dims=2)) # type: ignore[return-value] diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py index 21ea97c7c5c..85b34f474fb 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py @@ -69,7 +69,7 @@ from hypothesis.internal.conjecture.shrinker import Shrinker, ShrinkPredicateT, 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 +from hypothesis.reporting import base_report, report, verbose_report # 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 @@ -353,11 +353,10 @@ class ConjectureRunner: self.__pending_call_explanation: str | None = None self._backend_found_failure: bool = False self._backend_exceeded_deadline: bool = False - self._switch_to_hypothesis_provider: bool = False - - self.__failed_realize_count: int = 0 + self._backend_discard_count: int = 0 # note unsound verification by alt backends - self._verified_by: str | None = None + self._verified_by_backend: str | None = None + self._switch_to_hypothesis_provider: bool = False @contextmanager def _with_switch_to_hypothesis_provider( @@ -531,13 +530,21 @@ class ConjectureRunner: if exc.scope in ("verified", "exhausted"): self._switch_to_hypothesis_provider = True if exc.scope == "verified": - self._verified_by = self.settings.backend + self._verified_by_backend = self.settings.backend elif exc.scope == "discard_test_case": - self.__failed_realize_count += 1 + self._backend_discard_count += 1 if ( - self.__failed_realize_count > 10 - and (self.__failed_realize_count / self.call_count) > 0.2 + self._backend_discard_count > 10 + and (self._backend_discard_count / self.call_count) > 0.2 ): + verbose_report( + f"Switching away from backend {self.settings.backend!r} " + "to the Hypothesis backend, " + f"because {self._backend_discard_count} of {self.call_count} " + "attempted test cases " + f"({self._backend_discard_count / self.call_count * 100:0.1f}%) " + f"were discarded by backend {self.settings.backend!r}" + ) self._switch_to_hypothesis_provider = True # treat all BackendCannotProceed exceptions as invalid. This isn't diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py index bd3be431a29..5f3069fd050 100644 --- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py +++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py @@ -1585,7 +1585,7 @@ def _from_type(thing: type[Ex]) -> SearchStrategy[Ex]: f"{from_type_repr} resolved to {builds_repr}, because we could not " "find any (non-varargs) arguments. Use st.register_type_strategy() " "to resolve to a strategy which can generate more than one value, " - "or silence this warning.", + "or to silence this warning.", SmallSearchSpaceWarning, stacklevel=2, ) diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py index a85a584f267..af13b6ffa0e 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, 9) +__version_info__ = (6, 148, 11) __version__ = ".".join(map(str, __version_info__)) diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make index 94e9856d5e7..ed161e27502 100644 --- a/contrib/python/hypothesis/py3/ya.make +++ b/contrib/python/hypothesis/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(6.148.9) +VERSION(6.148.11) LICENSE(MPL-2.0) |
