Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/great_expectations/rule_based_profiler/data_assistant/data_assistant.py b/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
--- a/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
+++ b/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
@@ -223,10 +223,10 @@ def variables(self) -> Optional[Dict[str, Any]]:
 
     @property
     @abstractmethod
-    def rules(self) -> Optional[Dict[str, Dict[str, Any]]]:
+    def rules(self) -> Optional[List[Rule]]:
         """
         Returns:
-            Optional custom "rules" configuration attribute name/(configuration-dictionary) (overrides) can be added.
+            Optional custom list of "Rule" objects (overrides) can be added by subclasses (return "None" if not needed).
         """
         pass
 
@@ -360,9 +360,16 @@ def run_profiler_on_data(
     expectation_suite_name: Optional[str] = None,
     include_citation: bool = True,
 ) -> None:
+    if rules is None:
+        rules = []
+
+    rule: Rule
+    rules_configs: Optional[Dict[str, Dict[str, Any]]] = {
+        rule.name: rule.to_json_dict() for rule in rules
+    }
     profiler.run(
         variables=variables,
-        rules=rules,
+        rules=rules_configs,
         batch_list=batch_list,
         batch_request=batch_request,
         force_batch_data=False,
diff --git a/great_expectations/rule_based_profiler/data_assistant/volume_data_assistant.py b/great_expectations/rule_based_profiler/data_assistant/volume_data_assistant.py
--- a/great_expectations/rule_based_profiler/data_assistant/volume_data_assistant.py
+++ b/great_expectations/rule_based_profiler/data_assistant/volume_data_assistant.py
@@ -8,6 +8,7 @@
     MetricMultiBatchParameterBuilder,
     ParameterBuilder,
 )
+from great_expectations.rule_based_profiler.rule import Rule
 from great_expectations.rule_based_profiler.types import (
     DOMAIN_KWARGS_PARAMETER_FULLY_QUALIFIED_NAME,
 )
@@ -74,5 +75,5 @@ def variables(self) -> Optional[Dict[str, Any]]:
         return None
 
     @property
-    def rules(self) -> Optional[Dict[str, Dict[str, Any]]]:
+    def rules(self) -> Optional[List[Rule]]:
         return None
diff --git a/great_expectations/rule_based_profiler/parameter_builder/simple_date_format_string_parameter_builder.py b/great_expectations/rule_based_profiler/parameter_builder/simple_date_format_string_parameter_builder.py
--- a/great_expectations/rule_based_profiler/parameter_builder/simple_date_format_string_parameter_builder.py
+++ b/great_expectations/rule_based_profiler/parameter_builder/simple_date_format_string_parameter_builder.py
@@ -233,18 +233,18 @@ def _build_parameters(
         )
 
         # Gather "metric_value_kwargs" for all candidate "strftime_format" strings.
-        fmt_string: str
+        format_string: str
         match_strftime_metric_value_kwargs_list: List[dict] = []
         match_strftime_metric_value_kwargs: dict
-        for fmt_string in candidate_strings:
+        for format_string in candidate_strings:
             if self.metric_value_kwargs:
                 match_strftime_metric_value_kwargs = {
                     **self.metric_value_kwargs,
-                    **{"strftime_format": fmt_string},
+                    **{"strftime_format": format_string},
                 }
             else:
                 match_strftime_metric_value_kwargs = {
-                    "strftime_format": fmt_string,
+                    "strftime_format": format_string,
                 }
 
             match_strftime_metric_value_kwargs_list.append(
@@ -285,24 +285,24 @@ def _build_parameters(
         )
 
         # get best-matching datetime string that matches greater than threshold
-        best_fmt_string: str
+        best_format_string: str
         best_ratio: float
         (
-            best_fmt_string,
+            best_format_string,
             best_ratio,
         ) = ParameterBuilder._get_best_candidate_above_threshold(
             format_string_success_ratios, threshold
         )
         # dict of sorted datetime and ratios for all evaluated candidates
-        sorted_fmt_strings_and_ratios: dict = (
+        sorted_format_strings_and_ratios: dict = (
             ParameterBuilder._get_sorted_candidates_and_ratios(
                 format_string_success_ratios
             )
         )
         return (
-            best_fmt_string,
+            best_format_string,
             {
                 "success_ratio": best_ratio,
-                "candidate_strings": sorted_fmt_strings_and_ratios,
+                "candidate_strings": sorted_format_strings_and_ratios,
             },
         )


Test patch: