From 78632be4f75181432dc2ccffe912e063a8258a65 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Sun, 12 Feb 2023 22:33:15 +0100 Subject: [PATCH] Use typing_extensions only on Python 3.7 and lower Protocol was added with PEP 544 to Python 3.8+ --- janus/__init__.py | 6 +++++- setup.cfg | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/janus/__init__.py b/janus/__init__.py index a2887aa..8b2a9fe 100644 --- a/janus/__init__.py +++ b/janus/__init__.py @@ -9,7 +9,11 @@ from queue import Full as SyncQueueFull from typing import Any, Callable, Deque, Generic, List, Optional, Set, TypeVar -from typing_extensions import Protocol +try: + # Python 3.8+ + from typing import Protocol +except ImportError: + from typing_extensions import Protocol __version__ = "1.0.0" __all__ = ( diff --git a/setup.cfg b/setup.cfg index d7ae24d..c142f98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ zip_safe = True include_package_data = True install_requires = - typing-extensions>=3.7.4.3 + typing-extensions>=3.7.4.3;python_version<"3.8" [flake8] exclude = .git,.env,__pycache__,.eggs