Skip to content

refactor: simplify send-request plumbing; wire mypy into pre-commit - #19

Merged
lukwam merged 3 commits into
mainfrom
refactor/send-options
Oct 26, 2026
Merged

lukwam merged 3 commits into
mainfrom
refactor/send-options

Conversation

@lukwam

@lukwam lukwam commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #17.

  • Wire mypy into pre-commit (abecbf6): this commit was sitting unpushed on a local main; it now goes through review.
  • _build_email_request: one dict with the None values filtered out, replacing eleven if x is not None blocks. False is still forwarded.
  • Per-send options: preheader, headers, send_to_unsubscribed, tracked and disable_message_retention pass through _send_inline as a typed **options: Unpack[_RequestOptions], so mypy still checks the keys and a new field can't be dropped in the middle layer. Public signatures are unchanged.
  • Tests: tracked/disable_message_retention on send_text/send_html for True, False and unset. Removing the forwarding in _send_inline makes 10 tests fail.

128 tests pass; mypy and ruff are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CDMxuV2fXnLmpJG3tgv2Yu

lukwam and others added 3 commits October 26, 2026 11:31
mypy was configured strict=true in pyproject.toml and listed as a dev
dependency, but nothing actually invoked it — pre-commit had no mypy
hook. Add a local repo hook that runs mypy on src/ during pre-commit
(and thus in CI's `pre-commit run --all-files` lint job).

Enabling it surfaced two pre-existing issues in client.py, both fixed:
- customerio's SDK ships no type stubs/py.typed marker, causing
  import-untyped errors; added a `[[tool.mypy.overrides]]` for
  `customerio.*` with ignore_missing_imports = true.
- _get_regions_class() returned an Any-typed symbol from the untyped
  customerio import where a type[Regions] was declared; added an
  explicit cast.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…rough as one

_build_email_request drops None values with a dict comprehension instead of
eleven if-blocks, and the pass-through fields (preheader, headers,
send_to_unsubscribed, tracked, disable_message_retention) travel through
_send_inline as a typed **options, so a new field can't be silently dropped
in the middle layer. Also covers tracked/disable_message_retention on
send_text/send_html for True, False and unset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CDMxuV2fXnLmpJG3tgv2Yu
language: system ran whatever mypy was on PATH, which is nothing outside
the Poetry venv, so a plain git commit failed with "Executable mypy not
found". poetry run uses the locked mypy and customerio SDK, so local runs
match CI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CDMxuV2fXnLmpJG3tgv2Yu
@lukwam
lukwam merged commit fb6d2e0 into main Oct 26, 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