python-injection 0.21.0__tar.gz → 0.21.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_injection-0.21.0 → python_injection-0.21.2}/PKG-INFO +1 -1
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/type.py +2 -2
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/module.py +93 -82
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/scope.py +6 -4
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/entrypoint.py +24 -24
- {python_injection-0.21.0 → python_injection-0.21.2}/pyproject.toml +1 -1
- {python_injection-0.21.0 → python_injection-0.21.2}/.gitignore +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/LICENSE +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/README.md +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/__init__.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/__init__.pyi +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/__init__.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/asfunction.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/__init__.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/asynchronous.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/event.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/invertible.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/key.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/lazy.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/threading.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/descriptors.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/injectables.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/slots.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/exceptions.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/ext/__init__.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/ext/fastapi.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/ext/fastapi.pyi +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/loaders.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/py.typed +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/testing/__init__.py +0 -0
- {python_injection-0.21.0 → python_injection-0.21.2}/injection/testing/__init__.pyi +0 -0
|
@@ -9,7 +9,7 @@ from collections.abc import (
|
|
|
9
9
|
Iterable,
|
|
10
10
|
Iterator,
|
|
11
11
|
)
|
|
12
|
-
from inspect import isfunction
|
|
12
|
+
from inspect import isclass, isfunction
|
|
13
13
|
from types import GenericAlias, UnionType
|
|
14
14
|
from typing import (
|
|
15
15
|
Annotated,
|
|
@@ -33,7 +33,7 @@ type TypeInfo[T] = (
|
|
|
33
33
|
|
|
34
34
|
def get_return_types(*args: TypeInfo[Any]) -> Iterator[InputType[Any]]:
|
|
35
35
|
for arg in args:
|
|
36
|
-
if isinstance(arg, Collection):
|
|
36
|
+
if isinstance(arg, Collection) and not isclass(arg):
|
|
37
37
|
inner_args = arg
|
|
38
38
|
|
|
39
39
|
elif isfunction(arg) and (return_type := get_return_hint(arg)):
|
|
@@ -29,6 +29,7 @@ from inspect import signature as inspect_signature
|
|
|
29
29
|
from logging import Logger, getLogger
|
|
30
30
|
from types import MethodType
|
|
31
31
|
from typing import (
|
|
32
|
+
TYPE_CHECKING,
|
|
32
33
|
Any,
|
|
33
34
|
AsyncContextManager,
|
|
34
35
|
ClassVar,
|
|
@@ -577,21 +578,23 @@ class Module(Broker, EventListener):
|
|
|
577
578
|
|
|
578
579
|
return decorator(wrapped) if wrapped else decorator
|
|
579
580
|
|
|
580
|
-
|
|
581
|
-
def make_injected_function[**P, T](
|
|
582
|
-
self,
|
|
583
|
-
wrapped: Callable[P, T],
|
|
584
|
-
/,
|
|
585
|
-
threadsafe: bool | None = ...,
|
|
586
|
-
) -> SyncInjectedFunction[P, T]: ...
|
|
581
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
587
582
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
583
|
+
@overload
|
|
584
|
+
def make_injected_function[**P, T](
|
|
585
|
+
self,
|
|
586
|
+
wrapped: Callable[P, T],
|
|
587
|
+
/,
|
|
588
|
+
threadsafe: bool | None = ...,
|
|
589
|
+
) -> SyncInjectedFunction[P, T]: ...
|
|
590
|
+
|
|
591
|
+
@overload
|
|
592
|
+
def make_injected_function[**P, T](
|
|
593
|
+
self,
|
|
594
|
+
wrapped: Callable[P, Awaitable[T]],
|
|
595
|
+
/,
|
|
596
|
+
threadsafe: bool | None = ...,
|
|
597
|
+
) -> AsyncInjectedFunction[P, T]: ...
|
|
595
598
|
|
|
596
599
|
def make_injected_function[**P, T](
|
|
597
600
|
self,
|
|
@@ -643,23 +646,25 @@ class Module(Broker, EventListener):
|
|
|
643
646
|
injectable = self[cls]
|
|
644
647
|
return injectable.get_instance()
|
|
645
648
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
649
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
650
|
+
|
|
651
|
+
@overload
|
|
652
|
+
async def aget_instance[T, Default](
|
|
653
|
+
self,
|
|
654
|
+
cls: InputType[T],
|
|
655
|
+
default: Default,
|
|
656
|
+
*,
|
|
657
|
+
threadsafe: bool | None = ...,
|
|
658
|
+
) -> T | Default: ...
|
|
659
|
+
|
|
660
|
+
@overload
|
|
661
|
+
async def aget_instance[T](
|
|
662
|
+
self,
|
|
663
|
+
cls: InputType[T],
|
|
664
|
+
default: T = ...,
|
|
665
|
+
*,
|
|
666
|
+
threadsafe: bool | None = ...,
|
|
667
|
+
) -> T: ...
|
|
663
668
|
|
|
664
669
|
async def aget_instance[T, Default](
|
|
665
670
|
self,
|
|
@@ -673,23 +678,25 @@ class Module(Broker, EventListener):
|
|
|
673
678
|
except (KeyError, SkipInjectable):
|
|
674
679
|
return default
|
|
675
680
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
681
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
682
|
+
|
|
683
|
+
@overload
|
|
684
|
+
def get_instance[T, Default](
|
|
685
|
+
self,
|
|
686
|
+
cls: InputType[T],
|
|
687
|
+
default: Default,
|
|
688
|
+
*,
|
|
689
|
+
threadsafe: bool | None = ...,
|
|
690
|
+
) -> T | Default: ...
|
|
691
|
+
|
|
692
|
+
@overload
|
|
693
|
+
def get_instance[T](
|
|
694
|
+
self,
|
|
695
|
+
cls: InputType[T],
|
|
696
|
+
default: T = ...,
|
|
697
|
+
*,
|
|
698
|
+
threadsafe: bool | None = ...,
|
|
699
|
+
) -> T: ...
|
|
693
700
|
|
|
694
701
|
def get_instance[T, Default](
|
|
695
702
|
self,
|
|
@@ -703,23 +710,25 @@ class Module(Broker, EventListener):
|
|
|
703
710
|
except (KeyError, SkipInjectable):
|
|
704
711
|
return default
|
|
705
712
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
713
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
714
|
+
|
|
715
|
+
@overload
|
|
716
|
+
def aget_lazy_instance[T, Default](
|
|
717
|
+
self,
|
|
718
|
+
cls: InputType[T],
|
|
719
|
+
default: Default,
|
|
720
|
+
*,
|
|
721
|
+
threadsafe: bool | None = ...,
|
|
722
|
+
) -> Awaitable[T | Default]: ...
|
|
723
|
+
|
|
724
|
+
@overload
|
|
725
|
+
def aget_lazy_instance[T](
|
|
726
|
+
self,
|
|
727
|
+
cls: InputType[T],
|
|
728
|
+
default: T = ...,
|
|
729
|
+
*,
|
|
730
|
+
threadsafe: bool | None = ...,
|
|
731
|
+
) -> Awaitable[T]: ...
|
|
723
732
|
|
|
724
733
|
def aget_lazy_instance[T, Default](
|
|
725
734
|
self,
|
|
@@ -735,23 +744,25 @@ class Module(Broker, EventListener):
|
|
|
735
744
|
metadata = function.__inject_metadata__.set_owner(cls)
|
|
736
745
|
return SimpleAwaitable(metadata.acall)
|
|
737
746
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
747
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
748
|
+
|
|
749
|
+
@overload
|
|
750
|
+
def get_lazy_instance[T, Default](
|
|
751
|
+
self,
|
|
752
|
+
cls: InputType[T],
|
|
753
|
+
default: Default,
|
|
754
|
+
*,
|
|
755
|
+
threadsafe: bool | None = ...,
|
|
756
|
+
) -> Invertible[T | Default]: ...
|
|
757
|
+
|
|
758
|
+
@overload
|
|
759
|
+
def get_lazy_instance[T](
|
|
760
|
+
self,
|
|
761
|
+
cls: InputType[T],
|
|
762
|
+
default: T = ...,
|
|
763
|
+
*,
|
|
764
|
+
threadsafe: bool | None = ...,
|
|
765
|
+
) -> Invertible[T]: ...
|
|
755
766
|
|
|
756
767
|
def get_lazy_instance[T, Default](
|
|
757
768
|
self,
|
|
@@ -10,6 +10,7 @@ from dataclasses import dataclass, field
|
|
|
10
10
|
from enum import StrEnum
|
|
11
11
|
from types import EllipsisType, TracebackType
|
|
12
12
|
from typing import (
|
|
13
|
+
TYPE_CHECKING,
|
|
13
14
|
Any,
|
|
14
15
|
AsyncContextManager,
|
|
15
16
|
ContextManager,
|
|
@@ -158,12 +159,13 @@ def get_active_scopes(name: str) -> tuple[Scope, ...]:
|
|
|
158
159
|
return tuple(itertools.chain.from_iterable(active_scopes))
|
|
159
160
|
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
def get_scope(name: str, default: EllipsisType = ...) -> Scope: ...
|
|
162
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
163
163
|
|
|
164
|
+
@overload
|
|
165
|
+
def get_scope(name: str, default: EllipsisType = ...) -> Scope: ...
|
|
164
166
|
|
|
165
|
-
@overload
|
|
166
|
-
def get_scope[T](name: str, default: T) -> Scope | T: ...
|
|
167
|
+
@overload
|
|
168
|
+
def get_scope[T](name: str, default: T) -> Scope | T: ...
|
|
167
169
|
|
|
168
170
|
|
|
169
171
|
def get_scope[T](name: str, default: T | EllipsisType = ...) -> Scope | T:
|
|
@@ -7,7 +7,7 @@ from dataclasses import dataclass, field
|
|
|
7
7
|
from functools import wraps
|
|
8
8
|
from types import MethodType
|
|
9
9
|
from types import ModuleType as PythonModule
|
|
10
|
-
from typing import Any, Concatenate, Self, final, overload
|
|
10
|
+
from typing import TYPE_CHECKING, Any, Concatenate, Self, final, overload
|
|
11
11
|
|
|
12
12
|
from injection import Module
|
|
13
13
|
from injection.loaders import ProfileLoader, PythonModuleLoader
|
|
@@ -21,13 +21,13 @@ type EntrypointSetupMethod[**P, **EPP, T1, T2] = Callable[
|
|
|
21
21
|
Entrypoint[EPP, T2],
|
|
22
22
|
]
|
|
23
23
|
|
|
24
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
24
25
|
|
|
25
|
-
@overload
|
|
26
|
-
def autocall[T: Callable[..., Any]](wrapped: T, /) -> T: ...
|
|
26
|
+
@overload
|
|
27
|
+
def autocall[T: Callable[..., Any]](wrapped: T, /) -> T: ...
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def autocall[T: Callable[..., Any]](wrapped: None = ..., /) -> Callable[[T], T]: ...
|
|
29
|
+
@overload
|
|
30
|
+
def autocall[T: Callable[..., Any]](wrapped: None = ..., /) -> Callable[[T], T]: ...
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
def autocall[T: Callable[..., Any]](
|
|
@@ -44,26 +44,26 @@ def autocall[T: Callable[..., Any]](
|
|
|
44
44
|
# SMP = Setup Method Parameters
|
|
45
45
|
# EPP = EntryPoint Parameters
|
|
46
46
|
|
|
47
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
47
48
|
|
|
48
|
-
@overload
|
|
49
|
-
def entrypointmaker[**SMP, **EPP, T1, T2](
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
) -> EntrypointDecorator[EPP, T1, T2]: ...
|
|
55
|
-
|
|
49
|
+
@overload
|
|
50
|
+
def entrypointmaker[**SMP, **EPP, T1, T2](
|
|
51
|
+
wrapped: EntrypointSetupMethod[SMP, EPP, T1, T2],
|
|
52
|
+
/,
|
|
53
|
+
*,
|
|
54
|
+
profile_loader: ProfileLoader = ...,
|
|
55
|
+
) -> EntrypointDecorator[EPP, T1, T2]: ...
|
|
56
56
|
|
|
57
|
-
@overload
|
|
58
|
-
def entrypointmaker[**SMP, **EPP, T1, T2](
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
) -> Callable[
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
]: ...
|
|
57
|
+
@overload
|
|
58
|
+
def entrypointmaker[**SMP, **EPP, T1, T2](
|
|
59
|
+
wrapped: None = ...,
|
|
60
|
+
/,
|
|
61
|
+
*,
|
|
62
|
+
profile_loader: ProfileLoader = ...,
|
|
63
|
+
) -> Callable[
|
|
64
|
+
[EntrypointSetupMethod[SMP, EPP, T1, T2]],
|
|
65
|
+
EntrypointDecorator[EPP, T1, T2],
|
|
66
|
+
]: ...
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def entrypointmaker[**SMP, **EPP, T1, T2](
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|