SKY-L045 · Logic and resilience
Test assertion always true
An assertion in a test whose condition is true for every value of the names in it: len(x) >= 0, x or True, isinstance(x, object), x is x, or a non-empty tuple, list, set or dict such as assert (x == 1, "message"). SKY-L040 reports conditions made only of literals, like assert True; this rule covers the ones that mention a variable and still cannot fail.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
The assertion looks like a check but passes whatever the code returns. The parenthesised form is a real bug: assert (x == 1, "message") asserts a two-item tuple, which is always true, instead of x == 1 with a message.
What Skylos flags
from agents.run_state import deserialize_items def test_deserialize_items_keeps_string_agents(): result = deserialize_items([{"source_agent": "triage"}]) assert len(result) >= 0What Skylos leaves alone
from agents.run_state import deserialize_items def test_deserialize_items_keeps_string_agents(): result = deserialize_items([{"source_agent": "triage"}]) assert len(result) >= 1 assert result == resultWhy Skylos leaves it alone
len(result) >= 1 fails on an empty list. result == result can be false (a NaN, or a class whose __eq__ says so), so Skylos does not call it always true. Neither line is reported.
How Skylos decides
- Runs with
--qualityon the same collected tests as SKY-L044, and only on assertions that run: lines after areturnor a proven jump are skipped. - Reports
assertwith a non-empty tuple, list, set or dict display (no*unpacking), anorchain with an always-true part,len(x) >= 0or0 <= len(x)wherelenis the builtin,isinstance(x, object)where both names are the builtins, andx is x. - In
unittesttests it also reportsself.assertTrue(True),self.assertFalse(False)andself.assertEqualon two equal literals. - Leaves literal-only conditions to SKY-L040, and does not report
x == x, a comparison of two displays such as[a] == [b], orlenandisinstancewhen the file rebinds those names.
How to fix it
Assert on the value the code should produce. For the tuple mistake, drop the parentheses: assert x == 1, "message".
from agents.run_state import deserialize_items def test_deserialize_items_keeps_string_agents(): result = deserialize_items([{"source_agent": "triage"}])Removed: assert len(result) >= 0Added: assert [item.agent_name for item in result] == ["triage"]When it can be wrong
assert len(events) >= 0 # timing dependentis reported even when the author meant "this must not raise". The assertion still checks nothing; remove it, or assert something the timing cannot change.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the assertion line.
Python assert len(events) >= 0 # skylos: ignore[SKY-L045] streaming must not raise[tool.skylos] ignore = ["SKY-L045"]turns the rule off for the project.