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 float sizes (min_size, max_size) #1635
Deprecate float sizes (min_size, max_size) #1635
Conversation
min_size and max_size should be integers. And we only test whole float numbers, like 5.0 for example.
It use to be type: int
float size warning were breaking a test that was making sure that invalid arguments raised an InvalidArgument error.
lint and check-format tasks on travis
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.
Solid start - see comments below.
Also make sure that you mention the change of the type hints in RELEASE.rst
; something like
The type hint for
average_size
arguments has been changed fromOptional[int]
toNone
, because non-None values are always ignored and deprecated.
I've also just done a quick check for other uses of average_size
(with git grep -n "average_size="
), and you could delete the use of it in docs/examples.rst
. There are plenty more, but all of those uses are OK for compatibility or internal use.
'{} should be an integer, got {}'.format(name, value) | ||
) | ||
else: | ||
check_type(integer_types, value) | ||
if value < 0: | ||
raise InvalidArgument(u'Invalid size %s=%r < 0' % (name, value)) | ||
if isinstance(value, float) and math.isnan(value): |
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.
We can move this to the isinstance(value, float)
clause above.
Moving it before the deprecation will also fix the failing test!
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.
Hum... I don't know how I didn't see this... 😢 I'll make sure to read the whole function next time 👀
Conforms to the rest of the document's style
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.
LGTM (looks good to me) 🎉
And if you're looking for another (!) issue, #1600 would be a good choice - a bit more complex now that you're comfortable with the process and tests, but still fairly well defined and the code should be quite self-contained. After that it's the deep end, at least for Hypothesis issues. |
Whooo! Thank you! I'll have a look at #1600. |
Closes #1619
It shows a deprecation warning when
min_size
ormax_size
is a float, instead of being an integer.The tests only target "whole" float number like
5.0
, and not5.1
.I tried to find somewhere in the documentation where to mention this deprecation, but I didn't find anything... I'm not really sure if it'd be that useful anyway...
It also changes the type hints for
average_size
to beingNone
instead ofint
.Lastly, this broke a test with NaN values: a test (in
cover/test_direct_strategies.py
, attest_validates_keyword_arguments
) checks a bunch of invalid arguments and asserts that they raiseInvalidArgument
.One of them tests
min_size
asfloat('nan')
. And this breaks because it raises a warning that it doesn't expect (the warning that this PR adds). Here's the error messageSo, I tried to find a way for this test to ignore the warning, without breaking all the other tests in the table.
I've tried to use
@pytest.mark.filterwarnings
, without success, but weirdly, awith pytest.warns
clause works. I'd expect it would make sure every call would raise a warning, but instead, it seems that it just filters them out.If you want to try it locally: