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

Open
#447 0 comments 0 reactions 0 assignees View on GitHub

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):

  1. Mutable default argument - code_puppy/tools/file_modifications.py register_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).

  1. ReadFileOutput.num_tokens: conint(lt=10000) off-by-one crash - code_puppy/tools/file_operations.py:40 + _read_file (~line 545): the guard is if num_tokens > 10000: return error, but the model constraint is lt=10000 (strictly less). A file estimating exactly 10000 tokens passes the guard and then fails pydantic validation, raising instead of returning a clean error. Use le=10000 or guard with >=.

  2. 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/FuturesTimeoutError are used, but check subprocess usage is only for ruff - fine; just remove _stub_not_implemented.

  3. tools/common.py brighten_hex() docstring says "Darken a hex color" while the function name says brighten and the math int(r * (1 + factor)) brightens for positive factor. Three contradictory signals; fix the docstring.

  4. 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.

  5. code_puppy/tools/file_operations.py _read_file: total_lines counts content.count("\n") of the returned slice when start_line/num_lines are set, but the emitted FileContentMessage.total_lines field 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.