Skip to content

Commit

Permalink
Add compatibility imports from legacy package in __all__.
Browse files Browse the repository at this point in the history
Supersedes #1400.
  • Loading branch information
aaugustin committed Oct 1, 2023
1 parent c41ce81 commit 1b10ca1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/websockets/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from __future__ import annotations

# See #940 for why lazy_import isn't used here for backwards compatibility.
# See #1400 for why listing compatibility imports in __all__ helps PyCharm.
from .legacy.auth import *
from .legacy.auth import __all__ # noqa: F401
4 changes: 3 additions & 1 deletion src/websockets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@


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


__all__ = ["ClientProtocol"]
__all__ = ["ClientProtocol"] + legacy__all__


class ClientProtocol(Protocol):
Expand Down
4 changes: 3 additions & 1 deletion src/websockets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@


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


__all__ = ["ServerProtocol"]
__all__ = ["ServerProtocol"] + legacy__all__


class ServerProtocol(Protocol):
Expand Down
10 changes: 3 additions & 7 deletions tests/test_exports.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import unittest

import websockets
import websockets.auth
import websockets.client
import websockets.exceptions
import websockets.legacy.auth
import websockets.legacy.client
import websockets.legacy.protocol
import websockets.legacy.server
import websockets.server
import websockets.typing
import websockets.uri


combined_exports = (
websockets.legacy.auth.__all__
+ websockets.legacy.client.__all__
+ websockets.legacy.protocol.__all__
+ websockets.legacy.server.__all__
websockets.auth.__all__
+ websockets.client.__all__
+ websockets.exceptions.__all__
+ websockets.legacy.protocol.__all__
+ websockets.server.__all__
+ websockets.typing.__all__
+ websockets.uri.__all__
Expand Down

0 comments on commit 1b10ca1

Please sign in to comment.