Repository navigation
Conversation
…endently Three unrelated, classic bugs in three separate files: a mutable default argument, an off-by-one slice, and an unclosed file handle. Checking whether marginal returns three distinct findings, not one merged/missed one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🤖 marginal review
PR #104: DO NOT MERGE -- verify separate findings for separate bugs · open · 2d1ad43f6114b0119ee426be3d6433ef356fbfe9 → 37d281ac2f7273ff366e650de04cf3acbc8870c0 · 3 files changed
Changed files (3)
scratch_bug_mutable_default.pyscratch_bug_off_by_one.pyscratch_bug_resource_leak.py
| """DO NOT MERGE -- throwaway file, part of a verification test.""" | ||
|
|
||
|
|
||
| def append_item(item, items=[]): # noqa: B006 |
There was a problem hiding this comment.
🟠 High · 95% confidence
Using a mutable default argument (items=[]) means the same list is shared across all calls that don't pass items explicitly, causing items to accumulate unexpectedly between calls. Should use items=None and initialize items = [] if items is None else items inside the function.
|
|
||
|
|
||
| def get_last_n(items: list, n: int) -> list: | ||
| """Return the last `n` items of `items`.""" |
There was a problem hiding this comment.
🟠 High · 90% confidence
Off-by-one error: items[len(items) - n - 1:] returns n+1 items instead of n, and will behave incorrectly for n=0 (returns last element instead of empty list). The correct slice should be items[len(items) - n:] or simply items[-n:].
|
|
||
| def read_file_contents(path: str) -> str: | ||
| """Read and return the contents of the file at `path`.""" | ||
| f = open(path) |
There was a problem hiding this comment.
🟠 High · 90% confidence
The file opened with open(path) is never closed, causing a resource leak. Should use a with open(path) as f: context manager to ensure the file handle is properly closed even if an exception occurs during read.
|
Verification complete -- 3/3 separate bugs caught as 3 distinct findings (95%, 90%, 90% confidence), all correctly diagnosed. Closing without merging, deleting the branch. |
Throwaway verification PR. Three unrelated bugs in three separate files -- checking whether marginal returns 3 distinct findings, not fewer/merged. Will close without merging.