From 4d4c3fb5b5131f6f98137c40e17a96b8e19f5a51 Mon Sep 17 00:00:00 2001 From: Damir Mirasov Date: Mon, 25 Nov 2024 01:17:28 +0500 Subject: [PATCH] Fix di for builtin generics --- sanic_ext/extensions/injection/constructor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sanic_ext/extensions/injection/constructor.py b/sanic_ext/extensions/injection/constructor.py index a996717..0075a1d 100644 --- a/sanic_ext/extensions/injection/constructor.py +++ b/sanic_ext/extensions/injection/constructor.py @@ -12,6 +12,7 @@ Tuple, Type, get_args, + get_origin, get_type_hints, ) @@ -89,7 +90,7 @@ def prepare( self.pass_kwargs = True if is_optional(annotation): annotation = get_args(annotation)[0] - if not isclass(annotation): + if not isclass(annotation) and get_origin(annotation) is None: missing.append((param, annotation)) continue if issubclass(annotation, Request):