From 77cbba5ed8340a14e40c10c822e50a4ef2f5fbff Mon Sep 17 00:00:00 2001 From: Miro <200482516+Mirochill@users.noreply.github.com> Date: Mon, 18 May 2026 19:27:43 +0200 Subject: [PATCH 1/3] Require remote protocol error event hints --- src/wsproto/utilities.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wsproto/utilities.py b/src/wsproto/utilities.py index d02117a..5561af6 100644 --- a/src/wsproto/utilities.py +++ b/src/wsproto/utilities.py @@ -47,12 +47,12 @@ class RemoteProtocolError(ProtocolError): .. attribute:: event_hint - This is a suggested wsproto Event to send to the client based - on the error. It could be None if no hint is available. + This is the suggested wsproto Event to send to the client based + on the error. """ - def __init__(self, message: str, event_hint: Event | None = None) -> None: + def __init__(self, message: str, event_hint: Event) -> None: self.event_hint = event_hint super().__init__(message) From b1dc8d5f028081fd5746ab01f940801ab9602db7 Mon Sep 17 00:00:00 2001 From: Miro <200482516+Mirochill@users.noreply.github.com> Date: Mon, 18 May 2026 22:50:09 +0200 Subject: [PATCH 2/3] Document event hint API break --- CHANGELOG.rst | 6 ++++++ src/wsproto/utilities.py | 1 + 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 99ac2d4..fe46003 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Release History =============== +1.4.0 (unreleased) +------------------ + +- Require ``event_hint`` when constructing ``RemoteProtocolError``. + This is an API-breaking change. + 1.3.2 (2025-11-20) ------------------ diff --git a/src/wsproto/utilities.py b/src/wsproto/utilities.py index 5561af6..da339ff 100644 --- a/src/wsproto/utilities.py +++ b/src/wsproto/utilities.py @@ -52,6 +52,7 @@ class RemoteProtocolError(ProtocolError): """ + # API-breaking change for the next minor release: event_hint is required. def __init__(self, message: str, event_hint: Event) -> None: self.event_hint = event_hint super().__init__(message) From f40f1b3975a20f62fd4238dfe73284ce74991bf4 Mon Sep 17 00:00:00 2001 From: Miro <200482516+Mirochill@users.noreply.github.com> Date: Mon, 18 May 2026 23:00:43 +0200 Subject: [PATCH 3/3] Use versionchanged annotation for event hint --- src/wsproto/utilities.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wsproto/utilities.py b/src/wsproto/utilities.py index da339ff..414084c 100644 --- a/src/wsproto/utilities.py +++ b/src/wsproto/utilities.py @@ -50,9 +50,11 @@ class RemoteProtocolError(ProtocolError): This is the suggested wsproto Event to send to the client based on the error. + .. versionchanged:: 1.4.0 + Made ``event_hint`` a required argument. + """ - # API-breaking change for the next minor release: event_hint is required. def __init__(self, message: str, event_hint: Event) -> None: self.event_hint = event_hint super().__init__(message)