simplify Chain#append

This commit is contained in:
Pierre Chapuis 2023-08-23 17:12:54 +02:00
parent beacfe816b
commit 802970e79a

View file

@ -337,12 +337,7 @@ class Chain(ContextModule):
raise ValueError(f"No module of type {module_type.__name__} found in the chain.") raise ValueError(f"No module of type {module_type.__name__} found in the chain.")
def append(self, module: Module) -> None: def append(self, module: Module) -> None:
modules = list(self) self.insert(-1, module)
modules.append(module)
self._regenerate_keys(modules)
if isinstance(module, ContextModule):
module._set_parent(self)
self._register_provider()
def pop(self, index: int = -1) -> Module | tuple[Module]: def pop(self, index: int = -1) -> Module | tuple[Module]:
modules = list(self) modules = list(self)