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

min_size arguments should default to zero instead of None #1618

Closed
Zac-HD opened this issue Oct 3, 2018 · 1 comment
Closed

min_size arguments should default to zero instead of None #1618

Zac-HD opened this issue Oct 3, 2018 · 1 comment
Labels
legibility make errors helpful and Hypothesis grokable

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Oct 3, 2018

We default arguments to None where we don't have a known bound (e.g. integers()), or where a non-None default argument would require us to weaken our checks for consistency (e.g. if min_value defaulted to -inf for floats(), we couldn't warn a user who passed min_value=-inf, allow_infinity=False). For strategies such as dates() we don't accept None at all!

It turns out that neither of these reasons apply to minimum sizes! We should therefore:

  • Set min_size=0 as the default for all size arguments
  • In hypothesis.internal.validation.check_valid_size, add a check if name == 'min_size' and value is None: and use note_deprecation to warn users that they should use min_size=0 instead.
  • Search for any remaining cases in our codebase where we use this argument, with git grep --line-number --perl-regexp "min_size ?= ?None"
  • Write a test in hypothesis-python/tests/cover/test_validation.py that uses @checks_deprecated_behaviour and passes min_size=None to lists().
@Zac-HD Zac-HD added good first issue legibility make errors helpful and Hypothesis grokable labels Oct 3, 2018
@lgoeller
Copy link
Contributor

lgoeller commented Oct 7, 2018

I'm going to take this one on!

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

No branches or pull requests

2 participants