Skip to content

Move the source into a palmer/ package, tests into tests/, scripts into scripts/ - #13

Merged
pythonjeff merged 2 commits into
mainfrom
chore/package-layout
Oct 15, 2026
Merged

pythonjeff merged 2 commits into
mainfrom
chore/package-layout

Conversation

@pythonjeff

Copy link
Copy Markdown
Owner

Summary

Stage 2 of 4 (hygiene → package layout → test consolidation → docs split). Pure relocation: no function changed, and the suite is 1,430 tests before and after. The repo root goes from ~100 entries to ten.

palmer/          every library module + trusted_sources.json
scripts/         send_morning, send_reminders, preview_opening, migrate_profile_prune
                 → run as `python -m scripts.<name>`
tests/           the 51 test files, unchanged apart from imports
pyproject.toml   pytest + ruff config (replaces ruff.toml); tool config only
  • send_reminders.py was both a library (main.py imports it) and a script, so it becomes palmer/reminders.py with a three-line shim in scripts/.
  • Imports are absolute (from palmer import db) so import lines and patch strings share one spelling. The 318 patch targets were rewritten by a pass anchored on patch( / import_module( / __import__( plus an allow-list of first-party names — never on bare quoted words, since "home", "weather", "opening" are also payload keys.
  • Hand edits: db._DB_PATH resolves to the repo root; test_sources reads the JSON beside sources.py; test_phantom_history reads sender source from palmer.__file__; the "alerts is gone" assertion now imports palmer.alerts (it would otherwise pass vacuously); three __import__("x") sites became importlib.import_module because a dotted name returns the top-level package.
  • Procfile → uvicorn palmer.main:app. Commands in CLAUDE.md and README updated.

After merging, deploy needs a push: git pull origin main && git push heroku main, then watch heroku logs --tail for the boot line and the nine job registrations. The Procfile change is the only production-visible difference.

Test plan

  • ruff check . clean
  • pytest -q — 1,430 passed, same as main
  • PALMER_NO_SCHEDULER=1 python -c "import palmer.main, scripts.send_morning, scripts.send_reminders, scripts.preview_opening, scripts.migrate_profile_prune" imports, nothing sent
  • uvicorn palmer.main:app boots locally and answers HTTP
  • No bare first-party import x / patch("x.…") left in the tree
  • CI green
  • Heroku boot after merge

🤖 Generated with Claude Code

https://claude.ai/code/session_018QpUhnYC3U7KxF8QCeenfQ

…ripts into scripts/

Pure relocation. No function changed; the suite is 1,430 tests before and
after. The repo root goes from ~100 entries to ten.

    palmer/     every library module plus trusted_sources.json
    scripts/    send_morning, send_reminders, preview_opening,
                migrate_profile_prune — run as `python -m scripts.<name>`
    tests/      the 51 test files, unchanged apart from imports
    pyproject.toml   pytest (testpaths, pythonpath=".") and ruff config;
                     replaces ruff.toml. Tool config only — Palmer is
                     deployed from requirements.txt and run from the repo
                     root, not built as a package.

send_reminders.py was both a library (main.py imports send_due_reminders)
and a script, so it becomes palmer/reminders.py with a three-line shim in
scripts/. tickers and wxaudit keep their __main__ blocks inside the package
(`python -m palmer.tickers --audit`, `python -m palmer.wxaudit`).

Imports are absolute (`from palmer import db`, `from palmer.weather import
x`) so import lines and patch strings share one spelling. The 318 patch
targets were rewritten by a pass anchored on `patch(`, `import_module(`
and `__import__(` plus an allow-list of first-party names — never on bare
quoted words, because "home", "weather", "opening" and "morning" are also
payload keys and DB columns.

Hand edits the mechanical pass could not make:
- db._DB_PATH now resolves to the repo root, not inside the package.
- test_sources reads trusted_sources.json beside sources.py rather than
  beside itself; test_phantom_history reads the proactive senders' source
  from palmer.__file__ instead of bare filenames against the CWD.
- test_scheduler_config's "alerts is gone" assertion imports
  palmer.alerts, or it would have passed vacuously for the wrong reason.
- Three tests used __import__("x") to reach a module; with a dotted name
  that returns the top-level package, so they use importlib.import_module.
- Procfile: uvicorn palmer.main:app. Commands in CLAUDE.md and README
  updated to match.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018QpUhnYC3U7KxF8QCeenfQ
Resolves the freshness-test import conflict and moves the new morning/page
tests onto the palmer package paths.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pythonjeff
pythonjeff merged commit d7836df into main Oct 15, 2026
1 check passed
@pythonjeff
pythonjeff deleted the chore/package-layout branch October 15, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant