From c20cdc4bb9295e88853da72bba76f130f1c45528 Mon Sep 17 00:00:00 2001 From: DHUKK Date: Wed, 11 Mar 2026 18:16:55 +0000 Subject: [PATCH 1/3] Remove StateMachineError re-export from state_machine module Update all imports to use pygwire.exceptions or the top-level pygwire package instead. --- docs/reference/state-machine.md | 2 +- src/pygwire/state_machine.py | 1 - tests/unit/test_codec.py | 2 +- tests/unit/test_state_machine.py | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/reference/state-machine.md b/docs/reference/state-machine.md index 54dba45..7bf97dc 100644 --- a/docs/reference/state-machine.md +++ b/docs/reference/state-machine.md @@ -127,7 +127,7 @@ STARTUP → AUTHENTICATING → INITIALIZATION → READY ## `StateMachineError` ```python -from pygwire.state_machine import StateMachineError +from pygwire import StateMachineError ``` Raised when an invalid message is sent or received for the current connection phase. Subclass of `ProtocolError`. diff --git a/src/pygwire/state_machine.py b/src/pygwire/state_machine.py index 0c1d59c..1a7aad9 100644 --- a/src/pygwire/state_machine.py +++ b/src/pygwire/state_machine.py @@ -47,7 +47,6 @@ "BackendStateMachine", "FrontendStateMachine", "MessageAction", - "StateMachineError", ] _P = ConnectionPhase diff --git a/tests/unit/test_codec.py b/tests/unit/test_codec.py index a312d93..5d94a41 100644 --- a/tests/unit/test_codec.py +++ b/tests/unit/test_codec.py @@ -599,7 +599,7 @@ def test_strict_false_does_not_raise(self): def test_strict_true_raises(self): """Test that strict=True raises StateMachineError.""" - from pygwire.state_machine import StateMachineError + from pygwire import StateMachineError conn = FrontendConnection(initial_phase=ConnectionPhase.READY, strict=True) with pytest.raises(StateMachineError): diff --git a/tests/unit/test_state_machine.py b/tests/unit/test_state_machine.py index 593ed28..081438a 100644 --- a/tests/unit/test_state_machine.py +++ b/tests/unit/test_state_machine.py @@ -3,6 +3,7 @@ import pytest from pygwire.constants import TransactionStatus +from pygwire.exceptions import StateMachineError from pygwire.messages import ( AuthenticationCleartextPassword, AuthenticationMD5Password, @@ -48,7 +49,6 @@ BackendStateMachine, ConnectionPhase, FrontendStateMachine, - StateMachineError, ) From edde37f20b6601e4156c16a976f06f1d66c63db8 Mon Sep 17 00:00:00 2001 From: DHUKK Date: Wed, 11 Mar 2026 18:17:02 +0000 Subject: [PATCH 2/3] Use top-level pygwire package imports in docs --- docs/reference/codec.md | 4 ++-- docs/reference/connection.md | 2 +- docs/reference/state-machine.md | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/reference/codec.md b/docs/reference/codec.md index 325c5c6..30887b9 100644 --- a/docs/reference/codec.md +++ b/docs/reference/codec.md @@ -18,7 +18,7 @@ Both share the same API. Decoder for backend (server to client) messages. ```python -from pygwire.codec import BackendMessageDecoder +from pygwire import BackendMessageDecoder decoder = BackendMessageDecoder() ``` @@ -37,7 +37,7 @@ The decoder automatically uses phase-aware framing based on the current connecti Decoder for frontend (client to server) messages. ```python -from pygwire.codec import FrontendMessageDecoder +from pygwire import FrontendMessageDecoder decoder = FrontendMessageDecoder() ``` diff --git a/docs/reference/connection.md b/docs/reference/connection.md index a01ec24..380502c 100644 --- a/docs/reference/connection.md +++ b/docs/reference/connection.md @@ -115,7 +115,7 @@ conn = BackendConnection() ```python from pygwire import BackendConnection -from pygwire.constants import TransactionStatus +from pygwire import TransactionStatus from pygwire.messages import AuthenticationOk, ReadyForQuery, StartupMessage conn = BackendConnection() diff --git a/docs/reference/state-machine.md b/docs/reference/state-machine.md index 7bf97dc..8d66cfe 100644 --- a/docs/reference/state-machine.md +++ b/docs/reference/state-machine.md @@ -28,8 +28,8 @@ Both track a `ConnectionPhase` and raise `StateMachineError` if a message type i Tracks protocol state from the client's perspective. ```python -from pygwire.constants import ConnectionPhase -from pygwire.state_machine import FrontendStateMachine +from pygwire import ConnectionPhase +from pygwire import FrontendStateMachine sm = FrontendStateMachine(phase=ConnectionPhase.STARTUP) ``` @@ -64,8 +64,8 @@ Record receiving a backend message. Raises `StateMachineError` if the message is Tracks protocol state from the server's perspective. Same API as `FrontendStateMachine`. ```python -from pygwire.constants import ConnectionPhase -from pygwire.state_machine import BackendStateMachine +from pygwire import ConnectionPhase +from pygwire import BackendStateMachine sm = BackendStateMachine(phase=ConnectionPhase.STARTUP) ``` From 13b90925211010a8c5519fddae6112ffcce114cc Mon Sep 17 00:00:00 2001 From: DHUKK Date: Wed, 11 Mar 2026 18:17:04 +0000 Subject: [PATCH 3/3] Add changelog entries for unreleased changes since v0.0.2 --- CHANGELOG.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3efd079..bed8f0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `FramingError` and `DecodingError` exception subclasses of `ProtocolError` for fine-grained error handling. +- `BackendMessageDecoder` and `FrontendMessageDecoder` exported from the top-level `pygwire` package. +- `__all__` defined on all public modules. + +### Changed + +- `StateMachineError` moved to `pygwire.exceptions`. + +### Fixed + +- `FunctionCallResponse` registered under `FUNCTION_CALL` phase instead of `READY`. + +### Removed + +- `FrontendMessageType` and `BackendMessageType` enums (unused). +- `COPY_BOTH` phase and `CopyBothResponse` message (not part of the standard client/server protocol). + ## [0.0.2] - 2026-03-09 ### Added @@ -18,5 +37,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `FrontendConnection` and `BackendConnection` coordinating decoder and state machine. - `py.typed` marker for PEP 561 typed package support. -[Unreleased]: https://github.com/DHUKK/pygwire/compare/v0.0.1...HEAD +[Unreleased]: https://github.com/DHUKK/pygwire/compare/v0.0.2...HEAD +[0.0.2]: https://github.com/DHUKK/pygwire/releases/tag/v0.0.2 [0.0.1]: https://github.com/DHUKK/pygwire/releases/tag/v0.0.1