Eliminate "is True" and "is False" #342
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a parameter X is documented as having a boolean value, it should be treated (in duck-typing style) as true if bool(X) is true, or false if bool(X) is false.
Writing "if X is True" is almost always a bad idea: it suggests to the reader that "X is True" and "X is False" are the only possibilities, when in fact there is no such guarantee.
(In some cases it might make sense to explicitly check argument types to catch programming errors - but in most cases this feels like an overcomplication, and even then it's a bad idea to write "if X is True" because the permitted argument types might change in the future.)
To wit:
rdrecord("foo", physical=0)
would do what you expect;rdrecord("foo", physical=1)
would crash.rdrecord("foo", smooth_frames=1)
would do what you expect;rdrecord("foo", smooth_frames=0)
would crash.