mpfaffenberger / mpfaffenberger/code_puppy
tools/: grouped minor nits - mutable default arg, conint(lt=10000) off-by-one validation crash, dead UC stub, contradictory brighten_hex docs, md5 group ids
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 814
- Forks
- 278
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 76
Description
Grouped minor findings across the tools/ subsystem (one issue to avoid noise):
- Mutable default argument -
code_puppy/tools/file_modifications.pyregister_replace_in_file:
def replace_in_file(context: RunContext, file_path: str = "", replacements: RepairableReplacementsList = [], ...)
Classic anti-idiom; pydantic-ai may copy it, but the Python-level default is still a shared list. Use None + normalize, or Field(default_factory=list).
-
ReadFileOutput.num_tokens: conint(lt=10000)off-by-one crash -code_puppy/tools/file_operations.py:40+_read_file(~line 545): the guard isif num_tokens > 10000: return error, but the model constraint islt=10000(strictly less). A file estimating exactly 10000 tokens passes the guard and then fails pydantic validation, raising instead of returning a clean error. Usele=10000or guard with>=. -
Dead code -
code_puppy/tools/universal_constructor.py:57_stub_not_implemented()is unused (all actions are implemented now). Also unused imports kept alive:time/ThreadPoolExecutor/FuturesTimeoutErrorare used, but checksubprocessusage is only for ruff - fine; just remove_stub_not_implemented. -
tools/common.pybrighten_hex()docstring says "Darken a hex color" while the function name says brighten and the mathint(r * (1 + factor))brightens for positive factor. Three contradictory signals; fix the docstring. -
generate_group_id()(tools/common.py, end of file) builds an md5 of timestamp+random for a non-crypto uniqueness token -uuid4().hex[:8]says the same thing in one line without importing hashlib/random locally. -
code_puppy/tools/file_operations.py_read_file: total_lines countscontent.count("\n")of the returned slice when start_line/num_lines are set, but the emittedFileContentMessage.total_linesfield name implies whole-file lines - misleading for partial reads.
Filed by Zen Reviewer B (code-puppy-60635a)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the named functions in code_puppy/tools/file_modifications.py, code_puppy/tools/file_operations.py, code_puppy/tools/universal_constructor.py, and tools/common.py. Verify each listed cleanup and validation mismatch, then confirm that partial reads report the intended total_lines value and that the existing project tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100