Skip to content

Commit

Permalink
Change Sans-I/O constructors to keyword-only.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Nov 27, 2022
1 parent f5ea94a commit 3573119
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/project/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Backwards-incompatible changes
``client.ClientConnection`` classes were renamed to ``protocol.Protocol``,
``server.ServerProtocol``, and ``client.ClientProtocol``.

.. admonition:: Sans-I/O protocol constructors now use keyword-only arguments.
:class: caution

If you instantiate :class:`~server.ServerProtocol` or
:class:`~client.ClientProtocol` directly, make sure you are using keyword
arguments.

.. admonition:: Closing a connection without an empty close frame is OK.
:class: note

Expand Down
1 change: 1 addition & 0 deletions src/websockets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ClientProtocol(Protocol):
def __init__(
self,
wsuri: WebSocketURI,
*,
origin: Optional[Origin] = None,
extensions: Optional[Sequence[ClientExtensionFactory]] = None,
subprotocols: Optional[Sequence[Subprotocol]] = None,
Expand Down
1 change: 1 addition & 0 deletions src/websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Protocol:
def __init__(
self,
side: Side,
*,
state: State = OPEN,
max_size: Optional[int] = 2**20,
logger: Optional[LoggerLike] = None,
Expand Down
1 change: 1 addition & 0 deletions src/websockets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ServerProtocol(Protocol):

def __init__(
self,
*,
origins: Optional[Sequence[Optional[Origin]]] = None,
extensions: Optional[Sequence[ServerExtensionFactory]] = None,
subprotocols: Optional[Sequence[Subprotocol]] = None,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,6 @@ def test_server_connection_class(self):
):
from websockets.server import ServerConnection

server = ServerConnection("ws://localhost/")
server = ServerConnection()

self.assertIsInstance(server, ServerProtocol)

0 comments on commit 3573119

Please sign in to comment.