diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-13 08:41:32 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-05-13 08:49:12 +0300 |
commit | 729cf217631f33c3297a77b89df46671992350ac (patch) | |
tree | db808d27d756c10fe26ab8aba46e1b52d7fb0476 /contrib/python/hypothesis/py3 | |
parent | b2d826f65dc1cddb9e2ebca3b0048bb0e8052340 (diff) | |
download | ydb-729cf217631f33c3297a77b89df46671992350ac.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis/py3')
12 files changed, 71 insertions, 25 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA index 5c622375cd..79347abbf0 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.100.1 +Version: 6.100.2 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/errors.py b/contrib/python/hypothesis/py3/hypothesis/errors.py index d71f1c337e..0d376a7493 100644 --- a/contrib/python/hypothesis/py3/hypothesis/errors.py +++ b/contrib/python/hypothesis/py3/hypothesis/errors.py @@ -8,6 +8,7 @@ # 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/. + class HypothesisException(Exception): """Generic parent class for exceptions thrown by Hypothesis.""" diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/array_api.py b/contrib/python/hypothesis/py3/hypothesis/extra/array_api.py index 8c82f63114..85e5f3f8f9 100644 --- a/contrib/python/hypothesis/py3/hypothesis/extra/array_api.py +++ b/contrib/python/hypothesis/py3/hypothesis/extra/array_api.py @@ -282,7 +282,7 @@ def _from_dtype( if allow_subnormal is not None: kw["allow_subnormal"] = allow_subnormal else: - subnormal = next_down(finfo.smallest_normal, width=finfo.bits) + subnormal = next_down(float(finfo.smallest_normal), width=finfo.bits) ftz = bool(xp.asarray(subnormal, dtype=dtype) == 0) if ftz: kw["allow_subnormal"] = False @@ -303,7 +303,7 @@ def _from_dtype( # complex array, in case complex arrays have different FTZ behaviour # than arrays of the respective composite float. if allow_subnormal is None: - subnormal = next_down(finfo.smallest_normal, width=finfo.bits) + subnormal = next_down(float(finfo.smallest_normal), width=finfo.bits) x = xp.asarray(complex(subnormal, subnormal), dtype=dtype) builtin_x = complex(x) allow_subnormal = builtin_x.real != 0 and builtin_x.imag != 0 diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py index 93f7758ba2..d3b7ba9a8a 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py @@ -1977,6 +1977,7 @@ class ConjectureData: self.extra_information = ExtraInformation() self.ir_tree_nodes = ir_tree_prefix + self._node_index = 0 self.start_example(TOP_LABEL) def __repr__(self): @@ -2274,10 +2275,11 @@ class ConjectureData: def _pop_ir_tree_node(self, ir_type: IRTypeName, kwargs: IRKWargsType) -> IRNode: assert self.ir_tree_nodes is not None - if self.ir_tree_nodes == []: + if self._node_index == len(self.ir_tree_nodes): self.mark_overrun() - node = self.ir_tree_nodes.pop(0) + node = self.ir_tree_nodes[self._node_index] + self._node_index += 1 # If we're trying to draw a different ir type at the same location, then # this ir tree has become badly misaligned. We don't have many good/simple # options here for realigning beyond giving up. diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py index c22cd0b294..ac79b42e6e 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py @@ -63,6 +63,15 @@ class Killed: next_node = attr.ib() + def _repr_pretty_(self, p, cycle): + assert cycle is False + p.text("Killed") + + +def _node_pretty(ir_type, value, kwargs, *, forced): + forced_marker = " [forced]" if forced else "" + return f"{ir_type} {value}{forced_marker} {kwargs}" + @attr.s(slots=True) class Branch: @@ -79,6 +88,16 @@ class Branch: assert max_children > 0 return max_children + def _repr_pretty_(self, p, cycle): + assert cycle is False + for i, (value, child) in enumerate(self.children.items()): + if i > 0: + p.break_() + p.text(_node_pretty(self.ir_type, value, self.kwargs, forced=False)) + with p.indent(2): + p.break_() + p.pretty(child) + @attr.s(slots=True, frozen=True) class Conclusion: @@ -87,6 +106,15 @@ class Conclusion: status: Status = attr.ib() interesting_origin: Optional[InterestingOrigin] = attr.ib() + def _repr_pretty_(self, p, cycle): + assert cycle is False + o = self.interesting_origin + # avoid str(o), which can include multiple lines of context + origin = ( + "" if o is None else f", {o.exc_type.__name__} at {o.filename}:{o.lineno}" + ) + p.text(f"Conclusion ({self.status!r}{origin})") + # The number of max children where, beyond this, it is practically impossible # for hypothesis to saturate / explore all children nodes in a reasonable time @@ -493,6 +521,29 @@ class TreeNode: ) return self.is_exhausted + def _repr_pretty_(self, p, cycle): + assert cycle is False + indent = 0 + for i, (ir_type, kwargs, value) in enumerate( + zip(self.ir_types, self.kwargs, self.values) + ): + with p.indent(indent): + if i > 0: + p.break_() + p.text(_node_pretty(ir_type, value, kwargs, forced=i in self.forced)) + indent += 2 + + if isinstance(self.transition, Branch): + if len(self.values) > 0: + p.break_() + p.pretty(self.transition) + + if isinstance(self.transition, (Killed, Conclusion)): + with p.indent(indent): + if len(self.values) > 0: + p.break_() + p.pretty(self.transition) + class DataTree: """ @@ -889,6 +940,10 @@ class DataTree: if child in children: children.remove(child) + def _repr_pretty_(self, p, cycle): + assert cycle is False + return p.pretty(self.root) + class TreeRecordingObserver(DataObserver): def __init__(self, tree): diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py index ae28fcd741..04bbe079a3 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py @@ -922,7 +922,7 @@ class Shrinker: new_blocks[i] = int_to_bytes(v + o, len(blocked[i])) return self.incorporate_new_buffer(b"".join(new_blocks)) - Integer.shrink(offset, reoffset, random=self.random) + Integer.shrink(offset, reoffset) self.clear_change_tracking() def clear_change_tracking(self): @@ -1193,7 +1193,6 @@ class Shrinker: Lexical.shrink( block, lambda b: self.try_shrinking_blocks(targets, b), - random=self.random, ) @defines_shrink_pass() @@ -1236,7 +1235,6 @@ class Shrinker: + [node.copy(with_value=sign * val)] + self.nodes[node.index + 1 :] ), - random=self.random, node=node, ) @@ -1362,7 +1360,6 @@ class Shrinker: Lexical.shrink( self.shrink_target.buffer[u:v], lambda b: self.try_shrinking_blocks((i,), b), - random=self.random, ) if self.shrink_target is not initial: @@ -1459,7 +1456,6 @@ class Shrinker: ], ) ), - random=self.random, key=lambda i: st.buffer[examples[i].start : examples[i].end], ) diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py index 5acdf85a8d..1de89bd18b 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py @@ -20,7 +20,6 @@ class Shrinker: self, initial, predicate, - random, *, full=False, debug=False, @@ -30,7 +29,6 @@ class Shrinker: self.setup(**kwargs) self.current = self.make_immutable(initial) self.initial = self.current - self.random = random self.full = full self.changes = 0 self.name = name @@ -75,7 +73,7 @@ class Shrinker: Note we explicitly do not pass through full. """ - return other_class.shrink(initial, predicate, random=self.random, **kwargs) + return other_class.shrink(initial, predicate, **kwargs) def debug(self, *args): if self.debugging_enabled: @@ -155,7 +153,6 @@ class Shrinker: Does nothing by default. """ - raise NotImplementedError def short_circuit(self): """Possibly attempt to do some shrinking. @@ -163,7 +160,7 @@ class Shrinker: If this returns True, the ``run`` method will terminate early without doing any more work. """ - raise NotImplementedError + return False def left_is_better(self, left, right): """Returns True if the left is strictly simpler than the right diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/lexical.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/lexical.py index 569561c4ed..2f69f1fee3 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/lexical.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/lexical.py @@ -43,16 +43,10 @@ class Lexical(Shrinker): Integer.shrink( self.current_int, lambda c: c == self.current_int or self.incorporate_int(c), - random=self.random, ) def partial_sort(self): - Ordering.shrink(self.current, self.consider, random=self.random) - - def short_circuit(self): - """This is just an assemblage of other shrinkers, so we rely on their - short circuiting.""" - return False + Ordering.shrink(self.current, self.consider) def run_step(self): self.minimize_as_integer() diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/strategies.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/strategies.py index 448f7e51ac..53bee1fe22 100644 --- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/strategies.py +++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/strategies.py @@ -908,9 +908,9 @@ def _collection_ish_functions(): np.diag, # bonus undocumented functions from tab-completion: np.asarray_chkfinite, - np.asfarray, np.asfortranarray, ] + return funcs diff --git a/contrib/python/hypothesis/py3/hypothesis/utils/conventions.py b/contrib/python/hypothesis/py3/hypothesis/utils/conventions.py index ead205adc6..ec01326b49 100644 --- a/contrib/python/hypothesis/py3/hypothesis/utils/conventions.py +++ b/contrib/python/hypothesis/py3/hypothesis/utils/conventions.py @@ -8,6 +8,7 @@ # 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/. + class UniqueIdentifier: """A factory for sentinel objects with nice reprs.""" diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py index be22825634..7d9f42de8e 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, 100, 1) +__version_info__ = (6, 100, 2) __version__ = ".".join(map(str, __version_info__)) diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make index c899d543fd..4e4a82e03a 100644 --- a/contrib/python/hypothesis/py3/ya.make +++ b/contrib/python/hypothesis/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(6.100.1) +VERSION(6.100.2) LICENSE(MPL-2.0) |