-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add an "assert" function #252
Comments
In Python 3, this line is a no op: >>> assert(False, "abc")
<stdin>:1: SyntaxWarning: assertion is always true, perhaps remove parentheses? The syntax is actually without parentheses: assert someExpression
assert someExpression, "error message" So the request would require a change in the syntax (and all Starlark-aware tooling). We would also need a way to prevent users from writing the no-op line |
As someone that ported assert that("this").is_not_equal_to("that") Today I'm able to declare |
I don't quite know the requirements of Starlark - is it a requirement that it must be Python3 - compatible? Creating an |
Hi,
There is already a
fail
function, but it's not ergonomic to use, because it takes 2 lines and 1 added indentation level. It would be good if we could have aassert
function. Consider:vs
The same code with
assert
is much cleaner. It's also consistent with most programming languages.The text was updated successfully, but these errors were encountered: