-
Notifications
You must be signed in to change notification settings - Fork 820
Assertion helper added #808
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
Conversation
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.
This looks great! Thanks @Kacppian
First, thanks a lot for your work @Kacppian. After reviewing this PR, I sincerely don't prefer this new syntax, since with the
assert something is not None, "Something was unexpectedly None"
if something is not None:
raise AssertionError("Something was unexpectedly None") What we have in the PR: raise_assertion_if_not(
something is not None,
"Something was unexpectedly None"
) I would love to get more input into this, so comments are more than welcome! |
Hey sorry for not looking at this sooner. I agree with Syrus, the helper feels unnecessary. It basically just abstracts out an if statement, which I think makes the code less readable. |
Thank you for the comments. Should I fall back to not having the helper method? |
In JavaScript the |
@Kacppian in my opinion, we should use the form: if condition:
raise AssertionError(message) And I think we should do this at the call sites, not in a function. @jkimbo I think that makes more sense in the JS ecosystem where everything is libraries and functions all the way down, but in Python it's much expected that you do the obvious thing rather than wrapping up potentially unexpected effects. In this case I don't think there's any benefit introduced by wrapping up AssertionErrors - it really does just feel like turning an if statement into a function - that requires an extra import, possibly a test, documentation, knowledge transfer, and understanding by new developers. An |
I used the suggested construction in #794 and closed it later because you'd suggested I use a helper method. Never mind, I'll revert back to it. |
@Kacppian apologies for the back and forth. I disagree with @dan98765's suggestion on that PR, and it appears that @syrusakbary does too. I'm afraid we're not a cohesive team, just people who happen to have an interest in this library! |
I'm extremely sorry. I didn't mean it to come out like that. Just mentioning the reason I've done it this way. |
No problem! I didn’t read it as rude, and it is a valid criticism.
… On 29 Aug 2018, at 18:39, Kaushik Asp ***@***.***> wrote:
I'm extremely sorry. I didn't mean it to come out like that. Just mentioning the reason I've done it this way.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Cool then, I'll remove the helper method and make the necessary changes. |
I agree that the unwrapped form is the one to go for because it's unambiguous and requires no extra |
needs rebase |
needs love ;) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
assert
added.