Will It Vibe logoWill It Vibe?
PY-007Low severity-4 points

assert used for input validation

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

assert statements are removed entirely when Python runs with -O, so validation logic (and its message) that lives only in an assert silently disappears in that mode.

Why it matters

assert statements are stripped out entirely when Python runs with the -O (optimize) flag, so any validation logic that lives only in an assert silently disappears in that mode, along with the message describing what went wrong. Because asserts are meant for internal invariants and debugging aids rather than for validating external input, using one to reject bad user or caller input can leave a production build with no validation at all. This check only flags asserts that include an explicit message, since that is the strongest indication the author intended it as a validation or error path rather than a debug-only sanity check.

How to fix it

Replace the assert with an explicit if check that raises a real exception, for example if percent < 0: raise ValueError("discount percent must be non-negative"). Keep the same message text so the error stays just as clear to whoever hits it, and choose an exception type (ValueError, TypeError) that matches what is actually wrong.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks