From 268a3bd4adfbdf63e4f05198ca7b32b9b5db8161 Mon Sep 17 00:00:00 2001 From: Serg Tereshchenko Date: Fri, 20 May 2022 20:20:38 +0300 Subject: [PATCH] Use try/except for ParamSpec --- setup.cfg | 2 +- src/decopatch/main.pyi | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index d80e072..ed9ef4e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ install_requires = # we're using typing_extensions even for new versions of python, so we don't pollute our code # with try/except every time we use new feature. # typing_extensions will use version from typing module if it detects new enough python. - typing-extensions>=4.2;python_version>='3.6' + typing-extensions>=4.2;python_version>='3.6',<'3.10' # note: do not use double quotes in these, this triggers a weird bug in PyCharm in debug mode only funcsigs;python_version<'3.3' enum34;python_version<'3.4' diff --git a/src/decopatch/main.pyi b/src/decopatch/main.pyi index 1dd410d..1cdeb76 100644 --- a/src/decopatch/main.pyi +++ b/src/decopatch/main.pyi @@ -1,6 +1,11 @@ from typing import Any, Callable, Optional, Protocol, TypeVar, overload -from typing_extensions import ParamSpec +try: + # We're importing typing_extensions version first, becouse it will + # detect best available implementation depending on python version. + from typing_extensions import ParamSpec +except ImportError: + from typing import ParamSpec from decopatch.utils_disambiguation import FirstArgDisambiguation from decopatch.utils_modes import SignatureInfo