4040
4141_ROUTES : set [Route ] = set ()
4242
43+ _ResponseType = str
44+
4345
4446def route (
4547 path_pattern : str ,
4648 http_methods : set [HTTPMethod ],
47- ) -> Callable [[Callable [..., str ]], Callable [..., str ]]:
49+ ) -> Callable [[Callable [..., str ]], Callable [..., _ResponseType ]]:
4850 """
4951 Register a decorated method so that it can be recognized as a route.
5052
@@ -57,7 +59,9 @@ def route(
5759 A decorator which takes methods and makes them recognizable as routes.
5860 """
5961
60- def decorator (method : Callable [..., str ]) -> Callable [..., str ]:
62+ def decorator (
63+ method : Callable [..., _ResponseType ],
64+ ) -> Callable [..., _ResponseType ]:
6165 """
6266 Register a decorated method so that it can be recognized as a route.
6367
@@ -130,7 +134,9 @@ def __init__(
130134 path_pattern = "/targets" ,
131135 http_methods = {HTTPMethod .POST },
132136 )
133- def add_target (self , request : "Request" , context : "Context" ) -> str :
137+ def add_target (
138+ self , request : "Request" , context : "Context"
139+ ) -> _ResponseType :
134140 """
135141 Add a target.
136142
@@ -207,7 +213,9 @@ def add_target(self, request: "Request", context: "Context") -> str:
207213 path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
208214 http_methods = {HTTPMethod .DELETE },
209215 )
210- def delete_target (self , request : "Request" , context : "Context" ) -> str :
216+ def delete_target (
217+ self , request : "Request" , context : "Context"
218+ ) -> _ResponseType :
211219 """
212220 Delete a target.
213221
@@ -274,7 +282,9 @@ def delete_target(self, request: "Request", context: "Context") -> str:
274282 return body_json
275283
276284 @route (path_pattern = "/summary" , http_methods = {HTTPMethod .GET })
277- def database_summary (self , request : "Request" , context : "Context" ) -> str :
285+ def database_summary (
286+ self , request : "Request" , context : "Context"
287+ ) -> _ResponseType :
278288 """
279289 Get a database summary report.
280290
@@ -340,7 +350,9 @@ def database_summary(self, request: "Request", context: "Context") -> str:
340350 return body_json
341351
342352 @route (path_pattern = "/targets" , http_methods = {HTTPMethod .GET })
343- def target_list (self , request : "Request" , context : "Context" ) -> str :
353+ def target_list (
354+ self , request : "Request" , context : "Context"
355+ ) -> _ResponseType :
344356 """
345357 Get a list of all targets.
346358
@@ -400,7 +412,9 @@ def target_list(self, request: "Request", context: "Context") -> str:
400412 path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
401413 http_methods = {HTTPMethod .GET },
402414 )
403- def get_target (self , request : "Request" , context : "Context" ) -> str :
415+ def get_target (
416+ self , request : "Request" , context : "Context"
417+ ) -> _ResponseType :
404418 """
405419 Get details of a target.
406420
@@ -468,7 +482,9 @@ def get_target(self, request: "Request", context: "Context") -> str:
468482 path_pattern = f"/duplicates/{ _TARGET_ID_PATTERN } " ,
469483 http_methods = {HTTPMethod .GET },
470484 )
471- def get_duplicates (self , request : "Request" , context : "Context" ) -> str :
485+ def get_duplicates (
486+ self , request : "Request" , context : "Context"
487+ ) -> _ResponseType :
472488 """
473489 Get targets which may be considered duplicates of a given target.
474490
@@ -542,7 +558,9 @@ def get_duplicates(self, request: "Request", context: "Context") -> str:
542558 path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
543559 http_methods = {HTTPMethod .PUT },
544560 )
545- def update_target (self , request : "Request" , context : "Context" ) -> str :
561+ def update_target (
562+ self , request : "Request" , context : "Context"
563+ ) -> _ResponseType :
546564 """
547565 Update a target.
548566
@@ -651,7 +669,9 @@ def update_target(self, request: "Request", context: "Context") -> str:
651669 path_pattern = f"/summary/{ _TARGET_ID_PATTERN } " ,
652670 http_methods = {HTTPMethod .GET },
653671 )
654- def target_summary (self , request : "Request" , context : "Context" ) -> str :
672+ def target_summary (
673+ self , request : "Request" , context : "Context"
674+ ) -> _ResponseType :
655675 """
656676 Get a summary report for a target.
657677
0 commit comments