Skip to main content

SKY-L033 · Logic and resilience

No-effect statement

Low

The catalog gives no severity for this rule; the detector always reports LOW.

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

accounts/admin.py · PythonReported on line 5
"""User administration."""  def deactivate(user):    user.active == False    user.save()

What Skylos leaves alone

tests/test_version.py · Python
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

  1. Runs with --quality on Python files. Looks at every statement that is a bare expression.
  2. Reports a comparison (==, <, in, is and the others) whose result is discarded, and a constant expression Skylos can work out without running anything, such as 42 or 1 + 2.
  3. Reports a discarded call to uuid.uuid1(), uuid.uuid3(), uuid.uuid4() or uuid.uuid5(); other calls can have side effects and are left alone.
  4. Skips strings (docstrings), ..., None, await and yield, a bare name or attribute, any expression that contains a call or :=, a constant expression that would raise (such as 1 / 0), and expressions inside with pytest.raises(...).
  5. 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.

accounts/admin.py · Python · the fix, against the flagged file
"""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 + tax or user.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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.