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

Deprecate min_value or max_value that cannot be generated #1625

Closed
Zac-HD opened this issue Oct 6, 2018 · 4 comments · Fixed by #1634
Closed

Deprecate min_value or max_value that cannot be generated #1625

Zac-HD opened this issue Oct 6, 2018 · 4 comments · Fixed by #1634
Labels
legibility make errors helpful and Hypothesis grokable

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Oct 6, 2018

Many Hypothesis strategies accept min_value and max_value arguments, which usually have to be the same type as the examples the strategy can generate. The strategies for numbers generally allow any type of number to be used - which is convenient, but has a surprising catch: sometimes, the strategy will be unable to generate the given bound or bounds!

We should deprecate bounds for integers() and floats() which cannot be exactly represented as integers and floats respectively. For example, you can check if min_value != min_int_value and then use note_deprecation to issue the warning.

Finally, we should deprecate bounds for fractions() with a non-None max_denominator where the denominator of the bound (after casting to Fraction) is larger than max_denominator.

@Zac-HD Zac-HD added good first issue legibility make errors helpful and Hypothesis grokable labels Oct 6, 2018
@ghost
Copy link

ghost commented Oct 8, 2018

This looks like something I can give a shot tomorrow. 👍

@Zac-HD
Copy link
Member Author

Zac-HD commented Oct 8, 2018

Awesome! This issue is all your for the next week 😄

@ghost
Copy link

ghost commented Oct 9, 2018

just to make sure that i'm on the right path - in the end it should look similar to my first commit, right?
thinkgruen@cc84677

@Zac-HD
Copy link
Member Author

Zac-HD commented Oct 10, 2018

Yep, I've left two comments but that's an excellent start 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legibility make errors helpful and Hypothesis grokable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant