Skip to content

Commit

Permalink
remove unused .trivial, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Jan 8, 2025
1 parent 719ff5b commit 95c061b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 39 deletions.
37 changes: 0 additions & 37 deletions hypothesis-python/src/hypothesis/internal/conjecture/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions hypothesis-python/tests/conjecture/test_inquisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 95c061b

Please sign in to comment.