@@ -59,17 +59,17 @@ def __init__(self, data: Dict):
5959 self .string_result = None
6060
6161 if result_type == "string" or result_type == "error" :
62- self .string_result = str (result )
62+ self .string_result : str = str (result )
6363 elif result_type == "scalar" and isinstance (result , list ):
64- self .scalar_result = PrometheusScalarValue (result ).to_dict ()
64+ self .scalar_result : Dict [ str , any ] = PrometheusScalarValue (result ).to_dict ()
6565 elif result_type == "vector" and isinstance (result , list ):
66- self .vector_result = self ._format_vector (result )
66+ self .vector_result : List [ Dict [ str , any ]] = self ._format_vector (result )
6767 elif result_type == "matrix" and isinstance (result , list ):
68- self .series_list_result = self ._format_series (result )
68+ self .series_list_result : List [ Dict [ str , any ]] = self ._format_series (result )
6969 else :
7070 raise ValueError ("result or returnType is invalid" )
7171
72- def _format_vector (self , vector : List ):
72+ def _format_vector (self , vector : List ) -> List [ Dict [ str , any ]] :
7373 """ Convert vector result into a list of dictionaries for JSON """
7474 return [
7575 {
@@ -79,7 +79,7 @@ def _format_vector(self, vector: List):
7979 for vector_item in vector
8080 ]
8181
82- def _format_series (self , series : List ):
82+ def _format_series (self , series : List ) -> List [ Dict [ str , any ]] :
8383 """ Convert matrix (series) result into a list of PrometheusSeries dictionaries for JSON """
8484 return [
8585 PrometheusSeries (series_item ["metric" ], series_item ["values" ]).to_dict ()
0 commit comments