-
Notifications
You must be signed in to change notification settings - Fork 9
Bandit, release v1, use ifs over assert in src #67
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
|
|
||
| """ | ||
|
|
||
| __version__ = "0.5.0" | ||
| __version__ = "1.0.0" | ||
|
|
||
| import logging | ||
| import time | ||
|
|
@@ -180,15 +180,16 @@ def poll( | |
| This message should allow a user to work-out how long the poll could take, and thereby detect a hang in real-time | ||
| if the poll takes longer than it should. | ||
| """ | ||
|
|
||
| assert (timeout is not None or max_tries is not None) or poll_forever, ( | ||
| "You did not specify a maximum number of tries or a timeout. Without either of these set, the polling " | ||
| 'function will poll forever. If this is the behavior you want, pass "poll_forever=True"' | ||
| ) | ||
|
|
||
| assert not ( | ||
| (timeout is not None or max_tries is not None) and poll_forever | ||
| ), "You cannot specify both the option to poll_forever and max_tries/timeout." | ||
| if not ((timeout is not None or max_tries is not None) or poll_forever): | ||
| raise AssertionError( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're including this in a major release, I don't think it would be unreasonable to break compatibility by switching to a (FWIW, I don't actually need/rely on this at all. It's just more correct IMO.) Alternatively, a compromise solution could be to create a custom exception for a while that inherits from both: class ValueAssertionError(ValueError, AssertionError):
"""Backwards-compatible ValueError (catching AssertionError is deprecated!)""" |
||
| "You did not specify a maximum number of tries or a timeout. Without either of these set, the polling " | ||
| 'function will poll forever. If this is the behavior you want, pass "poll_forever=True"' | ||
| ) | ||
|
|
||
| if (timeout is not None or max_tries is not None) and poll_forever: | ||
| raise AssertionError( | ||
| "You cannot specify both the option to poll_forever and max_tries/timeout." | ||
| ) | ||
|
|
||
| kwargs = kwargs or dict() | ||
| values = collect_values or Queue() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Down with ZeroVer! 💯
(Nothing to do here, just pleased with this 😋)