-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental changes for Crosshair support #4164
Conversation
@@ -1334,6 +1334,29 @@ def draw_bytes( | |||
) -> bytes: | |||
raise NotImplementedError | |||
|
|||
def span_start(self, label: int, /) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big fan of the "span" terminology, over "examples".
In the future we should probably provide a more meaningful representation of the strategy than an integer label, so providers can do particular things for e.g. lists. Pass through the strategy instance wholesale, for examples with a corresponding strategy? I'd guess providers are unlikely to check anything beyond type(strategy) is ListStrategy
, but could also check attributes like strategy.min_size
in principle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe we should rename the existing code to match? big diff but it'd make it easier to work with the internals...)
The PrimitiveProvider
interface is explicitly unstable for now, so we can change the label
type when we get around to that ourselves. Nonetheless IMO passing the strategy instance exposes too much accidental complexity and implementation detail; I do want to at least try evolving towards a clean well-abstracted interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the strategy type + relevant type-specific kwargs as a dict?
def span_start(self, label: int, strategy: type[SearchStrategy] | None, strategy_kwargs: dict[str, Any])
Agree we can just change it later though, not something we have to decide now. And the label will likely have to stay forever because not all spans are associated with a strategy (eg stateful rules).
-0 on a patch in the near future for selfish reasons; I have some local work towards excising all buffer usages, which is very large and would require conflict resolution. But I wouldn't stop such a pull.
Thanks for this! Yeah, this sort of change looks like the kind of thing that would help, but my example cases aren't yet passing. They are |
Ok! What you have is almost enough; however I also need BackendCannotProceed exception cases to count as INVALID; something like this?: diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py
index d12ad4b5b..180ac3f81 100644
--- a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py
+++ b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py
@@ -444,6 +444,7 @@ class ConjectureRunner:
interrupted = True
raise
except BackendCannotProceed as exc:
+ data.status = Status.INVALID
if exc.scope in ("verified", "exhausted"):
self._switch_to_hypothesis_provider = True
if exc.scope == "verified": This solution would imply that we're declaring that exhausted/verified should be raised outside of a normal execution. But I think we're ok with that? |
Hmm. It's not really |
Sounds good. I will franken-merge the things together, apply electricity, and report back. |
Makes sense. This tweak is not solving the issue for me right now however. Setting |
Looks like the early Once you confirm, I'll merge! |
Yes! These work for me too! |
cc @pschanely
span_start()
andspan_end()
methods to make recognising recursive strategies easier.Unsatisfiable
after an alternative backend gives up.