Skip to content

Commit

Permalink
Merge pull request #3988 from tybug/fix-type-assertion
Browse files Browse the repository at this point in the history
Fix overly strict type assertion
  • Loading branch information
Zac-HD committed May 13, 2024
2 parents eb86911 + 936a399 commit 57e1fc1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch fixes an overly strict internal type assertion.
29 changes: 16 additions & 13 deletions hypothesis-python/src/hypothesis/internal/conjecture/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,20 +1072,23 @@ def generate_mutations_from(
failed_mutations += 1
continue

assert isinstance(new_data, ConjectureResult)
if (
new_data.status >= data.status
and data.buffer != new_data.buffer
and all(
k in new_data.target_observations
and new_data.target_observations[k] >= v
for k, v in data.target_observations.items()
)
):
data = new_data
failed_mutations = 0
if new_data is Overrun:
failed_mutations += 1 # pragma: no cover # annoying case
else:
failed_mutations += 1
assert isinstance(new_data, ConjectureResult)
if (
new_data.status >= data.status
and data.buffer != new_data.buffer
and all(
k in new_data.target_observations
and new_data.target_observations[k] >= v
for k, v in data.target_observations.items()
)
):
data = new_data
failed_mutations = 0
else:
failed_mutations += 1

def optimise_targets(self) -> None:
"""If any target observations have been made, attempt to optimise them
Expand Down

0 comments on commit 57e1fc1

Please sign in to comment.