Skip to content

Commit 1b10ca1

Browse files
committed
Add compatibility imports from legacy package in __all__.
Supersedes #1400.
1 parent c41ce81 commit 1b10ca1

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/websockets/auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from __future__ import annotations
22

33
# See #940 for why lazy_import isn't used here for backwards compatibility.
4+
# See #1400 for why listing compatibility imports in __all__ helps PyCharm.
45
from .legacy.auth import *
6+
from .legacy.auth import __all__ # noqa: F401

src/websockets/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@
3838

3939

4040
# See #940 for why lazy_import isn't used here for backwards compatibility.
41+
# See #1400 for why listing compatibility imports in __all__ helps PyCharm.
4142
from .legacy.client import * # isort:skip # noqa: I001
43+
from .legacy.client import __all__ as legacy__all__
4244

4345

44-
__all__ = ["ClientProtocol"]
46+
__all__ = ["ClientProtocol"] + legacy__all__
4547

4648

4749
class ClientProtocol(Protocol):

src/websockets/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939

4040

4141
# See #940 for why lazy_import isn't used here for backwards compatibility.
42+
# See #1400 for why listing compatibility imports in __all__ helps PyCharm.
4243
from .legacy.server import * # isort:skip # noqa: I001
44+
from .legacy.server import __all__ as legacy__all__
4345

4446

45-
__all__ = ["ServerProtocol"]
47+
__all__ = ["ServerProtocol"] + legacy__all__
4648

4749

4850
class ServerProtocol(Protocol):

tests/test_exports.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import unittest
22

33
import websockets
4+
import websockets.auth
45
import websockets.client
56
import websockets.exceptions
6-
import websockets.legacy.auth
7-
import websockets.legacy.client
87
import websockets.legacy.protocol
9-
import websockets.legacy.server
108
import websockets.server
119
import websockets.typing
1210
import websockets.uri
1311

1412

1513
combined_exports = (
16-
websockets.legacy.auth.__all__
17-
+ websockets.legacy.client.__all__
18-
+ websockets.legacy.protocol.__all__
19-
+ websockets.legacy.server.__all__
14+
websockets.auth.__all__
2015
+ websockets.client.__all__
2116
+ websockets.exceptions.__all__
17+
+ websockets.legacy.protocol.__all__
2218
+ websockets.server.__all__
2319
+ websockets.typing.__all__
2420
+ websockets.uri.__all__

0 commit comments

Comments
 (0)