From ac3ea2cc49b06f6b3cf9ab5b22fa041a19f829c7 Mon Sep 17 00:00:00 2001 From: Ben Avrahami Date: Wed, 7 Feb 2024 22:29:15 +0200 Subject: [PATCH] maybe --- envolved/parsers.py | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/envolved/parsers.py b/envolved/parsers.py index 5ef2689..6bee3e5 100644 --- a/envolved/parsers.py +++ b/envolved/parsers.py @@ -20,21 +20,9 @@ Union, ) -from envolved.utils import extract_from_option - -try: - from typing import TypeAlias -except ImportError: - from typing_extensions import TypeAlias +from typing_extensions import Concatenate, TypeAlias -try: - from typing import ( - Concatenate, - ) -except ImportError: - # typing-extensions won't help us here: https://github.com/python/typing_extensions/issues/48 - # Concatenate in only available in python 3.10+, before that, there is no way to type hint a callable with any number of arguments - Concatenate = None # type: ignore[assignment] +from envolved.utils import extract_from_option __all__ = ["Parser", "BoolParser", "CollectionParser", "parser"] @@ -55,11 +43,8 @@ T = TypeVar("T") -if Concatenate: - # theoretically, I'd like to restrict this to keyword arguments only, but that's not possible yet in python - Parser: TypeAlias = Callable[Concatenate[str, ...], T] -else: - Parser = Callable[[str], T] # type: ignore[misc, no-redef] +# theoretically, I'd like to restrict this to keyword arguments only, but that's not possible yet in python +Parser: TypeAlias = Callable[Concatenate[str, ...], T] ParserInput = Union[Parser[T], Type[T]]