Skip to content

Commit 0b54907

Browse files
authored
rename: 🚚 resolve -> find_instance
1 parent c038ed7 commit 0b54907

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

β€Žinjection/__init__.pyβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"InjectableMode",
88
"Module",
99
"ModulePriority",
10+
"find_instance",
1011
"get_instance",
1112
"get_lazy_instance",
1213
"inject",
@@ -25,6 +26,7 @@ def mod(name: str = None, /) -> Module:
2526
return Module.from_name(name)
2627

2728

29+
find_instance = mod().find_instance
2830
get_instance = mod().get_instance
2931
get_lazy_instance = mod().get_lazy_instance
3032
inject = mod().inject

β€Žinjection/__init__.pyiβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ from .core import PriorityStr as ModulePriorityStr
2121

2222
_: Module = ...
2323

24+
find_instance = _.find_instance
2425
get_instance = _.get_instance
2526
get_lazy_instance = _.get_lazy_instance
2627
inject = _.inject
@@ -107,7 +108,7 @@ class Module:
107108
that no dependencies are resolved, so the module doesn't need to be locked.
108109
"""
109110

110-
def resolve[T](self, cls: type[T]) -> T:
111+
def find_instance[T](self, cls: type[T]) -> T:
111112
"""
112113
Function used to retrieve an instance associated with the type passed in
113114
parameter or an exception will be raised.

β€Žinjection/core/module.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,13 @@ def listen():
488488

489489
return decorator(wrapped) if wrapped else decorator
490490

491-
def resolve[T](self, cls: type[T]) -> T:
491+
def find_instance[T](self, cls: type[T]) -> T:
492492
injectable = self[cls]
493493
return injectable.get_instance()
494494

495495
def get_instance[T](self, cls: type[T]) -> T | None:
496496
try:
497-
return self.resolve(cls)
497+
return self.find_instance(cls)
498498
except KeyError:
499499
return None
500500

β€Žinjection/integrations/blacksheep.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ def register(self, obj_type: type | Any, *args, **kwargs):
2525
return self
2626

2727
def resolve[T](self, obj_type: type[T] | Any, *args, **kwargs) -> T:
28-
return self.__module.resolve(obj_type)
28+
return self.__module.find_instance(obj_type)

0 commit comments

Comments
Β (0)