Skip to content

Commit ee0d744

Browse files
committed
Avoid shadowing an import with another import.
1 parent 8f12d8f commit ee0d744

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ exclude_lines = [
6767
"except ImportError:",
6868
"if self.debug:",
6969
"if sys.platform != \"win32\":",
70-
"if typing.TYPE_CHECKING:",
70+
"if TYPE_CHECKING:",
7171
"raise AssertionError",
7272
"self.fail\\(\".*\"\\)",
7373
"@unittest.skip",

src/websockets/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
import typing
3+
# Importing the typing module would conflict with websockets.typing.
4+
from typing import TYPE_CHECKING
45

56
from .imports import lazy_import
67
from .version import version as __version__ # noqa: F401
@@ -72,7 +73,7 @@
7273
]
7374

7475
# When type checking, import non-deprecated aliases eagerly. Else, import on demand.
75-
if typing.TYPE_CHECKING:
76+
if TYPE_CHECKING:
7677
from .asyncio.client import ClientConnection, connect, unix_connect
7778
from .asyncio.server import (
7879
Server,

src/websockets/typing.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import http
44
import logging
5-
import typing
6-
from typing import Any, NewType, Optional, Union
5+
from typing import TYPE_CHECKING, Any, NewType, Optional, Union
76

87

98
__all__ = [
@@ -31,7 +30,7 @@
3130

3231

3332
# Change to logging.Logger | ... when dropping Python < 3.10.
34-
if typing.TYPE_CHECKING:
33+
if TYPE_CHECKING:
3534
LoggerLike = Union[logging.Logger, logging.LoggerAdapter[Any]]
3635
"""Types accepted where a :class:`~logging.Logger` is expected."""
3736
else: # remove this branch when dropping support for Python < 3.11

0 commit comments

Comments
 (0)