Skip to content

QA-PY-004 — Bare truthiness assert on complex object ​

← Back to the rule catalog

Generated from the rule registry. Get the same detail from the CLI with mjolnir explain QA-PY-004.

FieldValue
Severitywarning
Confidencemedium
Tierquarantine
Measured FP ratenot yet measured
Evidence levelE1
QA impactFalse-green risk (FALSE-GREEN)
False-positive risk (author estimate)medium
Autofix availableno
Languagespython
Frameworkspytest
Detection strategyLEXICAL
Introduced inv0.3.0

Why this fails in production ​

This passes for any truthy value — a wrong object, wrong count, or partially-built result all slip through. It verifies existence, not correctness.

What gets flagged (real detector output) ​

Bare truthiness assert: `assert order`.

Example from this rule's own must-fire fixture: tests/fixtures/QA-PY-004/must-fire/attribute-chains.py

The fix ​

Assert the specific expected value or property: assert result.id == expected, assert len(items) == 3.

Confirmed NOT to fire on the corresponding clean pattern ​

Verified against tests/fixtures/QA-PY-004/must-not-fire/constant-asserts.py — a legitimate, similar-looking pattern this rule correctly leaves alone.

Corpus-measured false-positive risk ​

Real occurrence counts from npm run corpus:audit against actively-maintained OSS repos — reproduce yourself, don't just trust this table (see the false-positive audit):

RepoOccurrences
apache-airflow534
getsentry-sentry889
negative-fixtures1
pallets-click4
positive-fixtures11
psf-requests11
pyca-cryptography17
pytest-dev-pytest84
reflex-dev-reflex140
streamlit-streamlit361

Released under the MIT License.