From 3c6b1aab96adde1a4b0d3e8f1a93b7f2c7310af0 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 13 Jan 2024 20:46:54 +0100 Subject: [PATCH] Restore compatibility with Python < 3.11. Broken in 9038a62e. --- src/websockets/typing.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/websockets/typing.py b/src/websockets/typing.py index e073e650..5dfecf66 100644 --- a/src/websockets/typing.py +++ b/src/websockets/typing.py @@ -2,6 +2,7 @@ import http import logging +import typing from typing import Any, List, NewType, Optional, Tuple, Union @@ -28,8 +29,12 @@ """ -LoggerLike = Union[logging.Logger, logging.LoggerAdapter[Any]] -"""Types accepted where a :class:`~logging.Logger` is expected.""" +if typing.TYPE_CHECKING: + LoggerLike = Union[logging.Logger, logging.LoggerAdapter[Any]] + """Types accepted where a :class:`~logging.Logger` is expected.""" +else: # remove this branch when dropping support for Python < 3.11 + LoggerLike = Union[logging.Logger, logging.LoggerAdapter] + """Types accepted where a :class:`~logging.Logger` is expected.""" StatusLike = Union[http.HTTPStatus, int]