Skip to content

docs: add Coming-from-Python section + fix stale counts - #2

Merged
conorbronsdon merged 3 commits into
mainfrom
docs/python-onramp-and-accuracy
Jul 6, 2026
Merged

docs: add Coming-from-Python section + fix stale counts#2
conorbronsdon merged 3 commits into
mainfrom
docs/python-onramp-and-accuracy

Conversation

@conorbronsdon

Copy link
Copy Markdown
Owner

Summary

Two documentation changes:

  1. Coming from Python — a short side-by-side section (near the top, after
    the intro) mapping the familiar Python API to this library's real API.
    Every snippet was extracted from this repo's own examples/ and test/;
    nothing was invented.
  2. Accuracy fixes — Suite copy Ten -> Eleven and added mojo-xml link. Corrected protocol-test count 29 -> 34 in README (x2) and CHANGELOG. Re-verified by counting: 34 protocol tests in test/test_resp.mojo + 21 integration tests in test/test_integration.mojo.

Test counts were re-verified by actually counting the test functions in the
repo (not trusting the prior text).

From an automated review (personal-context#62); drafted by Claude Code — please review the Coming-from-Python snippets for API accuracy.

conorbronsdon and others added 3 commits July 5, 2026 23:01
…the process

Writing to a socket whose peer has closed delivered SIGPIPE, whose default
disposition terminates the whole process (exit 141) before send() could
return EPIPE — so the existing `n <= 0 -> raise` error path in _send_all
never ran. CPython dodges this by installing SIG_IGN for SIGPIPE at startup;
a Mojo process does not.

Suppress the signal at the syscall boundary, platform-gated:
- Linux: pass MSG_NOSIGNAL (0x4000) in the send() flags.
- macOS/BSD: set SO_NOSIGPIPE via setsockopt(2) right after socket()
  (there is no MSG_NOSIGNAL). Platform chosen at comptime via
  CompilationTarget.

A dead peer now raises a catchable Error. Added test/test_connection.mojo,
a self-contained regression test (stands up its own loopback peer via FFI,
no Redis server) wired into CI, so it exercises the Linux MSG_NOSIGNAL path
on the ubuntu runner. Against the unfixed code this test terminates the test
binary with signal 13 (exit 141); with the fix it passes.

Also fixes a build-blocking pixi pin: `mojo = ">=1.0.0b3"` sorts after the
dev nightlies (1.0.0b3.dev…) so `pixi install` found no candidates; pinned
to `>=1.0.0b3.dev0,<2`.

Co-Authored-By: Claude <noreply@anthropic.com>
Adds a "Coming from Python" on-ramp table (verified against the repo's own
examples/ and tests) and corrects suite/test-count accuracy issues.

Co-Authored-By: Claude <noreply@anthropic.com>
The SIGPIPE/DoS/pixi code + its CHANGELOG entries belong to the security
fix PR; this branch is docs (Coming-from-Python + test count) only.

Co-Authored-By: Claude <noreply@anthropic.com>
@conorbronsdon

Copy link
Copy Markdown
Owner Author

🤖 Independent Claude review: Ready.

Verified every Mojo snippet in the diff against real source — no invented APIs.

"Coming from Python" table — all methods exist in src/redis/client.mojo and are exercised in examples/demo.mojo:

  • Redis(host, port)Redis.__init__(out self, var host, port)
  • set("k","v") / set("k","v", ex=60)set(..., ex: Optional[Int] = None) ✓ (demo L26/L29)
  • get("k").value()get(...) -> Optional[String] ✓ (demo L27)
  • incr / decr → both present ✓
  • hset("h","f","v") / hgetall("h")hset(key, field, value), hgetall(key) -> Dict ✓ (demo L45-47)
  • Optional note (.value() / Bool(...)) matches the real Optional[String] return type ✓

Counts:

  • "34 protocol unit tests" (CHANGELOG + README ×2) → exactly 34 test_ fns in test/test_resp.mojo
  • "Eleven pure-Mojo libraries" → 10 sibling libs listed + mojo-redis itself = 11, internally consistent ✓ (mojo-xml correctly added)

Python-side snippets are idiomatic redis-py (redis.Redis(host, port), set(..., ex=), hset(h, f, v)).

No blocking issues.

@conorbronsdon
conorbronsdon marked this pull request as ready for review July 6, 2026 07:58
@conorbronsdon

Copy link
Copy Markdown
Owner Author

Docs review (sonnet): SHIP

redis-py-shaped table (Redis(host, port), set/get/incr/hset/hgetall, ex=) matches src/redis/client.mojo exactly; the .value() caveat for get's Optional[String] is accurate and consistent with the existing README example. The 29→34 protocol-test-count fix is a genuine correction (recounted 34 in test/test_resp.mojo), applied consistently across README ×2 + CHANGELOG with no stale "29" left. Ship.

@conorbronsdon
conorbronsdon merged commit 6553240 into main Jul 6, 2026
1 check passed
@conorbronsdon
conorbronsdon deleted the docs/python-onramp-and-accuracy branch July 6, 2026 08:13
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