Skip to content

Scraper: structured logging + packaging (console entry point)#9

Merged
cybermejo merged 2 commits into
mainfrom
worktree-scraper-package-11
Jun 18, 2026
Merged

Scraper: structured logging + packaging (console entry point)#9
cybermejo merged 2 commits into
mainfrom
worktree-scraper-package-11

Conversation

@cybermejo

Copy link
Copy Markdown
Owner

Summary

Knocks out two of the three remaining README Roadmap items for the scraper: structured logging and packaging. (The third — splitting tweet_scraper.py into a package — is deliberately deferred to its own PR; see note below.)

1. Logging

  • Replaced the 9 print(..., file=sys.stderr) progress/warning calls with a module logger (logging.getLogger("tweet_scraper")), configured INFO → stderr in main().
  • Importers/callers now control verbosity and handlers instead of getting hardcoded stderr writes.
  • Dry-run output stays on stdout via print() — it's the program's actual result, not progress chatter, so it remains pipeable.
  • Updated the unknown-key warning test from capsys to caplog.

2. Packaging

  • Added a [project] table (name/version/deps/requires-python), a setuptools build-system, and a [project.scripts] console entry point.
  • pip install -e . now exposes a tweet-scraper command. Verified end-to-end: installs in a clean venv and the entry point runs --dry-run.
  • Removed the old "intentionally NOT a packaging manifest" deferral comment.

Testing

Full validation loop green from scraper/ (ruff, ruff format --check, mypy, pytest) — 59 tests pass.

Deferred (separate PR)

Splitting the 630-line module into config/api/query/cli submodules is not included here. It would force rewriting ~20 test mock patch targets (patch("tweet_scraper.requests.get") etc.) since those names would move into submodules — a test-internals change worth isolating in its own reviewable PR. The module's seams are already clean, so it stays cheap to do later.

Christian-Bermejo added 2 commits June 18, 2026 09:47
Progress/warning output went through print(..., file=sys.stderr). Switch to a
module logger configured (INFO -> stderr) in main(), so callers/importers control
verbosity and handlers. Dry-run output stays on stdout via print() — it is the
program's actual result, not progress chatter.

Updates the unknown-key warn test from capsys to caplog. 59 tests green.
pyproject.toml was tooling-config only, with a comment deferring packaging.
Add a [project] table (name/version/deps/requires-python), a setuptools
build-system, and a console_scripts entry point so 'pip install -e .' exposes a
'tweet-scraper' command. Verified the CLI installs and the entry point runs
--dry-run. Validation loop still green (59 tests).
@cybermejo
cybermejo merged commit f246599 into main Jun 18, 2026
4 checks passed
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