40
40
41
41
_ROUTES : set [Route ] = set ()
42
42
43
+ _ResponseType = str
44
+
43
45
44
46
def route (
45
47
path_pattern : str ,
46
48
http_methods : set [HTTPMethod ],
47
- ) -> Callable [[Callable [..., str ]], Callable [..., str ]]:
49
+ ) -> Callable [[Callable [..., str ]], Callable [..., _ResponseType ]]:
48
50
"""
49
51
Register a decorated method so that it can be recognized as a route.
50
52
@@ -57,7 +59,9 @@ def route(
57
59
A decorator which takes methods and makes them recognizable as routes.
58
60
"""
59
61
60
- def decorator (method : Callable [..., str ]) -> Callable [..., str ]:
62
+ def decorator (
63
+ method : Callable [..., _ResponseType ],
64
+ ) -> Callable [..., _ResponseType ]:
61
65
"""
62
66
Register a decorated method so that it can be recognized as a route.
63
67
@@ -130,7 +134,9 @@ def __init__(
130
134
path_pattern = "/targets" ,
131
135
http_methods = {HTTPMethod .POST },
132
136
)
133
- def add_target (self , request : "Request" , context : "Context" ) -> str :
137
+ def add_target (
138
+ self , request : "Request" , context : "Context"
139
+ ) -> _ResponseType :
134
140
"""
135
141
Add a target.
136
142
@@ -207,7 +213,9 @@ def add_target(self, request: "Request", context: "Context") -> str:
207
213
path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
208
214
http_methods = {HTTPMethod .DELETE },
209
215
)
210
- def delete_target (self , request : "Request" , context : "Context" ) -> str :
216
+ def delete_target (
217
+ self , request : "Request" , context : "Context"
218
+ ) -> _ResponseType :
211
219
"""
212
220
Delete a target.
213
221
@@ -274,7 +282,9 @@ def delete_target(self, request: "Request", context: "Context") -> str:
274
282
return body_json
275
283
276
284
@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 :
278
288
"""
279
289
Get a database summary report.
280
290
@@ -340,7 +350,9 @@ def database_summary(self, request: "Request", context: "Context") -> str:
340
350
return body_json
341
351
342
352
@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 :
344
356
"""
345
357
Get a list of all targets.
346
358
@@ -400,7 +412,9 @@ def target_list(self, request: "Request", context: "Context") -> str:
400
412
path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
401
413
http_methods = {HTTPMethod .GET },
402
414
)
403
- def get_target (self , request : "Request" , context : "Context" ) -> str :
415
+ def get_target (
416
+ self , request : "Request" , context : "Context"
417
+ ) -> _ResponseType :
404
418
"""
405
419
Get details of a target.
406
420
@@ -468,7 +482,9 @@ def get_target(self, request: "Request", context: "Context") -> str:
468
482
path_pattern = f"/duplicates/{ _TARGET_ID_PATTERN } " ,
469
483
http_methods = {HTTPMethod .GET },
470
484
)
471
- def get_duplicates (self , request : "Request" , context : "Context" ) -> str :
485
+ def get_duplicates (
486
+ self , request : "Request" , context : "Context"
487
+ ) -> _ResponseType :
472
488
"""
473
489
Get targets which may be considered duplicates of a given target.
474
490
@@ -542,7 +558,9 @@ def get_duplicates(self, request: "Request", context: "Context") -> str:
542
558
path_pattern = f"/targets/{ _TARGET_ID_PATTERN } " ,
543
559
http_methods = {HTTPMethod .PUT },
544
560
)
545
- def update_target (self , request : "Request" , context : "Context" ) -> str :
561
+ def update_target (
562
+ self , request : "Request" , context : "Context"
563
+ ) -> _ResponseType :
546
564
"""
547
565
Update a target.
548
566
@@ -651,7 +669,9 @@ def update_target(self, request: "Request", context: "Context") -> str:
651
669
path_pattern = f"/summary/{ _TARGET_ID_PATTERN } " ,
652
670
http_methods = {HTTPMethod .GET },
653
671
)
654
- def target_summary (self , request : "Request" , context : "Context" ) -> str :
672
+ def target_summary (
673
+ self , request : "Request" , context : "Context"
674
+ ) -> _ResponseType :
655
675
"""
656
676
Get a summary report for a target.
657
677
0 commit comments