Skip to content

Commit

Permalink
maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Avrahami committed Feb 7, 2024
1 parent 3b68276 commit ac3ea2c
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions envolved/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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]]

Expand Down

0 comments on commit ac3ea2c

Please sign in to comment.