Skip to content

Commit a7b2400

Browse files
committed
Restore real imports for compatibility with mypy.
Fix #940.
1 parent 839e6d6 commit a7b2400

File tree

8 files changed

+22
-30
lines changed

8 files changed

+22
-30
lines changed

docs/api/client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Client
22
======
33

4-
.. automodule:: websockets.legacy.client
4+
.. automodule:: websockets.client
55

66
Opening a connection
77
--------------------

docs/api/index.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,10 @@ both in the client API and server API.
4646
utilities
4747

4848
All public APIs can be imported from the :mod:`websockets` package, unless
49-
noted otherwise. Anything that isn't listed in this API documentation is a
50-
private API, with no guarantees of behavior or backwards-compatibility.
49+
noted otherwise. This convenience feature is incompatible with static code
50+
analysis tools such as mypy_, though.
51+
52+
.. _mypy: https://github.com/python/mypy
53+
54+
Anything that isn't listed in this API documentation is a private API. There's
55+
no guarantees of behavior or backwards-compatibility for private APIs.

docs/api/server.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Server
22
======
33

4-
.. automodule:: websockets.legacy.server
4+
.. automodule:: websockets.server
55

66
Starting a server
77
-----------------
@@ -90,7 +90,7 @@ Server
9090
Basic authentication
9191
--------------------
9292

93-
.. automodule:: websockets.legacy.auth
93+
.. automodule:: websockets.auth
9494

9595
.. autofunction:: basic_auth_protocol_factory
9696

docs/changelog.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ fixing regressions shortly after a release.
2525
Only documented APIs are public. Undocumented APIs are considered private.
2626
They may change at any time.
2727

28-
9.1
29-
...
28+
9.0.2
29+
.....
3030

3131
*In development*
3232

33+
* Restored compatibility with mypy.
34+
3335
9.0.1
3436
.....
3537

docs/extensions.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ specification, WebSocket Per-Message Deflate, specified in :rfc:`7692`.
1414
Per-Message Deflate
1515
-------------------
1616

17-
:func:`~websockets.legacy.client.connect` and
18-
:func:`~websockets.legacy.server.serve` enable the Per-Message Deflate
19-
extension by default.
17+
:func:`~websockets.client.connect` and :func:`~websockets.server.serve` enable
18+
the Per-Message Deflate extension by default.
2019

2120
If you want to disable it, set ``compression=None``::
2221

src/websockets/auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# See #940 for why lazy_import isn't used here for backwards compatibility.
2+
from .legacy.auth import * # noqa

src/websockets/client.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
)
2525
from .http import USER_AGENT, build_host
2626
from .http11 import Request, Response
27-
from .imports import lazy_import
2827
from .typing import (
2928
ConnectionOption,
3029
ExtensionHeader,
@@ -35,15 +34,9 @@
3534
from .uri import parse_uri
3635
from .utils import accept_key, generate_key
3736

37+
# See #940 for why lazy_import isn't used here for backwards compatibility.
38+
from .legacy.client import * # noqa
3839

39-
lazy_import(
40-
globals(),
41-
aliases={
42-
"connect": ".legacy.client",
43-
"unix_connect": ".legacy.client",
44-
"WebSocketClientProtocol": ".legacy.client",
45-
},
46-
)
4740

4841
__all__ = ["ClientConnection"]
4942

src/websockets/server.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
)
2727
from .http import USER_AGENT
2828
from .http11 import Request, Response
29-
from .imports import lazy_import
3029
from .typing import (
3130
ConnectionOption,
3231
ExtensionHeader,
@@ -36,16 +35,8 @@
3635
)
3736
from .utils import accept_key
3837

39-
40-
lazy_import(
41-
globals(),
42-
aliases={
43-
"serve": ".legacy.server",
44-
"unix_serve": ".legacy.server",
45-
"WebSocketServerProtocol": ".legacy.server",
46-
"WebSocketServer": ".legacy.server",
47-
},
48-
)
38+
# See #940 for why lazy_import isn't used here for backwards compatibility.
39+
from .legacy.server import * # noqa
4940

5041

5142
__all__ = ["ServerConnection"]

0 commit comments

Comments
 (0)