Skip to content

Type Packet.stream as StreamT | None - #2475

Merged
WyattBlue merged 1 commit into
masterfrom
packet-stream-optional
Oct 25, 2026
Merged

WyattBlue merged 1 commit into
masterfrom
packet-stream-optional

Conversation

@WyattBlue

Copy link
Copy Markdown
Member

Packet.stream is None for packets that weren't demuxed or encoded by a stream: Packet(), Packet(b"..."), and packets from CodecContext.encode/parse. The stub claimed it was always set.

  • Getter returns StreamT | None
  • Setter still takes StreamT; assigning None raises TypeError at runtime

Demuxed packets always have a stream, so code reading packet.stream now needs to narrow it. In this repo that was two spots in tests/test_streams.py (one now uses packet.stream_index); examples/ mypy output is unchanged.

Packets that weren't demuxed or encoded by a stream, such as `Packet()`
or those from `CodecContext.encode` and `parse`, have no stream. The
setter still requires a stream; assigning `None` raises `TypeError`.
@WyattBlue
WyattBlue merged commit 1b9c5f6 into master Oct 25, 2026
9 checks passed
@WyattBlue
WyattBlue deleted the packet-stream-optional branch October 25, 2026 01:18
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