11"""CheckType Implementation."""
2- from typing import Mapping , Iterable , Tuple , Union , List
2+ from typing import Mapping , Iterable , Tuple , Union , List , Dict , Any
33from .evaluator import diff_generator
44from .runner import extract_values_from_output
55
@@ -12,7 +12,11 @@ def __init__(self, *args):
1212
1313 @staticmethod
1414 def init (* args ):
15- """Factory pattern to get the appropiate CheckType implementation."""
15+ """Factory pattern to get the appropriate CheckType implementation.
16+
17+ Args:
18+ *args: Variable length argument list.
19+ """
1620 check_type = args [0 ]
1721 if check_type == "exact_match" :
1822 return ExactMatchType (* args )
@@ -21,18 +25,23 @@ def init(*args):
2125 raise NotImplementedError
2226
2327 @staticmethod
24- def extract_value_from_json_path (
25- output : Union [Mapping , Iterable ], path : str , exclude : List = None
26- ) -> Union [Mapping , List , int , str , bool ]:
28+ def extract_value_from_json_path (output : Union [Mapping , Iterable ], path : str , exclude : List = None ) -> Any :
2729 """Return the value contained into a Mapping for a defined path."""
2830 return extract_values_from_output (output , path , exclude )
2931
3032 def evaluate (
3133 self , reference_value : Union [Mapping , Iterable ], value_to_compare : Union [Mapping , Iterable ]
32- ) -> Tuple [Mapping , bool ]:
34+ ) -> Tuple [Dict , bool ]:
3335 """Return the result of the evaluation and a boolean True if it passes it or False otherwise.
3436
3537 This method is the one that each CheckType has to implement.
38+
39+ Args:
40+ reference_value: dataset to compare
41+ value_to_compare: dataset to compare
42+
43+ Returns:
44+ tuple: Dictionary representing differences between datasets, bool indicating if differences are found.
3645 """
3746 raise NotImplementedError
3847
@@ -52,12 +61,12 @@ class ToleranceType(CheckType):
5261 """Tolerance class docstring."""
5362
5463 def __init__ (self , * args ):
55- """Tollerance init method."""
64+ """Tolerance init method."""
5665 self .tolerance_factor = float (args [1 ]) / 100
5766 super ().__init__ ()
5867
5968 def evaluate (self , reference_value : Mapping , value_to_compare : Mapping ) -> Tuple [Mapping , bool ]:
60- """Returns the difference between values and the boolean."""
69+ """Returns the difference between values and the boolean. Overwrites method in base class. """
6170 diff = diff_generator (reference_value , value_to_compare )
6271 diff = self ._get_outliers (diff )
6372 return diff , not diff
0 commit comments