Skip to content

Commit

Permalink
Merge ff644c8 into 211994f
Browse files Browse the repository at this point in the history
  • Loading branch information
jstasiak committed Mar 11, 2020
2 parents 211994f + ff644c8 commit 9a7081b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions injector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@
Union,
)

from typing_extensions import NoReturn
try:
from typing import NoReturn
except ImportError:
from typing_extensions import NoReturn

HAVE_ANNOTATED = sys.version_info >= (3, 7, 0)

if HAVE_ANNOTATED:
# Ignoring errors here as typing_extensions stub doesn't know about those things yet
from typing_extensions import _AnnotatedAlias, Annotated, get_type_hints # type: ignore
try:
from typing import _AnnotatedAlias, Annotated, get_type_hints # type: ignore
except ImportError:
from typing_extensions import _AnnotatedAlias, Annotated, get_type_hints # type: ignore
else:

class Annotated: # type: ignore
Expand Down Expand Up @@ -110,7 +116,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
InjectT = TypeVar('InjectT')
Inject = Annotated[InjectT, _inject_marker]
"""An experimental way to declare injectable dependencies utilizing a `PEP 593`_ implementation
in `typing_extensions`.
in Python 3.9 and backported to Python 3.7 in `typing_extensions`.
Those two declarations are equivalent::
Expand Down Expand Up @@ -150,7 +156,7 @@ def fun(t: Inject[SomeType], s: SomeOtherType) -> None:

NoInject = Annotated[InjectT, _noinject_marker]
"""An experimental way to declare noninjectable dependencies utilizing a `PEP 593`_ implementation
in `typing_extensions`.
in Python 3.9 and backported to Python 3.7 in `typing_extensions`.
Since :func:`inject` declares all function's parameters to be injectable there needs to be a way
to opt out of it. This has been provided by :func:`noninjectable` but `noninjectable` suffers from
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ def read_injector_variable(name):
'IoC',
'Inversion of Control container',
],
install_requires=['typing_extensions>=3.7.4'],
install_requires=['typing_extensions>=3.7.4;python_version<"3.9"'],
)

0 comments on commit 9a7081b

Please sign in to comment.