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/domain_builder/types/domain.py b/great_expectations/rule_based_profiler/domain_builder/types/domain.py
--- a/great_expectations/rule_based_profiler/domain_builder/types/domain.py
+++ b/great_expectations/rule_based_profiler/domain_builder/types/domain.py
@@ -80,21 +80,11 @@ def __init__(
             details=details,
         )
 
-    # Adding this property for convenience (also, in the future, arguments may not be all set to their default values).
-    @property
-    def id(self) -> str:
-        return IDDict(self.to_json_dict()).to_id()
-
-    def to_json_dict(self) -> dict:
-        json_dict: dict = {
-            "domain_type": self["domain_type"].value,
-            "domain_kwargs": self["domain_kwargs"].to_json_dict(),
-            "details": {key: value.value for key, value in self["details"].items()},
-        }
-        return filter_properties_dict(properties=json_dict, clean_falsy=True)
+    def __repr__(self):
+        return json.dumps(self.to_json_dict(), indent=2)
 
     def __str__(self):
-        return json.dumps(self.to_json_dict(), indent=2)
+        return self.__repr__()
 
     def __eq__(self, other):
         return (other is not None) and (
@@ -113,6 +103,19 @@ def __eq__(self, other):
     def __ne__(self, other):
         return not self.__eq__(other=other)
 
+    # Adding this property for convenience (also, in the future, arguments may not be all set to their default values).
+    @property
+    def id(self) -> str:
+        return IDDict(self.to_json_dict()).to_id()
+
+    def to_json_dict(self) -> dict:
+        json_dict: dict = {
+            "domain_type": self["domain_type"].value,
+            "domain_kwargs": self["domain_kwargs"].to_json_dict(),
+            "details": {key: value.value for key, value in self["details"].items()},
+        }
+        return filter_properties_dict(properties=json_dict, clean_falsy=True)
+
     def _convert_dictionaries_to_domain_kwargs(
         self, source: Optional[Any] = None
     ) -> Optional[Union[Any, "Domain"]]:
diff --git a/great_expectations/validator/validation_graph.py b/great_expectations/validator/validation_graph.py
--- a/great_expectations/validator/validation_graph.py
+++ b/great_expectations/validator/validation_graph.py
@@ -1,4 +1,5 @@
 import copy
+import json
 from typing import Dict, List, Optional, Tuple
 
 from great_expectations.core.id_dict import IDDict
@@ -25,6 +26,12 @@ def __init__(
             metric_dependencies = dict()
         self.metric_dependencies = metric_dependencies
 
+    def __repr__(self):
+        return json.dumps(self.to_json_dict(), indent=2)
+
+    def __str__(self):
+        return self.__repr__()
+
     @property
     def metric_name(self):
         return self._metric_name
@@ -39,11 +46,11 @@ def metric_value_kwargs(self):
 
     @property
     def metric_domain_kwargs_id(self):
-        return self._metric_domain_kwargs.to_id()
+        return self.metric_domain_kwargs.to_id()
 
     @property
     def metric_value_kwargs_id(self):
-        return self._metric_value_kwargs.to_id()
+        return self.metric_value_kwargs.to_id()
 
     @property
     def id(self) -> Tuple[str, str, str]:
@@ -53,6 +60,17 @@ def id(self) -> Tuple[str, str, str]:
             self.metric_value_kwargs_id,
         )
 
+    def to_json_dict(self) -> dict:
+        json_dict: dict = {
+            "metric_name": self.metric_name,
+            "metric_domain_kwargs": self.metric_domain_kwargs,
+            "metric_domain_kwargs_id": self.metric_domain_kwargs_id,
+            "metric_value_kwargs": self.metric_value_kwargs,
+            "metric_value_kwargs_id": self.metric_value_kwargs_id,
+            "id": self.id,
+        }
+        return json_dict
+
 
 class MetricEdge:
     def __init__(self, left: MetricConfiguration, right: Optional[MetricConfiguration]):


Test patch: