python-injection 0.19.0__tar.gz → 0.19.1__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.19.0 → python_injection-0.19.1}/PKG-INFO +1 -1
  2. {python_injection-0.19.0 → python_injection-0.19.1}/injection/__init__.pyi +3 -2
  3. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/asfunction.py +15 -3
  4. {python_injection-0.19.0 → python_injection-0.19.1}/pyproject.toml +1 -1
  5. {python_injection-0.19.0 → python_injection-0.19.1}/.gitignore +0 -0
  6. {python_injection-0.19.0 → python_injection-0.19.1}/LICENSE +0 -0
  7. {python_injection-0.19.0 → python_injection-0.19.1}/README.md +0 -0
  8. {python_injection-0.19.0 → python_injection-0.19.1}/injection/__init__.py +0 -0
  9. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/__init__.py +0 -0
  11. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/asynchronous.py +0 -0
  12. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/event.py +0 -0
  13. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/invertible.py +0 -0
  14. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/key.py +0 -0
  15. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/threading.py +0 -0
  17. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/common/type.py +0 -0
  18. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/descriptors.py +0 -0
  19. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/injectables.py +0 -0
  20. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/module.py +0 -0
  21. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/scope.py +0 -0
  22. {python_injection-0.19.0 → python_injection-0.19.1}/injection/_core/slots.py +0 -0
  23. {python_injection-0.19.0 → python_injection-0.19.1}/injection/entrypoint.py +0 -0
  24. {python_injection-0.19.0 → python_injection-0.19.1}/injection/exceptions.py +0 -0
  25. {python_injection-0.19.0 → python_injection-0.19.1}/injection/ext/__init__.py +0 -0
  26. {python_injection-0.19.0 → python_injection-0.19.1}/injection/ext/fastapi.py +0 -0
  27. {python_injection-0.19.0 → python_injection-0.19.1}/injection/ext/fastapi.pyi +0 -0
  28. {python_injection-0.19.0 → python_injection-0.19.1}/injection/loaders.py +0 -0
  29. {python_injection-0.19.0 → python_injection-0.19.1}/injection/py.typed +0 -0
  30. {python_injection-0.19.0 → python_injection-0.19.1}/injection/testing/__init__.py +0 -0
  31. {python_injection-0.19.0 → python_injection-0.19.1}/injection/testing/__init__.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-injection
3
- Version: 0.19.0
3
+ Version: 0.19.1
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Project-URL: Repository, https://github.com/100nm/python-injection
6
6
  Author: remimd
@@ -5,6 +5,7 @@ from enum import Enum
5
5
  from logging import Logger
6
6
  from typing import Any, Final, Protocol, Self, final, overload, runtime_checkable
7
7
 
8
+ from ._core.asfunction import AsFunctionWrappedType as _AsFunctionWrappedType
8
9
  from ._core.common.invertible import Invertible as _Invertible
9
10
  from ._core.common.type import InputType as _InputType
10
11
  from ._core.common.type import TypeInfo as _TypeInfo
@@ -32,7 +33,7 @@ singleton = __MODULE.singleton
32
33
 
33
34
  @overload
34
35
  def asfunction[**P, T](
35
- wrapped: type[Callable[P, T]],
36
+ wrapped: _AsFunctionWrappedType[P, T],
36
37
  /,
37
38
  *,
38
39
  module: Module = ...,
@@ -45,7 +46,7 @@ def asfunction[**P, T](
45
46
  *,
46
47
  module: Module = ...,
47
48
  threadsafe: bool | None = ...,
48
- ) -> Callable[[type[Callable[P, T]]], Callable[P, T]]: ...
49
+ ) -> Callable[[_AsFunctionWrappedType[P, T]], Callable[P, T]]: ...
49
50
  @asynccontextmanager
50
51
  def adefine_scope(
51
52
  name: str,
@@ -1,14 +1,26 @@
1
+ from abc import abstractmethod
1
2
  from collections.abc import Callable
2
3
  from functools import wraps
3
4
  from inspect import iscoroutinefunction
4
- from typing import Any
5
+ from typing import Any, Protocol, runtime_checkable
5
6
 
6
7
  from injection._core.common.asynchronous import Caller
7
8
  from injection._core.module import Module, mod
8
9
 
10
+ type AsFunctionWrappedType[**P, T] = type[_Callable[P, T]]
11
+
12
+
13
+ @runtime_checkable
14
+ class _Callable[**P, T](Protocol):
15
+ __slots__ = ()
16
+
17
+ @abstractmethod
18
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
19
+ raise NotImplementedError
20
+
9
21
 
10
22
  def asfunction[**P, T](
11
- wrapped: type[Callable[P, T]] | None = None,
23
+ wrapped: AsFunctionWrappedType[P, T] | None = None,
12
24
  /,
13
25
  *,
14
26
  module: Module | None = None,
@@ -16,7 +28,7 @@ def asfunction[**P, T](
16
28
  ) -> Any:
17
29
  module = module or mod()
18
30
 
19
- def decorator(wp: type[Callable[P, T]]) -> Callable[P, T]:
31
+ def decorator(wp: AsFunctionWrappedType[P, T]) -> Callable[P, T]:
20
32
  get_method = wp.__call__.__get__
21
33
  method = get_method(NotImplemented)
22
34
  factory: Caller[..., Callable[P, T]] = module.make_injected_function(
@@ -30,7 +30,7 @@ test = [
30
30
 
31
31
  [project]
32
32
  name = "python-injection"
33
- version = "0.19.0"
33
+ version = "0.19.1"
34
34
  description = "Fast and easy dependency injection framework."
35
35
  license = "MIT"
36
36
  license-files = ["LICENSE"]