anydi 0.36.1a1__tar.gz → 0.36.1a3__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 (28) hide show
  1. {anydi-0.36.1a1 → anydi-0.36.1a3}/PKG-INFO +1 -1
  2. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/_container.py +28 -14
  3. {anydi-0.36.1a1 → anydi-0.36.1a3}/pyproject.toml +1 -1
  4. {anydi-0.36.1a1 → anydi-0.36.1a3}/LICENSE +0 -0
  5. {anydi-0.36.1a1 → anydi-0.36.1a3}/README.md +0 -0
  6. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/__init__.py +0 -0
  7. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/_context.py +0 -0
  8. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/_provider.py +0 -0
  9. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/_types.py +0 -0
  10. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/_utils.py +0 -0
  11. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/__init__.py +0 -0
  12. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/_utils.py +0 -0
  13. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/__init__.py +0 -0
  14. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/_container.py +0 -0
  15. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/_settings.py +0 -0
  16. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/_utils.py +0 -0
  17. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/apps.py +0 -0
  18. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/middleware.py +0 -0
  19. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/ninja/__init__.py +0 -0
  20. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/ninja/_operation.py +0 -0
  21. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/django/ninja/_signature.py +0 -0
  22. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/fastapi.py +0 -0
  23. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/faststream.py +0 -0
  24. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/pydantic_settings.py +0 -0
  25. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/pytest_plugin.py +0 -0
  26. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/starlette/__init__.py +0 -0
  27. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/ext/starlette/middleware.py +0 -0
  28. {anydi-0.36.1a1 → anydi-0.36.1a3}/anydi/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anydi
3
- Version: 0.36.1a1
3
+ Version: 0.36.1a3
4
4
  Summary: Dependency Injection library
5
5
  Home-page: https://github.com/antonrh/anydi
6
6
  License: MIT
@@ -709,10 +709,9 @@ class Container:
709
709
  if interface in self._override_instances:
710
710
  return self._override_instances[interface]
711
711
 
712
- if not hasattr(instance, "__dict__"):
713
- return instance
714
-
715
- if hasattr(instance, "__patched__"):
712
+ if not hasattr(instance, "__dict__") or hasattr(
713
+ instance, "__resolver_getter__"
714
+ ):
716
715
  return instance
717
716
 
718
717
  wrapped = {
@@ -721,20 +720,35 @@ class Container:
721
720
  if isinstance(value, InstanceProxy)
722
721
  }
723
722
 
724
- # Custom resolver function
725
- def _resolver(_self: Any, _name: str) -> Any:
726
- if _name in wrapped:
727
- _interface = wrapped[_name]
723
+ def __resolver_getter__(name: str) -> Any:
724
+ if name in wrapped:
725
+ _interface = wrapped[name]
728
726
  # Resolve the dependency if it's wrapped
729
727
  return self.resolve(_interface)
730
- # Fall back to default behavior
731
- return object.__getattribute__(_self, _name)
728
+ raise LookupError
729
+
730
+ if not hasattr(instance.__class__, "__getattribute_patched__"):
731
+
732
+ def __getattribute__(_self: Any, name: str) -> Any:
733
+ # Skip the resolver getter
734
+ if name in {"__resolver_getter__"}:
735
+ return object.__getattribute__(_self, name)
736
+
737
+ if hasattr(_self, "__resolver_getter__"):
738
+ try:
739
+ return _self.__resolver_getter__(name)
740
+ except LookupError:
741
+ pass
742
+
743
+ # Fall back to default behavior
744
+ return object.__getattribute__(_self, name)
732
745
 
733
- # Apply the patched resolver if wrapped attributes exist
734
- if wrapped:
735
- instance.__class__.__getattribute__ = _resolver
746
+ # Apply the patched resolver if wrapped attributes exist
747
+ instance.__class__.__getattribute__ = __getattribute__
748
+ instance.__class__.__getattribute_patched__ = True
736
749
 
737
- instance.__patched__ = True
750
+ # Attach the resolver getter to the instance
751
+ instance.__resolver_getter__ = __resolver_getter__
738
752
 
739
753
  return instance
740
754
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "anydi"
3
- version = "0.36.1a1"
3
+ version = "0.36.1a3"
4
4
  description = "Dependency Injection library"
5
5
  authors = ["Anton Ruhlov <antonruhlov@gmail.com>"]
6
6
  license = "MIT"
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