From 5513ac4c61496a9c0edbd9ed48f748683e90c3c3 Mon Sep 17 00:00:00 2001 From: Andrey Tikhonov <17@itishka.org> Date: Fri, 17 Apr 2026 22:34:31 +0200 Subject: [PATCH] Fix non-caching alias --- src/dishka/code_tools/factory_compiler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dishka/code_tools/factory_compiler.py b/src/dishka/code_tools/factory_compiler.py index f423c885..2c21199a 100644 --- a/src/dishka/code_tools/factory_compiler.py +++ b/src/dishka/code_tools/factory_compiler.py @@ -446,8 +446,12 @@ def compile_factory( compiled_deps: dict[DependencyKey, CompiledFactory], container_key: DependencyKey, ) -> CompiledFactory: - if factory.type is FactoryType.ALIAS and factory.source in compiled_deps: - return compiled_deps[factory.source] + if ( + factory.type is FactoryType.ALIAS + and factory.dependencies[0] in compiled_deps + and not factory.cache + ): + return compiled_deps[factory.dependencies[0]] if not is_async and factory.type in ASYNC_TYPES: raise UnsupportedFactoryError(factory)