Skip to content

feat(local): allow write callbacks to suppress default storage - #684

Open
timothyanderson096-ocdealcheck wants to merge 1 commit into
canopen-python:masterfrom
timothyanderson096-ocdealcheck:feat/598-write-callback-storage
Open

timothyanderson096-ocdealcheck wants to merge 1 commit into
canopen-python:masterfrom
timothyanderson096-ocdealcheck:feat/598-write-callback-storage

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown

Allow LocalNode write callbacks to suppress the default data-store write by returning anything except None, while still invoking all registered callbacks in order. Addresses the requested enhancement in #598, reported by @sveinse and discussed with @acolomb.

Use an explicit is not None check after each callback and return only after the loop. This implements the discussion's stated non-None/all-callback contract without truthiness or generator short-circuiting. False, 0 and empty values also opt out. Document arguments, order, return semantics and exception propagation in the callback registration API.

Compatibility change: previously ignored non-None callback return values now suppress storage. Existing callbacks needing normal storage must return None. Prior stored data is left unchanged when opting out. Validation still precedes callbacks; callback exceptions propagate and prevent storage as before. Read-callback behavior, async dispatch and registration concurrency are unchanged.

Validation recorded 25 October 2026, Linux / CPython 3.12.14 / python-can 4.6.1: six of eleven requested-contract tests fail on original production source and five controls pass; these demonstrate an unimplemented enhancement, not six existing defects. Final focused new/existing LocalNode tests 30 passed, independently rerun. Full base suite 291 passed, one optional-export skip; export-enabled 292 passed; docs build succeeds and includes the callback contract. Fresh original/final optional mypy both retain 44 identical inherited errors in seven files, exit 1.

Tests cover false/empty/truthiness-resistant results, all-callback order, prior data preservation, default copying, kwargs, pre-callback rejection, exceptions, unchanged reads, NMT side effects and real client/server SDO callback round trips without a connected CAN backend. Baseline/final test ASTs match; two formatting-only wraps do not alter assertions.

On 27 October, public head bea9b0443464c482eab6f2cf6590e95de8747daa, tree 372d057a337c52a3ad2939e7be960f3aa3337d6d, exactly matches clean tested 3dfa5b5 on unchanged base 14b3336. Saved evidence and independent review were checked; no fresh project-suite rerun during publication. Related #676 subscriber dispatch and #359 async work do not supply this LocalNode storage behavior.

Physical devices, other OS/Python/minimum dependencies, async callbacks, concurrent registration, real application migration and integration with other prepared branches remain unvalidated. This is a proposed API enhancement, not an accepted compatibility policy or upstream approval.

Prepared with AI assistance and independent inspection during original preparation.

Timothy Anderson — Spotted Ridge Engineering / OC Labs
Independent software verification · GDN (Global Decision Network)
timothyanderson096@gmail.com · Engineering evidence

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