2323from __future__ import annotations
2424
2525import json
26- from typing import Any , Optional
26+ from typing import Any , Optional , Union
2727from sonar import metrics , exceptions , platform
2828from sonar .util .types import ApiPayload , ApiParams , KeyList
2929from sonar .util import cache , constants as c
@@ -121,8 +121,8 @@ def is_a_percent(self) -> bool:
121121 def is_an_effort (self ) -> bool :
122122 return metrics .is_an_effort (self .endpoint , self .key )
123123
124- def format (self , ratings : str = "letters" , percents : str = "float" ) -> any :
125- return format (self .endpoint , self .key , self .value , ratings = ratings , percents = percents )
124+ def format_measure (self , ratings : str = "letters" , percents : str = "float" ) -> any :
125+ return format_measure (self .endpoint , self .key , self .value , ratings = ratings , percents = percents )
126126
127127
128128def get (concerned_object : object , metrics_list : KeyList , ** kwargs ) -> dict [str , Measure ]:
@@ -171,7 +171,7 @@ def get_history(concerned_object: object, metrics_list: KeyList, **kwargs) -> li
171171 return res_list
172172
173173
174- def get_rating_letter (rating : Any ) -> str :
174+ def get_rating_letter (rating : Union [ int , float , str ] ) -> str :
175175 """
176176 :param any rating: The rating as repturned by the API (a str or float)
177177 :return: The rating converted from number to letter, if number between 1 and 5, else the unchanged rating
@@ -197,7 +197,7 @@ def get_rating_number(rating_letter: str) -> int:
197197 return rating_letter
198198
199199
200- def format (endpoint : platform .Platform , metric_key : str , value : Any , ratings : str = "letters" , percents : str = "float" ) -> Any :
200+ def format_measure (endpoint : platform .Platform , metric_key : str , value : Any , ratings : str = "letters" , percents : str = "float" ) -> Any :
201201 """Formats a measure"""
202202 try :
203203 metric = metrics .Metric .get_object (endpoint , metric_key )
0 commit comments