Skip to content

Fix WebSocketMessage type contract - #1032

Open
pengpengyi92 wants to merge 1 commit into
massive-com:masterfrom
pengpengyi92:fix-websocket-message-type-contract
Open

Fix WebSocketMessage type contract#1032
pengpengyi92 wants to merge 1 commit into
massive-com:masterfrom
pengpengyi92:fix-websocket-message-type-contract

Conversation

@pengpengyi92

@pengpengyi92 pengpengyi92 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • define WebSocketMessage as the union of individual parsed event models instead of a new type over a list
  • keep batch callbacks typed as List[WebSocketMessage], matching the runtime parser output
  • add runtime and mypy regression coverage for single-event and batch contracts

Root cause

parse_single() returns one event model, while parse() returns a list. The previous alias represented a list itself, so callback annotations became a nested List[WebSocketMessage] and parse_single() needed an unsafe cast to hide the mismatch.

Validation

  • python -m unittest discover -s test_websocket (3 passed)
  • mypy massive test_websocket (50 files, no issues)
  • black --check massive test_websocket
  • git diff --check

The REST suite could not start locally because its longest fixture path is corrupted by the Windows non-ASCII workspace path; all failures occurred while loading the same unrelated fixture before test execution. Upstream CI should provide the full Linux run.

Closes #1022

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.

Inconsistent typing for WebSocketMessage and WebSocketClient.run() callback in v2.8.0

1 participant