From f00ee0cc139f5559c9c8d1f263f79c240ae62a74 Mon Sep 17 00:00:00 2001 From: Duncan Macleod Date: Fri, 4 Apr 2025 10:52:44 +0100 Subject: [PATCH] Move use of typing_extensions into TYPE_CHECKING block so that typing-extensions is not required at runtime --- kombu/asynchronous/semaphore.py | 15 +++++++-------- requirements/default.txt | 1 - requirements/pkgutils.txt | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/kombu/asynchronous/semaphore.py b/kombu/asynchronous/semaphore.py index 940e6d860..2936459e6 100644 --- a/kombu/asynchronous/semaphore.py +++ b/kombu/asynchronous/semaphore.py @@ -3,21 +3,20 @@ import sys from collections import deque -from typing import TYPE_CHECKING, Callable, Deque - -if sys.version_info < (3, 10): - from typing_extensions import ParamSpec -else: - from typing import ParamSpec +from typing import TYPE_CHECKING if TYPE_CHECKING: from types import TracebackType + from typing import Callable, Deque + if sys.version_info < (3, 10): + from typing_extensions import ParamSpec + else: + from typing import ParamSpec + P = ParamSpec("P") __all__ = ('DummyLock', 'LaxBoundedSemaphore') -P = ParamSpec("P") - class LaxBoundedSemaphore: """Asynchronous Bounded Semaphore. diff --git a/requirements/default.txt b/requirements/default.txt index 1ad71d4fc..4a430ee56 100644 --- a/requirements/default.txt +++ b/requirements/default.txt @@ -1,4 +1,3 @@ -typing_extensions==4.12.2; python_version<"3.10" amqp>=5.1.1,<6.0.0 vine==5.1.0 backports.zoneinfo[tzdata]>=0.2.1; python_version<"3.9" diff --git a/requirements/pkgutils.txt b/requirements/pkgutils.txt index 4a43eb047..8878c1ae4 100644 --- a/requirements/pkgutils.txt +++ b/requirements/pkgutils.txt @@ -6,3 +6,4 @@ sphinx2rst>=1.0 bumpversion==0.6.0 pydocstyle==6.3.0 mypy==1.14.1 +typing_extensions==4.12.2; python_version<"3.10"