SKY-L033 · Logic and resilience
No-effect statement
A statement that computes a value and throws it away, such as user.active == False on a line of its own. Python runs it without complaint. It is almost always a typo for an assignment (=) or a missing assert.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- defect
Why it matters
The code looks as if it does something and does not. In the example below a deactivated user is saved unchanged and can still sign in, and no test or error points at the line.
What Skylos flags
"""User administration.""" def deactivate(user): user.active == False user.save()What Skylos leaves alone
import pytest from app.version import Version def test_version_cannot_compare_with_text(): current = Version("1.2") with pytest.raises(TypeError): current < "1.3"Why Skylos leaves it alone
The comparison is thrown away on purpose: the test only checks that making it raises TypeError. Skylos skips expressions inside a with pytest.raises(...) block, where evaluating them is the point.
How Skylos decides
- Runs with
--qualityon Python files. Looks at every statement that is a bare expression. - Reports a comparison (
==,<,in,isand the others) whose result is discarded, and a constant expression Skylos can work out without running anything, such as42or1 + 2. - Reports a discarded call to
uuid.uuid1(),uuid.uuid3(),uuid.uuid4()oruuid.uuid5(); other calls can have side effects and are left alone. - Skips strings (docstrings),
...,None,awaitandyield, a bare name or attribute, any expression that contains a call or:=, a constant expression that would raise (such as1 / 0), and expressions insidewith pytest.raises(...). - Reports LOW on the line of the statement.
How to fix it
Use = to change the value. If the line was meant as a check, write assert or an if.
"""User administration.""" def deactivate(user):Removed: user.active == FalseAdded: user.active = False user.save()When it can be wrong
- A comparison kept only for its side effect, such as an overloaded
==on a query-builder object that records something, is reported. - It misses discarded arithmetic or attribute reads that involve names, such as
total + taxoruser.active, because Skylos cannot prove they have no effect.
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 reported line.
Python query.price < 10 # skylos: ignore[SKY-L033] builder records the filter[tool.skylos] ignore = ["SKY-L033"]turns the rule off for the project.