Skip to content

Commit 1519541

Browse files
committed
Move asyncio compatibility to a new package.
1 parent 177ae7b commit 1519541

File tree

9 files changed

+10
-8
lines changed

9 files changed

+10
-8
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ branch = true
4747
omit = [
4848
# */websockets matches src/websockets and .tox/**/site-packages/websockets
4949
"*/websockets/__main__.py",
50-
"*/websockets/legacy/async_timeout.py",
51-
"*/websockets/legacy/compatibility.py",
50+
"*/websockets/asyncio/async_timeout.py",
51+
"*/websockets/asyncio/compatibility.py",
5252
"tests/maxi_cov.py",
5353
]
5454

src/websockets/asyncio/__init__.py

Whitespace-only changes.

src/websockets/legacy/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
cast,
1717
)
1818

19+
from ..asyncio.compatibility import asyncio_timeout
1920
from ..datastructures import Headers, HeadersLike
2021
from ..exceptions import (
2122
InvalidHandshake,
@@ -40,7 +41,6 @@
4041
from ..http import USER_AGENT
4142
from ..typing import ExtensionHeader, LoggerLike, Origin, Subprotocol
4243
from ..uri import WebSocketURI, parse_uri
43-
from .compatibility import asyncio_timeout
4444
from .handshake import build_request, check_response
4545
from .http import read_response
4646
from .protocol import WebSocketCommonProtocol

src/websockets/legacy/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
cast,
2424
)
2525

26+
from ..asyncio.compatibility import asyncio_timeout
2627
from ..datastructures import Headers
2728
from ..exceptions import (
2829
ConnectionClosed,
@@ -49,7 +50,6 @@
4950
)
5051
from ..protocol import State
5152
from ..typing import Data, LoggerLike, Subprotocol
52-
from .compatibility import asyncio_timeout
5353
from .framing import Frame
5454

5555

src/websockets/legacy/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
cast,
2222
)
2323

24+
from ..asyncio.compatibility import asyncio_timeout
2425
from ..datastructures import Headers, HeadersLike, MultipleValuesError
2526
from ..exceptions import (
2627
AbortHandshake,
@@ -42,7 +43,6 @@
4243
from ..http import USER_AGENT
4344
from ..protocol import State
4445
from ..typing import ExtensionHeader, LoggerLike, Origin, StatusLike, Subprotocol
45-
from .compatibility import asyncio_timeout
4646
from .handshake import build_response, check_request
4747
from .http import read_request
4848
from .protocol import WebSocketCommonProtocol

tests/legacy/test_client_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import urllib.request
1515
import warnings
1616

17+
from websockets.asyncio.compatibility import asyncio_timeout
1718
from websockets.datastructures import Headers
1819
from websockets.exceptions import (
1920
ConnectionClosed,
@@ -30,7 +31,6 @@
3031
from websockets.frames import CloseCode
3132
from websockets.http import USER_AGENT
3233
from websockets.legacy.client import *
33-
from websockets.legacy.compatibility import asyncio_timeout
3434
from websockets.legacy.handshake import build_response
3535
from websockets.legacy.http import read_response
3636
from websockets.legacy.server import *

tests/maxi_cov.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def get_mapping(src_dir="src"):
5252
os.path.relpath(src_file, src_dir)
5353
for src_file in sorted(src_files)
5454
if "legacy" not in os.path.dirname(src_file)
55-
if os.path.basename(src_file) != "__init__.py"
55+
and os.path.basename(src_file) != "__init__.py"
5656
and os.path.basename(src_file) != "__main__.py"
57+
and os.path.basename(src_file) != "async_timeout.py"
5758
and os.path.basename(src_file) != "compatibility.py"
5859
]
5960
test_files = [
@@ -102,7 +103,8 @@ def get_ignored_files(src_dir="src"):
102103
"*/websockets/typing.py",
103104
# We don't test compatibility modules with previous versions of Python
104105
# or websockets (import locations).
105-
"*/websockets/*/compatibility.py",
106+
"*/websockets/asyncio/async_timeout.py",
107+
"*/websockets/asyncio/compatibility.py",
106108
"*/websockets/auth.py",
107109
# This approach isn't applicable to the test suite of the legacy
108110
# implementation, due to the huge test_client_server test module.

0 commit comments

Comments
 (0)