From 95c061b9c5baf9610b247da2362764660cc3b1b8 Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Wed, 8 Jan 2025 10:41:37 -0500 Subject: [PATCH] remove unused .trivial, lint --- .../hypothesis/internal/conjecture/data.py | 37 ------------------- .../tests/conjecture/test_inquisitor.py | 6 ++- 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/data.py b/hypothesis-python/src/hypothesis/internal/conjecture/data.py index 32e993b0ca..e02a512928 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/data.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/data.py @@ -271,13 +271,6 @@ def depth(self) -> int: depth of 0.""" return self.owner.depths[self.index] - @property - def trivial(self) -> bool: - """An example is "trivial" if it only contains forced bytes and zero bytes. - All examples start out as trivial, and then get marked non-trivial when - we see a byte that is neither forced nor zero.""" - return self.index in self.owner.trivial - @property def discarded(self) -> bool: """True if this is example's ``stop_example`` call had ``discard`` set to @@ -536,27 +529,6 @@ def stop_example(self, i: int, *, discarded: bool) -> None: discarded: frozenset[int] = calculated_example_property(_discarded) - class _trivial(ExampleProperty): - def begin(self) -> None: - self.nontrivial = IntList.of_length(len(self.examples)) - self.result: set[int] = set() - - def block(self, i: int) -> None: - if not self.examples.blocks.trivial(i): - self.nontrivial[self.example_stack[-1]] = 1 - - def stop_example(self, i: int, *, discarded: bool) -> None: - if self.nontrivial[i]: - if self.example_stack: - self.nontrivial[self.example_stack[-1]] = 1 - else: - self.result.add(i) - - def finish(self) -> frozenset[int]: - return frozenset(self.result) - - trivial: frozenset[int] = calculated_example_property(_trivial) - class _parentage(ExampleProperty): def stop_example(self, i: int, *, discarded: bool) -> None: if i > 0: @@ -746,15 +718,6 @@ def __known_block(self, i: int) -> Optional[Block]: except (KeyError, IndexError): return None - def trivial(self, i: int) -> Any: - """Equivalent to self.blocks[i].trivial.""" - if self.owner is not None: - return self.start(i) in self.owner.forced_indices or not any( - self.owner.buffer[self.start(i) : self.end(i)] - ) - else: - return self[i].trivial - def _check_index(self, i: int) -> int: n = len(self) if i < -n or i >= n: diff --git a/hypothesis-python/tests/conjecture/test_inquisitor.py b/hypothesis-python/tests/conjecture/test_inquisitor.py index 7db77db59a..7db5a0ad31 100644 --- a/hypothesis-python/tests/conjecture/test_inquisitor.py +++ b/hypothesis-python/tests/conjecture/test_inquisitor.py @@ -24,9 +24,11 @@ def _new(): settings(print_blob=False, derandomize=True, **kw)(f)() if not hasattr(err.value, "__notes__"): - # something has gone deeply wrong in the internals traceback.print_exception(err.value) - assert False + raise Exception( + "err.value does not have __notes__, something has gone " + "deeply wrong in the internals" + ) got = "\n".join(err.value.__notes__).strip() + "\n" assert got == expected.strip() + "\n"