SCR111: assert-on-tuple
assert on a non-empty tuple is always true
| Code | SCR111 |
| Name | assert-on-tuple |
| Category | Scripts (SCR) |
| Default severity | warning |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports assert (condition, "message"): an assertion whose test is a
non-empty tuple.
Why is this bad?
Section titled “Why is this bad?”A non-empty tuple is always true, so the assertion never fails. The parentheses turned the condition and the message into one tuple.
Example
Section titled “Example”assert (len(rows) > 0, "no rows returned")Use instead:
assert len(rows) > 0, "no rows returned"pylint
Section titled “pylint”Corresponds to W0199 assert-on-tuple.
Generated from the rule metadata by iglint generate-docs; iglint rule SCR111 prints the same page in the terminal. Source: docs/rules/SCR111.md.