python-injection 0.19.1__tar.gz → 0.19.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.19.1 → python_injection-0.19.2}/PKG-INFO +1 -1
  2. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/asfunction.py +11 -11
  3. {python_injection-0.19.1 → python_injection-0.19.2}/pyproject.toml +1 -1
  4. {python_injection-0.19.1 → python_injection-0.19.2}/.gitignore +0 -0
  5. {python_injection-0.19.1 → python_injection-0.19.2}/LICENSE +0 -0
  6. {python_injection-0.19.1 → python_injection-0.19.2}/README.md +0 -0
  7. {python_injection-0.19.1 → python_injection-0.19.2}/injection/__init__.py +0 -0
  8. {python_injection-0.19.1 → python_injection-0.19.2}/injection/__init__.pyi +0 -0
  9. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/__init__.py +0 -0
  11. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/asynchronous.py +0 -0
  12. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/event.py +0 -0
  13. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/invertible.py +0 -0
  14. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/key.py +0 -0
  15. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/threading.py +0 -0
  17. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/common/type.py +0 -0
  18. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/descriptors.py +0 -0
  19. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/injectables.py +0 -0
  20. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/module.py +0 -0
  21. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/scope.py +0 -0
  22. {python_injection-0.19.1 → python_injection-0.19.2}/injection/_core/slots.py +0 -0
  23. {python_injection-0.19.1 → python_injection-0.19.2}/injection/entrypoint.py +0 -0
  24. {python_injection-0.19.1 → python_injection-0.19.2}/injection/exceptions.py +0 -0
  25. {python_injection-0.19.1 → python_injection-0.19.2}/injection/ext/__init__.py +0 -0
  26. {python_injection-0.19.1 → python_injection-0.19.2}/injection/ext/fastapi.py +0 -0
  27. {python_injection-0.19.1 → python_injection-0.19.2}/injection/ext/fastapi.pyi +0 -0
  28. {python_injection-0.19.1 → python_injection-0.19.2}/injection/loaders.py +0 -0
  29. {python_injection-0.19.1 → python_injection-0.19.2}/injection/py.typed +0 -0
  30. {python_injection-0.19.1 → python_injection-0.19.2}/injection/testing/__init__.py +0 -0
  31. {python_injection-0.19.1 → python_injection-0.19.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.19.1
3
+ Version: 0.19.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
@@ -2,20 +2,21 @@ from abc import abstractmethod
2
2
  from collections.abc import Callable
3
3
  from functools import wraps
4
4
  from inspect import iscoroutinefunction
5
+ from types import MethodType
5
6
  from typing import Any, Protocol, runtime_checkable
6
7
 
7
8
  from injection._core.common.asynchronous import Caller
8
9
  from injection._core.module import Module, mod
9
10
 
10
- type AsFunctionWrappedType[**P, T] = type[_Callable[P, T]]
11
+ type AsFunctionWrappedType[**P, T] = type[AsFunctionCallable[P, T]]
11
12
 
12
13
 
13
14
  @runtime_checkable
14
- class _Callable[**P, T](Protocol):
15
+ class AsFunctionCallable[**P, T](Protocol):
15
16
  __slots__ = ()
16
17
 
17
18
  @abstractmethod
18
- def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
19
+ def call(self, *args: P.args, **kwargs: P.kwargs) -> T:
19
20
  raise NotImplementedError
20
21
 
21
22
 
@@ -29,28 +30,27 @@ def asfunction[**P, T](
29
30
  module = module or mod()
30
31
 
31
32
  def decorator(wp: AsFunctionWrappedType[P, T]) -> Callable[P, T]:
32
- get_method = wp.__call__.__get__
33
- method = get_method(NotImplemented)
34
- factory: Caller[..., Callable[P, T]] = module.make_injected_function(
33
+ fake_method = MethodType(wp.call, NotImplemented)
34
+ factory: Caller[..., AsFunctionCallable[P, T]] = module.make_injected_function(
35
35
  wp,
36
36
  threadsafe=threadsafe,
37
37
  ).__inject_metadata__
38
38
 
39
39
  wrapper: Callable[P, T]
40
40
 
41
- if iscoroutinefunction(method):
41
+ if iscoroutinefunction(fake_method):
42
42
 
43
- @wraps(method)
43
+ @wraps(fake_method)
44
44
  async def wrapper(*args: P.args, **kwargs: P.kwargs) -> Any:
45
45
  self = await factory.acall()
46
- return await get_method(self)(*args, **kwargs)
46
+ return await self.call(*args, **kwargs) # type: ignore[misc]
47
47
 
48
48
  else:
49
49
 
50
- @wraps(method)
50
+ @wraps(fake_method)
51
51
  def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
52
52
  self = factory.call()
53
- return get_method(self)(*args, **kwargs)
53
+ return self.call(*args, **kwargs)
54
54
 
55
55
  wrapper.__name__ = wp.__name__
56
56
  wrapper.__qualname__ = wp.__qualname__
@@ -30,7 +30,7 @@ test = [
30
30
 
31
31
  [project]
32
32
  name = "python-injection"
33
- version = "0.19.1"
33
+ version = "0.19.2"
34
34
  description = "Fast and easy dependency injection framework."
35
35
  license = "MIT"
36
36
  license-files = ["LICENSE"]