Skip to content

Commit 71ec431

Browse files
committed
typing
1 parent 4c48849 commit 71ec431

File tree

1 file changed

+6
-0
lines changed
  • hypothesis-python/src/hypothesis/internal/conjecture

1 file changed

+6
-0
lines changed

hypothesis-python/src/hypothesis/internal/conjecture/optimiser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from hypothesis.internal.compat import int_from_bytes, int_to_bytes
1414
from hypothesis.internal.conjecture.data import (
1515
ConjectureResult,
16+
IRType,
1617
Status,
1718
_Overrun,
1819
bits_to_bytes,
@@ -134,12 +135,16 @@ def attempt_replace(k: int) -> bool:
134135
return False
135136

136137
node = self.current_data.examples.ir_tree_nodes[i]
138+
assert node.index is not None
137139
if node.was_forced:
138140
return False # pragma: no cover
139141

142+
new_value: IRType
140143
if node.ir_type in {"integer", "float"}:
144+
assert isinstance(node.value, (int, float))
141145
new_value = node.value + k
142146
elif node.ir_type == "boolean":
147+
assert isinstance(node.value, bool)
143148
if abs(k) > 1:
144149
return False
145150
if k == -1:
@@ -150,6 +155,7 @@ def attempt_replace(k: int) -> bool:
150155
new_value = node.value
151156
else:
152157
assert node.ir_type == "bytes"
158+
assert isinstance(node.value, bytes)
153159
v = int_from_bytes(node.value)
154160
# can't go below zero for bytes
155161
if v + k < 0:

0 commit comments

Comments
 (0)