Browse Source

Intermediate changes

robot-piglet 1 year ago
parent
commit
6e1358a430

+ 1 - 1
contrib/python/hypothesis/py3/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: hypothesis
-Version: 6.92.8
+Version: 6.92.9
 Summary: A library for property-based testing
 Home-page: https://hypothesis.works
 Author: David R. MacIver and Zac Hatfield-Dodds

+ 8 - 0
contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py

@@ -30,6 +30,7 @@ from typing import (
     Set,
     Tuple,
     Type,
+    TypeVar,
     Union,
 )
 
@@ -88,6 +89,8 @@ InterestingOrigin = Tuple[
 ]
 TargetObservations = Dict[Optional[str], Union[int, float]]
 
+T = TypeVar("T")
+
 
 class ExtraInformation:
     """A class for holding shared state on a ``ConjectureData`` that should
@@ -1719,6 +1722,11 @@ class ConjectureData:
         self.buffer = bytes(self.buffer)
         self.observer.conclude_test(self.status, self.interesting_origin)
 
+    def choice(self, values: Sequence[T], *, forced: Optional[T] = None) -> T:
+        forced_i = None if forced is None else values.index(forced)
+        i = self.draw_integer(0, len(values) - 1, forced=forced_i)
+        return values[i]
+
     def draw_bits(self, n: int, *, forced: Optional[int] = None) -> int:
         """Return an ``n``-bit integer from the underlying source of
         bytes. If ``forced`` is set to an integer will instead

+ 2 - 10
contrib/python/hypothesis/py3/hypothesis/internal/conjecture/utils.py

@@ -81,14 +81,6 @@ def check_sample(
     return tuple(values)
 
 
-def choice(
-    data: "ConjectureData", values: Sequence[T], *, forced: Optional[T] = None
-) -> T:
-    forced_i = None if forced is None else values.index(forced)
-    i = data.draw_integer(0, len(values) - 1, forced=forced_i)
-    return values[i]
-
-
 class Sampler:
     """Sampler based on Vose's algorithm for the alias method. See
     http://www.keithschwarz.com/darts-dice-coins/ for a good explanation.
@@ -182,8 +174,8 @@ class Sampler:
             if forced is None
             else next((b, a, a_c) for (b, a, a_c) in self.table if forced in (b, a))
         )
-        base, alternate, alternate_chance = choice(
-            data, self.table, forced=forced_choice
+        base, alternate, alternate_chance = data.choice(
+            self.table, forced=forced_choice
         )
         use_alternate = data.draw_boolean(
             alternate_chance, forced=None if forced is None else forced == alternate

+ 1 - 1
contrib/python/hypothesis/py3/hypothesis/strategies/_internal/strategies.py

@@ -602,7 +602,7 @@ class SampledFromStrategy(SearchStrategy):
         # The speculative index didn't work out, but at this point we've built
         # and can choose from the complete list of allowed indices and elements.
         if allowed:
-            i, element = cu.choice(data, allowed)
+            i, element = data.choice(allowed)
             data.draw_integer(0, len(self.elements) - 1, forced=i)
             return element
         # If there are no allowed indices, the filter couldn't be satisfied.

+ 1 - 1
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, 92, 8)
+__version_info__ = (6, 92, 9)
 __version__ = ".".join(map(str, __version_info__))

+ 1 - 1
contrib/python/hypothesis/py3/ya.make

@@ -2,7 +2,7 @@
 
 PY3_LIBRARY()
 
-VERSION(6.92.8)
+VERSION(6.92.9)
 
 LICENSE(MPL-2.0)