mpfaffenberger / mpfaffenberger/code_puppy
Recommendations for cleanup
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 814
- Forks
- 278
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 76
Description
1. Kill the test bloat and mock avalanche
- Problem: tests are ~1.8x the size of the source, and 336/417 test files import unittest.mock. Many test files are clearly "coverage" padding (e.g. test_full_coverage.py, testcoverage.py,
test*_extended.py, test_remaining_coverage.py). - Cleanup: Merge coverage-only tests into real behavior tests. Delete files whose only purpose is to hit a line-count target. Replace MagicMock/patch heavy files with integration tests against the actual
plugin/module behavior.
2. Stop print()ing from production code
- Problem: 34 source files use print(). Some are demos/CLI helpers, but print() also appears in terminal_utils.py, cli_runner.py, plugin menus, and ask_user_question renderers.
- Cleanup: Route all output through the message bus / Rich renderer / logging. Remove or gate demo print() calls behind main blocks.
3. Replace silent except: pass with structured logging
- Problem: 39 source files have bare pass in exception handlers. This makes failures invisible.
- Cleanup: Every pass in an except block should log at debug or warning level, or re-raise if it is truly unrecoverable. Add a lint rule for bare except: pass.
4. Remove or finish TODOs
- Problem: only 4 TODOs, but they sit in http_utils.py, hook_engine/aliases.py (3x), and one is a docstring example.
- Cleanup: Resolve the hook engine alias TODOs or delete them if no longer needed. Remove the http_utils.py TODO by either implementing RetryingClient(httpx.Client) or deleting the comment.
5. Consolidate duplicated config/setting logic
- Problem: config.py is 2209 lines and contains many near-identical getter/setter pairs (temperature, top_p, seed, banner colors, output level, etc.). command_line/set_menu_catalog.py, model_settings_menu.py,
set_menu_values.py, etc. duplicate catalog logic. - Cleanup: Generate config keys/getters/setters from a single schema dataclass or dict. The existing set_menu_schema.py is a start but is not used to drive the actual config functions.
6. Unify HTTP clients
- Problem: httpx and requests are both used; requests appears in 8 source files (mostly OAuth plugins) and httpx in ~25. http_utils.py has a RetryingAsyncClient but no sync counterpart, and claude_cache_client.py
builds its own client. - Cleanup: Provide one async and one sync client factory in http_utils.py and make all plugins use them. Drop requests entirely if possible, or isolate it to one adapter.
7. Refactor the plugin registration explosion
- Problem: many plugins register only custom_command + custom_command_help and are essentially menu wrappers. Others register model types or agents. The surface area is huge.
- Cleanup: Introduce a Plugin base class or decorator that declares which phases it uses. Move boilerplate help/command registration into a shared mixin. This would shrink many register_callbacks.py files.
8. Split command_line/ into UI and command logic
- Problem: command_line/ has 62 files mixing Textual screens, completion, command handlers, and form wizards.
- Cleanup: Separate screens/ (Textual UI), commands/ (slash command implementations), and completions/ (prompt-toolkit completers). The current flat layout makes navigation hard.
9. Remove pickle session storage or sign it properly
- Problem: session_storage.py stores message history as pickles with a note that the legacy signed format was removed. Pickles are unsafe and a known footgun.
- Cleanup: Either sign pickles with HMAC again, or better, serialize to JSON/msgpack. pydantic-ai messages should be serializable to JSON already.
10. Reduce monkey-patching in pydantic_patches.py
- Problem: 543 lines of runtime monkey patches for pydantic-ai, termflow, prompt_toolkit, etc.
- Cleanup: Push upstream-compatible changes into wrapper classes (e.g. custom ToolManager, custom provider clients) instead of patching internals. Keep only patches that have no other hook.
11. Tighten environment variable access
- Problem: os.environ / os.getenv is scattered across 40+ files with inconsistent truthy checks.
- Cleanup: Centralize env access in config.py or provider_credentials.py. Provide typed helpers like get_bool_env, get_str_env.
12. Revisit the TUI/Textual dependency
- Problem: the repo is heavily investing in a Textual TUI (feat(tui) commits are everywhere in June) but pyproject.toml does not declare textual as a dependency.
- Cleanup: Either add textual (and any other TUI deps) to pyproject.toml or make the TUI code lazy/degradable when Textual is absent.
13. Simplify the model factory provider matrix
- Problem: model_factory.py has provider-specific code for ~10 providers with duplicated API-key/endpoint resolution logic.
- Cleanup: Drive provider construction from a declarative table (type → provider class, env var, default endpoint) and a single resolver function.
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
This is a project-wide cleanup list rather than one scoped task, with relevant entry points including config.py, http_utils.py, session_storage.py, pydantic_patches.py, pyproject.toml, and model_factory.py. First choose one numbered section and inspect its named files; no single test or completion criterion is provided, so the selected refactor needs its own scope and validation plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, build-system, cli, security, testing, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100