99from ellar .common .exceptions import ImproperConfiguration
1010from ellar .common .models import ControllerBase , ControllerType
1111from ellar .di import RequestORTransientScope , injectable
12- from ellar .reflect import REFLECT_TYPE , reflect
12+ from ellar .reflect import reflect , transfer_metadata
1313from injector import Scope
1414from starlette .middleware import Middleware
1515
@@ -64,10 +64,9 @@ def _decorator(cls: t.Type) -> t.Type[ControllerBase]:
6464 if type (cls ) is not ControllerType :
6565 # We force the cls to inherit from `ControllerBase` by creating another type.
6666 attrs = {}
67- if hasattr (cls , REFLECT_TYPE ):
68- attrs .update ({REFLECT_TYPE : cls .__dict__ [REFLECT_TYPE ]})
6967 new_cls = type (cls .__name__ , (cls , ControllerBase ), attrs )
7068
69+ transfer_metadata (cls , new_cls )
7170 _controller_type = t .cast (t .Type [ControllerBase ], new_cls )
7271
7372 _tag = _controller_type .controller_class_name ()
@@ -82,19 +81,6 @@ def _decorator(cls: t.Type) -> t.Type[ControllerBase]:
8281 .replace ("controller" , "" )
8382 )
8483
85- # for base in get_type_of_base(ControllerBase, _controller_type):
86- # if reflect.has_metadata(CONTROLLER_WATERMARK, base) and hasattr(
87- # cls, "__CONTROLLER_WATERMARK__"
88- # ):
89- # raise ImproperConfiguration(
90- # f"`@Controller` decorated classes does not support inheritance. \n"
91- # f"{_controller_type}"
92- # )
93-
94- # if not reflect.has_metadata(
95- # CONTROLLER_WATERMARK, _controller_type
96- # ) and not hasattr(cls, "__CONTROLLER_WATERMARK__"):
97-
9884 reflect .define_metadata (CONTROLLER_WATERMARK , True , _controller_type )
9985 # reflect_all_controller_type_routes(_controller_type)
10086
0 commit comments