Skip to content

Commit 976433a

Browse files
committed
fixed mypy issues
1 parent 1973660 commit 976433a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

ellar/core/modules/ref/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import typing as t
22
from abc import ABC, abstractmethod
3-
from functools import cached_property
43
from typing import Type
54

65
from ellar.auth.constants import POLICY_KEYS
@@ -66,16 +65,21 @@ def __init__(
6665
self._routers: t.List[t.Union[BaseRoute]] = []
6766
self._exports: t.List[t.Type] = []
6867
self._providers: t.Dict[t.Type, ProviderConfig] = {}
68+
self._module_execution_context: t.Optional[ModuleExecutionContext] = None
6969

7070
def __repr__(self) -> str:
7171
return f"<{self.__class__.__name__} name={self.name} module={self.module}>"
7272

7373
def __hash__(self) -> int:
7474
return hash(self.module)
7575

76-
@cached_property
76+
@property
7777
def module_context(self) -> ModuleExecutionContext:
78-
return ModuleExecutionContext(container=self.container, module=self.module)
78+
if self._module_execution_context is None:
79+
self._module_execution_context = ModuleExecutionContext(
80+
container=self.container, module=self.module
81+
)
82+
return self._module_execution_context
7983

8084
@property
8185
def tree_manager(self) -> ModuleTreeManager:

ellar/testing/dependency_analyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _build_module_tree(self) -> "ModuleTreeManager":
6868
module_setup = ModuleSetup(self.application_module)
6969
return AppFactory.read_all_module(module_setup)
7070

71-
def get_type_from_tag(self, tag: t.NewType) -> t.Optional[t.Type[t.Any]]:
71+
def get_type_from_tag(self, tag: t.Any) -> t.Optional[t.Type[t.Any]]:
7272
"""
7373
Get the type/interface associated with a given tag from ApplicationModule tree
7474
@@ -86,7 +86,7 @@ def get_type_from_tag(self, tag: t.NewType) -> t.Optional[t.Type[t.Any]]:
8686
if not hasattr(tag, "__name__"):
8787
return None
8888

89-
tag_instance = tag.__name__
89+
tag_instance = getattr(tag, "__name__", None)
9090
if not isinstance(tag_instance, Tag):
9191
return None
9292

ellar/testing/module.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ def _analyze_and_resolve_controller_dependencies(
271271
for dep_type in dependencies:
272272
# Handle tagged dependencies (InjectByTag)
273273
if isinstance(dep_type, t.NewType):
274-
dep_type = app_analyzer.get_type_from_tag(dep_type)
274+
resolved_type = app_analyzer.get_type_from_tag(dep_type)
275+
if not resolved_type:
276+
continue
277+
dep_type = resolved_type
275278

276279
providing_module = app_analyzer.find_module_providing_service(dep_type)
277280

0 commit comments

Comments
 (0)