mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 21:27:14 +01:00
Some checks are pending
BREAKING: sync_log's flat keyword arguments are replaced by SyncTarget, LogCodec and RevisionTracking. Callers change from eleven loose keywords to four positional arguments; every consumer repo is updated in the same pass. Eleven parameters on one function was the last real pylint finding in the package, and the grouping is the fix rather than a workaround: the three bundles are the three things a tick actually needs -- where to sync, how to serialize, and whether to track revisions -- and each documents its own fields. SyncTarget.own_ids also moves the "this device plus its pre-migration id" rule onto the type that owns it, instead of recomputing it inline. Internals follow: _pull_remote_logs takes a _PullContext instead of eight positionals, and the push half splits into _merge_peers/_push, which is what clears the 21-locals finding. The two duplicated in-memory fakes merge into one FakeStore in conftest, as does the no-bulk-read wrapper around it -- the shared half was the fiddly prefix slicing, which is exactly where two copies drift. crdt_sync now scores a clean 10.00/10 on pylint. Two suppressions remain, both scoped and explained at the line: asserting on a private attribute IS the timeout test, and reversing merge_record's operands IS the commutativity test. 259 tests, still 100% branch coverage. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCucBhUkHBBHHbsY7bSdGV
98 lines
2.3 KiB
Python
98 lines
2.3 KiB
Python
"""Shared CRDT merge scheme + pluggable remote sync transports."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from crdt_sync._config import (
|
|
CONFIG_DIR,
|
|
CONFIG_FILE,
|
|
PASSWORD_FILE,
|
|
ConfigError,
|
|
FirebaseConfig,
|
|
credential_store_for,
|
|
firebase_client_for,
|
|
mirror_client_for,
|
|
)
|
|
from crdt_sync._device import DeviceIdentity, load_device_identity
|
|
from crdt_sync._firebase import (
|
|
DatabaseNotFoundError,
|
|
FirebaseSyncClient,
|
|
FirebaseSyncError,
|
|
)
|
|
from crdt_sync._firebase_auth import (
|
|
CredentialStore,
|
|
FileCredentialStore,
|
|
FirebaseAuthError,
|
|
FirebaseCredentials,
|
|
FirebaseTokenProvider,
|
|
MemoryCredentialStore,
|
|
)
|
|
from crdt_sync._github import GitHubSyncClient, GitHubSyncError, RepoNotFoundError
|
|
from crdt_sync._hlc import Hlc
|
|
from crdt_sync._log import Log, merge_logs
|
|
from crdt_sync._mirror import MirrorSyncClient
|
|
from crdt_sync._record import Field, Record, merge_field, merge_record
|
|
from crdt_sync._remote import RemoteNotFoundError, RemoteStore, RemoteSyncError
|
|
from crdt_sync._store import dump_log, load_log, read_log, write_log
|
|
from crdt_sync._sync import (
|
|
FileSyncStateStore,
|
|
LogCodec,
|
|
MemorySyncStateStore,
|
|
RevisionTracking,
|
|
SyncState,
|
|
SyncStateStore,
|
|
SyncTarget,
|
|
default_revs_path,
|
|
revision_of,
|
|
sync_log,
|
|
)
|
|
|
|
__all__ = [
|
|
"CONFIG_DIR",
|
|
"CONFIG_FILE",
|
|
"PASSWORD_FILE",
|
|
"ConfigError",
|
|
"CredentialStore",
|
|
"DatabaseNotFoundError",
|
|
"DeviceIdentity",
|
|
"Field",
|
|
"FileCredentialStore",
|
|
"FileSyncStateStore",
|
|
"FirebaseAuthError",
|
|
"FirebaseConfig",
|
|
"FirebaseCredentials",
|
|
"FirebaseSyncClient",
|
|
"FirebaseSyncError",
|
|
"FirebaseTokenProvider",
|
|
"GitHubSyncClient",
|
|
"GitHubSyncError",
|
|
"Hlc",
|
|
"Log",
|
|
"LogCodec",
|
|
"MemoryCredentialStore",
|
|
"MemorySyncStateStore",
|
|
"MirrorSyncClient",
|
|
"Record",
|
|
"RemoteNotFoundError",
|
|
"RemoteStore",
|
|
"RemoteSyncError",
|
|
"RepoNotFoundError",
|
|
"RevisionTracking",
|
|
"SyncState",
|
|
"SyncStateStore",
|
|
"SyncTarget",
|
|
"credential_store_for",
|
|
"default_revs_path",
|
|
"dump_log",
|
|
"firebase_client_for",
|
|
"load_device_identity",
|
|
"load_log",
|
|
"merge_field",
|
|
"merge_logs",
|
|
"merge_record",
|
|
"mirror_client_for",
|
|
"read_log",
|
|
"revision_of",
|
|
"sync_log",
|
|
"write_log",
|
|
]
|