Skip to content

Fix incorrect docstrings and README guides - #142

Closed
phelma wants to merge 3 commits into
mainfrom
fix-store-docstrings
Closed

phelma wants to merge 3 commits into
mainfrom
fix-store-docstrings

Conversation

@phelma

@phelma phelma commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three commits, all docs-only:

  1. Docstrings (store/store.py)
 EventCategory
-  Categories are also iterable, supporting `iter`.
+  Categories are also async iterable, supporting `aiter` and `async for`.

 EventCategory.stream / EventStore.stream / EventStore.category
-  Returns: an event store scoped to the specified stream/category.
+  Returns: an `EventStream` / `EventCategory` for it.

 EventStream.publish
+  Args, Returns, Raises: UnmetWriteConditionError — nothing written

 EventCategory.publish
+  per-stream condition from each definition; result keyed by stream name
+  Raises: UnmetWriteConditionError — any unmet condition, nothing written
  1. Finalising state (README.md)
-  (via `state=`, and always by `ProjectionEventProcessor`)
+  via `state=`, or with `ProjectionEventProcessor` the state reloaded from
+  the projection store (`state=None` on a stream's first event)
-  `finalise_state` is a reserved name, so no event may be named `finalise-state`
+  nothing stops event names matching projector methods: `finalise-state`,
+  `apply`, `project` raise TypeError; `id-factory` silently replaces state
+  example extends `ProfileProjector` from the [basic example](#basic-example)
  1. Basic example (README.md)
-class ProfileProjector(Projector[StreamIdentifier, dict[str, str], dict[str, str]])
+class ProfileProjector(Projector[StreamIdentifier, dict[str, str]])
-    profile = projection.state
-# profile == {...}          (outside main)
+    print(projection.state)
+    # {'name': ..., 'email': ..., 'dob': ...}
+ note: third type argument is projection metadata, defaults to JsonValue
+ note: library logs via structlog, and how to show warnings only
  consistent publish calls, ≤79 columns, no trailing whitespace

Evidence

  • Before: docstrings claim iter(category) works and accessors return "an event store"; README example prints nothing and logs to stdout.
    After:
>>> type(category.stream(stream="o1")).__name__, type(category).__name__
('EventStream', 'EventCategory')
>>> iter(category)
TypeError: 'EventCategory' object is not iterable

event name      -> project() result
finalise-state  -> TypeError
apply           -> TypeError
project         -> TypeError
id-factory      -> OK, state = 'x'   (the projection id)

$ python readme_example.py   # with structlog configured for warnings
{'name': 'Joe Bloggs', 'email': 'joe.bloggs@example.com', 'dob': '1992-07-10'}

All-or-nothing category publish is covered by the shared adapter tests test_category_save_raises_if_any_*_condition_fails. ruff check and ruff format --check pass on store.py and the README code blocks.

Merge Danger

Door: two-way

Blast Radius: none

Docstrings and README only; no runtime change. docs-starlight-site will need its Getting started / Finalising state pages updated on rebase, with the #basic-example link becoming ../../getting-started/.

Categories are async iterable only, stream/category accessors return
EventStream/EventCategory, and publish docstrings now describe
conditions, return values and UnmetWriteConditionError.
Copilot AI balanced review requested due to automatic review settings November 3, 2026 15:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the event-store API documentation updates.

No open issues 🎉

What changed in this PR

Corrects event-store API docstrings to match existing behavior. All changes are documentation-only; runtime behavior is unchanged.

Changes:

  • Clarifies that categories support asynchronous iteration.
  • Identifies accessor return values as EventStream or EventCategory.
  • Documents publish arguments, return values, and write-condition failure guarantees.
File Description
src/​logicblocks/​event/​store/​store.py Corrects iteration and accessor documentation and expands publish-method docstrings.

Review effort: Balanced

Describe what state ProjectionEventProcessor actually passes, replace the
'reserved name' claim with the real handler-name clash behaviour, and
link ProfileProjector back to the basic example.
Print the projected state inside main(), drop the easily misread
projection-metadata type argument, explain structlog output and how to
quieten it, and tidy formatting.
@phelma phelma changed the title Fix incorrect docstrings in event store Fix incorrect docstrings and README guides Nov 3, 2026
@phelma
phelma added this pull request to stack #144 November 4, 2026 12:04
@phelma

phelma commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Closed in favour of #148, which combines the whole docs stack into one PR.

@phelma phelma closed this Nov 18, 2026
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.

2 participants