3838
3939_ROUTES : set [Route ] = set ()
4040
41+ _ResponseType = str
42+
4143
4244def route (
4345 path_pattern : str ,
4446 http_methods : set [HTTPMethod ],
45- ) -> Callable [[Callable [..., str ]], Callable [..., str ]]:
47+ ) -> Callable [[Callable [..., str ]], Callable [..., _ResponseType ]]:
4648 """
4749 Register a decorated method so that it can be recognized as a route.
4850
@@ -55,7 +57,9 @@ def route(
5557 A decorator which takes methods and makes them recognizable as routes.
5658 """
5759
58- def decorator (method : Callable [..., str ]) -> Callable [..., str ]:
60+ def decorator (
61+ method : Callable [..., _ResponseType ],
62+ ) -> Callable [..., _ResponseType ]:
5963 """
6064 Register a decorated method so that it can be recognized as a route.
6165
@@ -128,9 +132,7 @@ def __init__(
128132 path_pattern = "/targets" ,
129133 http_methods = {HTTPMethod .POST },
130134 )
131- def add_target (
132- self , request : PreparedRequest
133- ) -> tuple [int , dict [str , str ], str ]:
135+ def add_target (self , request : PreparedRequest ) -> _ResponseType :
134136 """
135137 Add a target.
136138
@@ -206,9 +208,7 @@ def add_target(
206208 path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
207209 http_methods = {HTTPMethod .DELETE },
208210 )
209- def delete_target (
210- self , request : PreparedRequest
211- ) -> tuple [int , dict [str , str ], str ]:
211+ def delete_target (self , request : PreparedRequest ) -> _ResponseType :
212212 """
213213 Delete a target.
214214
@@ -273,10 +273,7 @@ def delete_target(
273273 return HTTPStatus .OK , headers , body_json
274274
275275 @route (path_pattern = "/summary" , http_methods = {HTTPMethod .GET })
276- def database_summary (
277- self ,
278- request : PreparedRequest ,
279- ) -> tuple [int , dict [str , str ], str ]:
276+ def database_summary (self , request : PreparedRequest ) -> _ResponseType :
280277 """
281278 Get a database summary report.
282279
@@ -341,9 +338,7 @@ def database_summary(
341338 return HTTPStatus .OK , headers , body_json
342339
343340 @route (path_pattern = "/targets" , http_methods = {HTTPMethod .GET })
344- def target_list (
345- self , request : PreparedRequest
346- ) -> tuple [int , dict [str , str ], str ]:
341+ def target_list (self , request : PreparedRequest ) -> _ResponseType :
347342 """
348343 Get a list of all targets.
349344
@@ -401,9 +396,7 @@ def target_list(
401396 path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
402397 http_methods = {HTTPMethod .GET },
403398 )
404- def get_target (
405- self , request : PreparedRequest
406- ) -> tuple [int , dict [str , str ], str ]:
399+ def get_target (self , request : PreparedRequest ) -> _ResponseType :
407400 """
408401 Get details of a target.
409402
@@ -469,9 +462,7 @@ def get_target(
469462 path_pattern = f"/duplicates/{ _TARGET_ID_PATTERN } " ,
470463 http_methods = {HTTPMethod .GET },
471464 )
472- def get_duplicates (
473- self , request : PreparedRequest
474- ) -> tuple [int , dict [str , str ], str ]:
465+ def get_duplicates (self , request : PreparedRequest ) -> _ResponseType :
475466 """
476467 Get targets which may be considered duplicates of a given target.
477468
@@ -543,9 +534,7 @@ def get_duplicates(
543534 path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
544535 http_methods = {HTTPMethod .PUT },
545536 )
546- def update_target (
547- self , request : PreparedRequest
548- ) -> tuple [int , dict [str , str ], str ]:
537+ def update_target (self , request : PreparedRequest ) -> _ResponseType :
549538 """
550539 Update a target.
551540
@@ -653,9 +642,7 @@ def update_target(
653642 path_pattern = f"/summary/{ _TARGET_ID_PATTERN } " ,
654643 http_methods = {HTTPMethod .GET },
655644 )
656- def target_summary (
657- self , request : PreparedRequest
658- ) -> tuple [int , dict [str , str ], str ]:
645+ def target_summary (self , request : PreparedRequest ) -> _ResponseType :
659646 """
660647 Get a summary report for a target.
661648
0 commit comments