Skip to content
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

Make sampled_from() non-lazy #2515

Merged
merged 1 commit into from Jul 27, 2020
Merged

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Jul 27, 2020

Closes #2507. This is kinda fiddly, but not as bad as I expected... all we really lose is the "repr preserves sequence type" thing and there's no good way to do that without storing a shallow copy of whatever we're sampling just for the repr.

@Zac-HD Zac-HD requested a review from DRMacIver July 27, 2020 08:08
@Zac-HD Zac-HD closed this Jul 27, 2020
@Zac-HD Zac-HD reopened this Jul 27, 2020
@Zac-HD Zac-HD force-pushed the immediate-sample branch 3 times, most recently from 2e9b797 to 22c5fbe Compare July 27, 2020 10:05
@Zac-HD
Copy link
Member Author

Zac-HD commented Jul 27, 2020

OK, I think that's done now 🙂

Copy link
Member

@DRMacIver DRMacIver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some comments as thoughts for later, but I'll open a ticket about them as they're unrelated to this PR.

@@ -191,12 +191,18 @@ def cached_strategy(*args, **kwargs):
return cached_strategy


def base_defines_strategy(force_reusable: bool) -> Callable[[T], T]:
def base_defines_strategy(
force_reusable: bool, *, try_non_lazy: bool = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this as part of this pull request, but maybe we should open a minor ticket to move this over to keyword only arguments for both.

@@ -220,6 +236,7 @@ def accept(*args, **kwargs):

defines_strategy = base_defines_strategy(False)
defines_strategy_with_reusable_values = base_defines_strategy(True)
defines_strategy_without_laziness = base_defines_strategy(False, try_non_lazy=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also no need to do this in this PR but I kinda feel like we should just inline all of these.

@Zac-HD Zac-HD merged commit 8684b3e into HypothesisWorks:master Jul 27, 2020
@Zac-HD Zac-HD deleted the immediate-sample branch August 1, 2020 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mutable arguments and lazy definition of sampled_from interact poorly
2 participants