mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-07 13:54:25 +03:00
Add spike for 3.6
This commit is contained in:
parent
25e5ed62a2
commit
8e8cc31bc2
|
@ -3,9 +3,17 @@
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import pkgutil
|
import pkgutil
|
||||||
|
import sys
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Optional, Iterable, Callable, Any, Type, Dict, Generic, TypeVar
|
from typing import Optional, Iterable, Callable, Any, Type, Dict, Generic, TypeVar
|
||||||
|
|
||||||
|
if sys.version_info < (3, 7):
|
||||||
|
from typing import GenericMeta
|
||||||
|
else:
|
||||||
|
class GenericMeta:
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
from . import providers
|
from . import providers
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,13 +152,17 @@ def _patch_with_injections(fn, injections):
|
||||||
|
|
||||||
|
|
||||||
class ClassGetItemMeta(type):
|
class ClassGetItemMeta(type):
|
||||||
|
|
||||||
def __getitem__(cls, item):
|
def __getitem__(cls, item):
|
||||||
# Spike for Python 3.6
|
# Spike for Python 3.6
|
||||||
return cls(item)
|
return cls(item)
|
||||||
|
|
||||||
|
|
||||||
class _Marker(Generic[T], metaclass=ClassGetItemMeta):
|
class GenericClassGetItemMeta(GenericMeta, ClassGetItemMeta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class _Marker(Generic[T], metaclass=GenericClassGetItemMeta):
|
||||||
def __init__(self, provider: providers.Provider) -> None:
|
def __init__(self, provider: providers.Provider) -> None:
|
||||||
self.provider = provider
|
self.provider = provider
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user