Skip to content

Commit 5ada5f7

Browse files
committed
Reorder functions logically in ClientConnection.
Define callers after callees.
1 parent 033bf40 commit 5ada5f7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/websockets/asyncio/client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,6 @@ def factory() -> ClientConnection:
295295

296296
self._open_timeout = open_timeout
297297

298-
# async with connect(...) as ...: ...
299-
300-
async def __aenter__(self) -> ClientConnection:
301-
return await self
302-
303-
async def __aexit__(
304-
self,
305-
exc_type: type[BaseException] | None,
306-
exc_value: BaseException | None,
307-
traceback: TracebackType | None,
308-
) -> None:
309-
await self.connection.close()
310-
311298
# ... = await connect(...)
312299

313300
def __await__(self) -> Generator[Any, None, ClientConnection]:
@@ -333,6 +320,19 @@ async def __await_impl__(self) -> ClientConnection:
333320

334321
__iter__ = __await__
335322

323+
# async with connect(...) as ...: ...
324+
325+
async def __aenter__(self) -> ClientConnection:
326+
return await self
327+
328+
async def __aexit__(
329+
self,
330+
exc_type: type[BaseException] | None,
331+
exc_value: BaseException | None,
332+
traceback: TracebackType | None,
333+
) -> None:
334+
await self.connection.close()
335+
336336

337337
def unix_connect(
338338
path: str | None = None,

0 commit comments

Comments
 (0)