AIToday
AI Coding AssistantsLarge Language ModelsZenn AI/MLPublished: Nov 28, 2026, 10:01 JST

total(100, fee=5) fix passes all 4 tests; rollback fails 2

Send on LINE
total(100, fee=5) fix passes all 4 tests; rollback fails 2

3 Key Points

  1. What happened

    Using a small Python function where fee became keyword-only, a fix that removes the * from the definition is compared with one that updates the call to total(100, fee=5); both return 105 when tests check only the value.

  2. Why it matters

    A value-only test cannot distinguish the two fixes, so accepting a change on a green test alone may silently drop the calling convention the change was meant to enforce.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

A deliberately small Python function, total(amount, *, fee=5), is the focus, where the asterisk makes fee keyword-only. An old call, total(100, 5), passes the fee positionally and raises TypeError. Two repairs are offered: one removes the asterisk so the old call works, the other keeps the asterisk and changes the caller to total(100, fee=5). On a value-only check both return 105, so a four-test suite is used to separate them.

The separation depends on what the tests inspect. Two tests call the function and compare return values. A third reads the function's signature with inspect.signature to confirm fee is KEYWORD_ONLY, and a fourth uses assertRaises to confirm total(100, 5) raises TypeError. Under these four, the rollback fix fails the keyword-only and positional-rejection tests, while the caller fix passes all four. Adding a signature-level test is only appropriate when the requirement includes the definition's shape; fixing internal form can restrict changes that should be allowed.

The tutorial then reverses the requirement to keep the old positional call, and the verdict flips to the rollback fix, showing that the same code can be accepted or rejected depending on which calling convention is meant to be preserved. It closes with a one-page review memo template that records the target, requirement, environment, results, and the adopt/reject/hold decision, and it explicitly limits its own validation to the fictional two fixes, three requirements, four tests, and six calls, without claiming general bug-prevention effects from AI.

FAQ
What exactly do the four tests check?
They check that checkout() returns 105, that total(100, fee=5) returns 105, that fee is KEYWORD_ONLY via inspect.signature, and that total(100, 5) raises TypeError.
What happens if the requirement changes to keep the old positional call?
With the two conditions of returning 105 and continuing to allow total(100, 5), the rollback fix (案A) is the one to adopt, because the keyword-only fix rejects the positional call.
What environment does the reproduction require?
It uses Python 3.12 and a single file, repair_review.py, fixed at commit a127a99bc240e13f981dbccaa1a1dd1fa7b4a552, with no Git, AI model, account, network, or additional packages needed for execution.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleAI voices spur false police reports in US, NPR says