aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-11-20 08:08:50 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-11-20 08:24:39 +0300
commite6c39085c1c04fab359caa62bbc06eb997dffada (patch)
treebef7b0b65cd4700bee74e1b5f81ed0c3d7601de9 /contrib/python/hypothesis
parent1fa9774315c17f89786264ccc693932a8c134bfa (diff)
downloadydb-e6c39085c1c04fab359caa62bbc06eb997dffada.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/__init__.py1
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/_error_if_old.py23
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/core.py18
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/scrutineer.py41
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/stateful.py2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py33
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make3
10 files changed, 70 insertions, 61 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index fea15f2238..c58ef1bbbe 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.88.1
+Version: 6.88.3
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
diff --git a/contrib/python/hypothesis/py3/hypothesis/__init__.py b/contrib/python/hypothesis/py3/hypothesis/__init__.py
index e8a3873140..db140b8165 100644
--- a/contrib/python/hypothesis/py3/hypothesis/__init__.py
+++ b/contrib/python/hypothesis/py3/hypothesis/__init__.py
@@ -15,7 +15,6 @@ It verifies your code against a wide range of input and minimizes any
failing examples it finds.
"""
-import hypothesis._error_if_old # noqa # imported for side-effect of nice error
from hypothesis._settings import HealthCheck, Phase, Verbosity, settings
from hypothesis.control import (
assume,
diff --git a/contrib/python/hypothesis/py3/hypothesis/_error_if_old.py b/contrib/python/hypothesis/py3/hypothesis/_error_if_old.py
deleted file mode 100644
index 7f0850892d..0000000000
--- a/contrib/python/hypothesis/py3/hypothesis/_error_if_old.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# This file is part of Hypothesis, which may be found at
-# https://github.com/HypothesisWorks/hypothesis/
-#
-# Copyright the Hypothesis Authors.
-# Individual contributors are listed in AUTHORS.rst and the git log.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public License,
-# 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/.
-
-import sys
-
-from hypothesis.version import __version__
-
-message = """
-Hypothesis {} requires Python 3.8 or later.
-
-This can only happen if your packaging toolchain is older than python_requires.
-See https://packaging.python.org/guides/distributing-packages-using-setuptools/
-"""
-
-if sys.version_info[:2] < (3, 8):
- raise Exception(message.format(__version__))
diff --git a/contrib/python/hypothesis/py3/hypothesis/core.py b/contrib/python/hypothesis/py3/hypothesis/core.py
index 72d73aadb7..74e363447c 100644
--- a/contrib/python/hypothesis/py3/hypothesis/core.py
+++ b/contrib/python/hypothesis/py3/hypothesis/core.py
@@ -910,20 +910,18 @@ class StateForActualGivenExecution:
and not self.failed_due_to_deadline
and Phase.shrink in self.settings.phases
and Phase.explain in self.settings.phases
- and sys.gettrace() is None
+ and (sys.gettrace() is None or sys.version_info[:2] >= (3, 12))
and not PYPY
): # pragma: no cover
# This is in fact covered by our *non-coverage* tests, but due to the
# settrace() contention *not* by our coverage tests. Ah well.
- tracer = Tracer()
- try:
- sys.settrace(tracer.trace)
- result = self.execute_once(data)
- if data.status == Status.VALID:
- self.explain_traces[None].add(frozenset(tracer.branches))
- finally:
- sys.settrace(None)
- trace = frozenset(tracer.branches)
+ with Tracer() as tracer:
+ try:
+ result = self.execute_once(data)
+ if data.status == Status.VALID:
+ self.explain_traces[None].add(frozenset(tracer.branches))
+ finally:
+ trace = frozenset(tracer.branches)
else:
result = self.execute_once(data)
if result is not None:
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/scrutineer.py b/contrib/python/hypothesis/py3/hypothesis/internal/scrutineer.py
index bf57728e45..5b372ffd65 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/scrutineer.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/scrutineer.py
@@ -9,6 +9,7 @@
# obtain one at https://mozilla.org/MPL/2.0/.
import sys
+import types
from collections import defaultdict
from functools import lru_cache, reduce
from os import sep
@@ -25,6 +26,15 @@ def should_trace_file(fname):
return not (is_hypothesis_file(fname) or fname.startswith("<"))
+# where possible, we'll use 3.12's new sys.monitoring module for low-overhead
+# coverage instrumentation; on older python versions we'll use sys.settrace.
+# tool_id = 1 is designated for coverage, but we intentionally choose a
+# non-reserved tool id so we can co-exist with coverage tools.
+MONITORING_TOOL_ID = 3
+if sys.version_info[:2] >= (3, 12):
+ MONITORING_EVENTS = {sys.monitoring.events.LINE: "trace_line"}
+
+
class Tracer:
"""A super-simple branch coverage tracer."""
@@ -38,12 +48,43 @@ class Tracer:
if event == "call":
return self.trace
elif event == "line":
+ # manual inlining of self.trace_line for performance.
fname = frame.f_code.co_filename
if should_trace_file(fname):
current_location = (fname, frame.f_lineno)
self.branches.add((self._previous_location, current_location))
self._previous_location = current_location
+ def trace_line(self, code: types.CodeType, line_number: int) -> None:
+ fname = code.co_filename
+ if should_trace_file(fname):
+ current_location = (fname, line_number)
+ self.branches.add((self._previous_location, current_location))
+ self._previous_location = current_location
+
+ def __enter__(self):
+ if sys.version_info[:2] < (3, 12):
+ assert sys.gettrace() is None # caller checks in core.py
+ sys.settrace(self.trace)
+ return self
+
+ sys.monitoring.use_tool_id(MONITORING_TOOL_ID, "scrutineer")
+ for event, callback_name in MONITORING_EVENTS.items():
+ sys.monitoring.set_events(MONITORING_TOOL_ID, event)
+ callback = getattr(self, callback_name)
+ sys.monitoring.register_callback(MONITORING_TOOL_ID, event, callback)
+
+ return self
+
+ def __exit__(self, *args, **kwargs):
+ if sys.version_info[:2] < (3, 12):
+ sys.settrace(None)
+ return
+
+ sys.monitoring.free_tool_id(MONITORING_TOOL_ID)
+ for event in MONITORING_EVENTS:
+ sys.monitoring.register_callback(MONITORING_TOOL_ID, event, None)
+
UNHELPFUL_LOCATIONS = (
# There's a branch which is only taken when an exception is active while exiting
diff --git a/contrib/python/hypothesis/py3/hypothesis/stateful.py b/contrib/python/hypothesis/py3/hypothesis/stateful.py
index a4017cc0d9..b827d50d2d 100644
--- a/contrib/python/hypothesis/py3/hypothesis/stateful.py
+++ b/contrib/python/hypothesis/py3/hypothesis/stateful.py
@@ -442,7 +442,7 @@ class BundleReferenceStrategy(SearchStrategy):
# end there can be a lot of hard to remove padding.
position = cu.integer_range(data, 0, len(bundle) - 1, center=len(bundle))
if self.consume:
- return bundle.pop(position)
+ return bundle.pop(position) # pragma: no cover # coverage is flaky here
else:
return bundle[position]
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
index 51185fb38f..9210f039d6 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
@@ -324,27 +324,12 @@ def _try_import_forward_ref(thing, bound): # pragma: no cover
def from_typing_type(thing):
- # We start with special-case support for Tuple, which isn't actually a generic
- # type; then Final, Literal, and Annotated since they don't support `isinstance`.
+ # We start with Final, Literal, and Annotated since they don't support `isinstance`.
#
# We then explicitly error on non-Generic types, which don't carry enough
# information to sensibly resolve to strategies at runtime.
# Finally, we run a variation of the subclass lookup in `st.from_type`
# among generic types in the lookup.
- if get_origin(thing) == tuple or isinstance(
- thing, getattr(typing, "TupleMeta", ())
- ):
- elem_types = getattr(thing, "__tuple_params__", None) or ()
- elem_types += getattr(thing, "__args__", None) or ()
- if (
- getattr(thing, "__tuple_use_ellipsis__", False)
- or len(elem_types) == 2
- and elem_types[-1] is Ellipsis
- ):
- return st.lists(st.from_type(elem_types[0])).map(tuple)
- elif len(elem_types) == 1 and elem_types[0] == ():
- return st.tuples() # Empty tuple; see issue #1583
- return st.tuples(*map(st.from_type, elem_types))
if get_origin(thing) == typing.Final:
return st.one_of([st.from_type(t) for t in thing.__args__])
if is_typing_literal(thing):
@@ -396,7 +381,11 @@ def from_typing_type(thing):
if len(mapping) > 1:
_Environ = getattr(os, "_Environ", None)
mapping.pop(_Environ, None)
- tuple_types = [t for t in mapping if isinstance(t, type) and issubclass(t, tuple)]
+ tuple_types = [
+ t
+ for t in mapping
+ if (isinstance(t, type) and issubclass(t, tuple)) or t is typing.Tuple
+ ]
if len(mapping) > len(tuple_types):
for tuple_type in tuple_types:
mapping.pop(tuple_type)
@@ -760,6 +749,16 @@ def resolve_List(thing):
return st.lists(st.from_type(thing.__args__[0]))
+@register(typing.Tuple, st.builds(tuple))
+def resolve_Tuple(thing):
+ elem_types = getattr(thing, "__args__", None) or ()
+ if len(elem_types) == 2 and elem_types[-1] is Ellipsis:
+ return st.lists(st.from_type(elem_types[0])).map(tuple)
+ elif len(elem_types) == 1 and elem_types[0] == ():
+ return st.tuples() # Empty tuple; see issue #1583
+ return st.tuples(*map(st.from_type, elem_types))
+
+
def _can_hash(val):
try:
hash(val)
diff --git a/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt b/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt
index 53f55386fa..f8890db8fe 100644
--- a/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt
+++ b/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt
@@ -1,4 +1,4 @@
-# Version 2023081200, Last Updated Sat Aug 12 07:07:01 2023 UTC
+# Version 2023110200, Last Updated Thu Nov 2 07:07:01 2023 UTC
AAA
AARP
ABB
@@ -213,7 +213,6 @@ CATHOLIC
CBA
CBN
CBRE
-CBS
CC
CD
CENTER
@@ -242,7 +241,6 @@ CITADEL
CITI
CITIC
CITY
-CITYEATS
CK
CL
CLAIMS
@@ -444,7 +442,6 @@ FREE
FRESENIUS
FRL
FROGANS
-FRONTDOOR
FRONTIER
FTR
FUJITSU
@@ -1060,7 +1057,6 @@ SHOP
SHOPPING
SHOUJI
SHOW
-SHOWTIME
SI
SILK
SINA
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index a28ac7bd63..1388e5b7b1 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, 88, 1)
+__version_info__ = (6, 88, 3)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index ba30680ab2..785cd29b78 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.88.1)
+VERSION(6.88.3)
LICENSE(MPL-2.0)
@@ -22,7 +22,6 @@ PY_SRCS(
_hypothesis_ftz_detector.py
_hypothesis_pytestplugin.py
hypothesis/__init__.py
- hypothesis/_error_if_old.py
hypothesis/_settings.py
hypothesis/configuration.py
hypothesis/control.py