Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions docs/reference/codec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
Expand All @@ -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()
```
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/state-machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down Expand Up @@ -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)
```
Expand Down Expand Up @@ -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`.
Expand Down
1 change: 0 additions & 1 deletion src/pygwire/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"BackendStateMachine",
"FrontendStateMachine",
"MessageAction",
"StateMachineError",
]

_P = ConnectionPhase
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
DHUKK marked this conversation as resolved.

conn = FrontendConnection(initial_phase=ConnectionPhase.READY, strict=True)
with pytest.raises(StateMachineError):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from pygwire.constants import TransactionStatus
from pygwire.exceptions import StateMachineError
from pygwire.messages import (
AuthenticationCleartextPassword,
AuthenticationMD5Password,
Expand Down Expand Up @@ -48,7 +49,6 @@
BackendStateMachine,
ConnectionPhase,
FrontendStateMachine,
StateMachineError,
)


Expand Down
Loading