Skip to content

curriculum: add actionable assertion messages to recursion checks (batch 2 of 4) #97

Description

@abhiksark

Motivation

Bare assertions report only AssertionError, which does not tell a beginner what behavior was expected. Each hidden check should fail with a short, actionable message without changing what the exercise tests.

Current evidence

An exhaustive AST audit on dev at e1d4dae37234b75124bd6a53f06734296ebbbdee found 11 assert nodes without messages in this batch:

  • checks/recursion/recursion4.py: 5
  • checks/recursion/recursion5.py: 6

Reproduce from the repository root:

import ast
from pathlib import Path

files = [
    'checks/recursion/recursion4.py',
+    'checks/recursion/recursion5.py'
]
for filename in files:
    tree = ast.parse(Path(filename).read_text(encoding="utf-8"))
    missing = sum(
        isinstance(node, ast.Assert) and node.msg is None
        for node in ast.walk(tree)
    )
    print(filename, missing)

The full audit found 270 missing messages across 121 check files. This ticket is limited to 2 files and 11 messages.

Exact scope

Add a non-empty, beginner-facing message to each currently bare assertion in the listed files. Preserve every assertion predicate, execution order, helper statement, and success print.

Acceptance checklist

  • All 11 currently bare assertions in the listed files have non-empty messages.
  • Each message states the expected behavior or value in terms a learner can act on.
  • Messages include the actual value when it is readily available and useful.
  • Assertion predicates, ordering, side effects, and success output are unchanged.
  • No check outside the listed files is changed.
  • All 292 reference answers continue to pass.
  • Changed check code remains Python 3.9 compatible.

Explicit exclusions

Do not change learner exercises, reference solutions, solutions/_answers.py, hints, documentation URLs, manifest order, exercise names, or curriculum semantics. Difficulty sequencing remains in #17, and contribution-guide wording remains in #39.

Likely files

  • checks/recursion/recursion4.py
  • checks/recursion/recursion5.py

Verification

python -m pytest tests/integration/test_solution_verify.py -q
python -m pytest -q
pythonlings --root tests/fixtures/passing_curriculum verify

Rerun the AST probe above and confirm every listed count is zero.

Sprint coordination

See Discussion #37 and tracker #52. This issue is intentionally unassigned. A coordination comment is welcome, but it does not reserve the issue. The first pull request that satisfies every acceptance criterion and verification requirement is considered for merge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: curriculumCurriculum exercises, checks, and solutionsbugSomething isn't workingdev sprintPythonlings Community Dev Sprint August 2026good first issueGood for newcomerssize: SSmall, focused contribution

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions