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.
Files changed (31) hide show
  1. {python_injection-0.21.0 → python_injection-0.21.2}/PKG-INFO +1 -1
  2. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/type.py +2 -2
  3. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/module.py +93 -82
  4. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/scope.py +6 -4
  5. {python_injection-0.21.0 → python_injection-0.21.2}/injection/entrypoint.py +24 -24
  6. {python_injection-0.21.0 → python_injection-0.21.2}/pyproject.toml +1 -1
  7. {python_injection-0.21.0 → python_injection-0.21.2}/.gitignore +0 -0
  8. {python_injection-0.21.0 → python_injection-0.21.2}/LICENSE +0 -0
  9. {python_injection-0.21.0 → python_injection-0.21.2}/README.md +0 -0
  10. {python_injection-0.21.0 → python_injection-0.21.2}/injection/__init__.py +0 -0
  11. {python_injection-0.21.0 → python_injection-0.21.2}/injection/__init__.pyi +0 -0
  12. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/__init__.py +0 -0
  13. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/asfunction.py +0 -0
  14. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/__init__.py +0 -0
  15. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/asynchronous.py +0 -0
  16. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/event.py +0 -0
  17. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/invertible.py +0 -0
  18. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/key.py +0 -0
  19. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/lazy.py +0 -0
  20. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/common/threading.py +0 -0
  21. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/descriptors.py +0 -0
  22. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/injectables.py +0 -0
  23. {python_injection-0.21.0 → python_injection-0.21.2}/injection/_core/slots.py +0 -0
  24. {python_injection-0.21.0 → python_injection-0.21.2}/injection/exceptions.py +0 -0
  25. {python_injection-0.21.0 → python_injection-0.21.2}/injection/ext/__init__.py +0 -0
  26. {python_injection-0.21.0 → python_injection-0.21.2}/injection/ext/fastapi.py +0 -0
  27. {python_injection-0.21.0 → python_injection-0.21.2}/injection/ext/fastapi.pyi +0 -0
  28. {python_injection-0.21.0 → python_injection-0.21.2}/injection/loaders.py +0 -0
  29. {python_injection-0.21.0 → python_injection-0.21.2}/injection/py.typed +0 -0
  30. {python_injection-0.21.0 → python_injection-0.21.2}/injection/testing/__init__.py +0 -0
  31. {python_injection-0.21.0 → python_injection-0.21.2}/injection/testing/__init__.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-injection
3
- Version: 0.21.0
3
+ Version: 0.21.2
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Project-URL: Repository, https://github.com/100nm/python-injection
6
6
  Author: remimd
@@ -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
- @overload
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
- @overload
589
- def make_injected_function[**P, T](
590
- self,
591
- wrapped: Callable[P, Awaitable[T]],
592
- /,
593
- threadsafe: bool | None = ...,
594
- ) -> AsyncInjectedFunction[P, T]: ...
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
- @overload
647
- async def aget_instance[T, Default](
648
- self,
649
- cls: InputType[T],
650
- default: Default,
651
- *,
652
- threadsafe: bool | None = ...,
653
- ) -> T | Default: ...
654
-
655
- @overload
656
- async def aget_instance[T](
657
- self,
658
- cls: InputType[T],
659
- default: T = ...,
660
- *,
661
- threadsafe: bool | None = ...,
662
- ) -> T: ...
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
- @overload
677
- def get_instance[T, Default](
678
- self,
679
- cls: InputType[T],
680
- default: Default,
681
- *,
682
- threadsafe: bool | None = ...,
683
- ) -> T | Default: ...
684
-
685
- @overload
686
- def get_instance[T](
687
- self,
688
- cls: InputType[T],
689
- default: T = ...,
690
- *,
691
- threadsafe: bool | None = ...,
692
- ) -> T: ...
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
- @overload
707
- def aget_lazy_instance[T, Default](
708
- self,
709
- cls: InputType[T],
710
- default: Default,
711
- *,
712
- threadsafe: bool | None = ...,
713
- ) -> Awaitable[T | Default]: ...
714
-
715
- @overload
716
- def aget_lazy_instance[T](
717
- self,
718
- cls: InputType[T],
719
- default: T = ...,
720
- *,
721
- threadsafe: bool | None = ...,
722
- ) -> Awaitable[T]: ...
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
- @overload
739
- def get_lazy_instance[T, Default](
740
- self,
741
- cls: InputType[T],
742
- default: Default,
743
- *,
744
- threadsafe: bool | None = ...,
745
- ) -> Invertible[T | Default]: ...
746
-
747
- @overload
748
- def get_lazy_instance[T](
749
- self,
750
- cls: InputType[T],
751
- default: T = ...,
752
- *,
753
- threadsafe: bool | None = ...,
754
- ) -> Invertible[T]: ...
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
- @overload
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
- @overload
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
- wrapped: EntrypointSetupMethod[SMP, EPP, T1, T2],
51
- /,
52
- *,
53
- profile_loader: ProfileLoader = ...,
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
- wrapped: None = ...,
60
- /,
61
- *,
62
- profile_loader: ProfileLoader = ...,
63
- ) -> Callable[
64
- [EntrypointSetupMethod[SMP, EPP, T1, T2]],
65
- EntrypointDecorator[EPP, T1, T2],
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](
@@ -30,7 +30,7 @@ test = [
30
30
 
31
31
  [project]
32
32
  name = "python-injection"
33
- version = "0.21.0"
33
+ version = "0.21.2"
34
34
  description = "Fast and easy dependency injection framework."
35
35
  license = "MIT"
36
36
  license-files = ["LICENSE"]