Skip to content

fix: updated Client.watch_snapshot to use proper dataclass as argument type#40

Merged
petruki merged 1 commit intomasterfrom
staging
Mar 11, 2026
Merged

fix: updated Client.watch_snapshot to use proper dataclass as argument type#40
petruki merged 1 commit intomasterfrom
staging

Conversation

@petruki
Copy link
Member

@petruki petruki commented Mar 11, 2026

This pull request refactors the snapshot watching functionality to use a strongly typed callback class (WatchSnapshotCallback) instead of a generic dictionary for handling success and error callbacks. This change improves type safety, code clarity, and maintainability across the codebase. The update affects the main client API, internal watcher logic, tests, and documentation.

Refactoring to typed callback interface:

  • Introduced the WatchSnapshotCallback dataclass in switcher_client/lib/snapshot_watcher.py to replace the dictionary-based callback contract, providing explicit success and reject handlers.
  • Updated Client.watch_snapshot and all related internal methods to accept and use WatchSnapshotCallback instead of a dictionary, ensuring type safety and clearer callback invocation. [1] [2] [3] [4]

API and usage updates:

  • Modified imports and exports in switcher_client/__init__.py, switcher_client/client.py, and all relevant files to expose and use WatchSnapshotCallback. [1] [2]
  • Updated usage examples in README.md and test/playground scripts to demonstrate the new callback interface. [1] [2] [3]

Test suite migration:

  • Refactored all tests in tests/test_client_watch_snapshot.py to use WatchSnapshotCallback for snapshot watching, ensuring coverage of the new interface and error handling. [1] [2] [3] [4]

@petruki petruki self-assigned this Mar 11, 2026
@petruki petruki added the enhancement New feature or request label Mar 11, 2026
@sonarqubecloud
Copy link

@petruki petruki merged commit 3ae72c3 into master Mar 11, 2026
15 checks passed
@petruki petruki deleted the staging branch March 11, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant