Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions injection/_core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,20 @@ def make_record(self) -> Record[T]:
return Record(injectable, self.mode)


class LocatorHooks[T](NamedTuple):
on_conflict: Hook[[Record[T], Record[T], InputType[T]], bool]
on_input: Hook[[Iterable[InputType[T]]], Iterable[InputType[T]]]
on_update: Hook[[Updater[T]], Updater[T]]

@classmethod
def default(cls) -> Self:
return cls(
on_conflict=Hook(),
on_input=Hook(),
on_update=Hook(),
)
@dataclass(repr=False, eq=False, frozen=True, slots=True)
class LocatorHooks[T]:
on_conflict: Hook[[Record[T], Record[T], InputType[T]], bool] = field(
default_factory=Hook,
init=False,
)
on_input: Hook[[Iterable[InputType[T]]], Iterable[InputType[T]]] = field(
default_factory=Hook,
init=False,
)
on_update: Hook[[Updater[T]], Updater[T]] = field(
default_factory=Hook,
init=False,
)


@dataclass(repr=False, frozen=True, slots=True)
Expand All @@ -233,7 +235,7 @@ class Locator(Broker):
init=False,
)

static_hooks: ClassVar[LocatorHooks[Any]] = LocatorHooks.default()
static_hooks: ClassVar[LocatorHooks[Any]] = LocatorHooks()

def __getitem__[T](self, cls: InputType[T], /) -> Injectable[T]:
for input_class in self.__standardize_inputs((cls,)):
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading