-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All public API within this module are deprecated since version 9.0 so there's nothing to document.
- Loading branch information
Showing
3 changed files
with
26 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
from __future__ import annotations | ||
|
||
import typing | ||
import warnings | ||
|
||
from .imports import lazy_import | ||
from .datastructures import Headers, MultipleValuesError # noqa: F401 | ||
from .legacy.http import read_request, read_response # noqa: F401 | ||
|
||
|
||
# For backwards compatibility: | ||
|
||
|
||
# When type checking, import non-deprecated aliases eagerly. Else, import on demand. | ||
if typing.TYPE_CHECKING: | ||
from .datastructures import Headers, MultipleValuesError # noqa: F401 | ||
else: | ||
lazy_import( | ||
globals(), | ||
# Headers and MultipleValuesError used to be defined in this module. | ||
aliases={ | ||
"Headers": ".datastructures", | ||
"MultipleValuesError": ".datastructures", | ||
}, | ||
deprecated_aliases={ | ||
"read_request": ".legacy.http", | ||
"read_response": ".legacy.http", | ||
}, | ||
) | ||
warnings.warn( | ||
"Headers and MultipleValuesError were moved " | ||
"from websockets.http to websockets.datastructures" | ||
"and read_request and read_response were moved " | ||
"from websockets.http to websockets.legacy.http", | ||
DeprecationWarning, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from websockets.datastructures import Headers | ||
|
||
from .utils import DeprecationTestCase | ||
|
||
|
||
class BackwardsCompatibilityTests(DeprecationTestCase): | ||
def test_headers_class(self): | ||
with self.assertDeprecationWarning( | ||
"Headers and MultipleValuesError were moved " | ||
"from websockets.http to websockets.datastructures" | ||
"and read_request and read_response were moved " | ||
"from websockets.http to websockets.legacy.http", | ||
): | ||
from websockets.http import Headers as OldHeaders | ||
|
||
self.assertIs(OldHeaders, Headers) |