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/contrib/experimental/great_expectations_experimental/expectations/expect_column_values_to_be_string_integers_increasing.py b/contrib/experimental/great_expectations_experimental/expectations/expect_column_values_to_be_string_integers_increasing.py
--- a/contrib/experimental/great_expectations_experimental/expectations/expect_column_values_to_be_string_integers_increasing.py
+++ b/contrib/experimental/great_expectations_experimental/expectations/expect_column_values_to_be_string_integers_increasing.py
@@ -135,7 +135,6 @@ def _get_evaluation_dependencies(
             metric_value_kwargs={
                 "include_nested": True,
             },
-            metric_dependencies=None,
         )
 
         return dependencies
diff --git a/great_expectations/rule_based_profiler/domain_builder/column_domain_builder.py b/great_expectations/rule_based_profiler/domain_builder/column_domain_builder.py
--- a/great_expectations/rule_based_profiler/domain_builder/column_domain_builder.py
+++ b/great_expectations/rule_based_profiler/domain_builder/column_domain_builder.py
@@ -42,6 +42,7 @@ class ColumnDomainBuilder(DomainBuilder):
     """
 
     exclude_field_names: ClassVar[Set[str]] = DomainBuilder.exclude_field_names | {
+        "table_column_names",
         "semantic_type_filter",
     }
 
@@ -97,6 +98,8 @@ def __init__(
 
         self._semantic_type_filter = None
 
+        self._table_column_names: List[str] = []
+
     @property
     def domain_type(self) -> MetricDomainTypes:
         return MetricDomainTypes.COLUMN
@@ -196,23 +199,17 @@ def exclude_semantic_types(
     def semantic_type_filter(self) -> Optional[SemanticTypeFilter]:
         return self._semantic_type_filter
 
-    def get_effective_column_names(
+    def get_table_column_names(
         self,
         batch_ids: Optional[List[str]] = None,
         validator: Optional[Validator] = None,
         variables: Optional[ParameterContainer] = None,
     ) -> List[str]:
         """
-        This method applies multiple directives to obtain columns to be included as part of returned "Domain" objects.
+        This method returns all column names available (i.e., prior to any inclusions/exclusions filtering is applied).
         """
-        include_column_names: List[str] = cast(
-            List[str],
-            self._resolve_list_type_property(
-                property_name="include_column_names",
-                property_value_type=list,
-                variables=variables,
-            ),
-        )
+        if self._table_column_names:
+            return self._table_column_names
 
         if batch_ids is None:
             batch_ids: List[str] = self.get_batch_ids(variables=variables)  # type: ignore[no-redef]
@@ -230,8 +227,30 @@ def get_effective_column_names(
                 metric_value_kwargs=None,
             )
         )
+        self._table_column_names = table_columns
+
+        return self._table_column_names
+
+    def get_filtered_column_names(
+        self,
+        column_names: List[str],
+        batch_ids: Optional[List[str]] = None,
+        validator: Optional[Validator] = None,
+        variables: Optional[ParameterContainer] = None,
+    ) -> List[str]:
+        """
+        This method returns list of column names, filtered according to directives supplied via instance attributes.
+        """
+        include_column_names: List[str] = cast(
+            List[str],
+            self._resolve_list_type_property(
+                property_name="include_column_names",
+                property_value_type=list,
+                variables=variables,
+            ),
+        )
 
-        effective_column_names: List[str] = include_column_names or table_columns
+        filtered_column_names: List[str] = include_column_names or column_names
 
         exclude_column_names: List[str] = cast(
             List[str],
@@ -244,14 +263,14 @@ def get_effective_column_names(
 
         column_name: str
 
-        effective_column_names = [
+        filtered_column_names = [
             column_name
-            for column_name in effective_column_names
+            for column_name in filtered_column_names
             if column_name not in exclude_column_names
         ]
 
-        for column_name in effective_column_names:
-            if column_name not in table_columns:
+        for column_name in filtered_column_names:
+            if column_name not in column_names:
                 raise gx_exceptions.ProfilerExecutionError(
                     message=f'Error: The column "{column_name}" in BatchData does not exist.'
                 )
@@ -265,12 +284,12 @@ def get_effective_column_names(
             ),
         )
         if include_column_name_suffixes:
-            effective_column_names = list(
+            filtered_column_names = list(
                 filter(
                     lambda candidate_column_name: candidate_column_name.endswith(
                         tuple(include_column_name_suffixes)
                     ),
-                    effective_column_names,
+                    filtered_column_names,
                 )
             )
 
@@ -283,12 +302,12 @@ def get_effective_column_names(
             ),
         )
         if exclude_column_name_suffixes:
-            effective_column_names = list(
+            filtered_column_names = list(
                 filter(
                     lambda candidate_column_name: not candidate_column_name.endswith(
                         tuple(exclude_column_name_suffixes)
                     ),
-                    effective_column_names,
+                    filtered_column_names,
                 )
             )
 
@@ -326,7 +345,7 @@ def get_effective_column_names(
             runtime_environment={
                 "batch_ids": batch_ids,
                 "validator": validator,
-                "column_names": effective_column_names,
+                "column_names": filtered_column_names,
             },
             config_defaults={},
         )
@@ -345,13 +364,13 @@ def get_effective_column_names(
         )
 
         if include_semantic_types:
-            effective_column_names = list(
+            filtered_column_names = list(
                 filter(
                     lambda candidate_column_name: self.semantic_type_filter.table_column_name_to_inferred_semantic_domain_type_map[  # type: ignore[union-attr,arg-type]
                         candidate_column_name
                     ]
                     in include_semantic_types,
-                    effective_column_names,
+                    filtered_column_names,
                 )
             )
 
@@ -368,16 +387,46 @@ def get_effective_column_names(
         )
 
         if exclude_semantic_types:
-            effective_column_names = list(
+            filtered_column_names = list(
                 filter(
                     lambda candidate_column_name: self.semantic_type_filter.table_column_name_to_inferred_semantic_domain_type_map[  # type: ignore[union-attr,arg-type] # lambda missing type details
                         candidate_column_name
                     ]
                     not in exclude_semantic_types,
-                    effective_column_names,
+                    filtered_column_names,
                 )
             )
 
+        return filtered_column_names
+
+    def get_effective_column_names(
+        self,
+        batch_ids: Optional[List[str]] = None,
+        validator: Optional[Validator] = None,
+        variables: Optional[ParameterContainer] = None,
+    ) -> List[str]:
+        """
+        This method applies multiple directives to obtain columns to be included as part of returned "Domain" objects.
+        """
+        if batch_ids is None:
+            batch_ids: List[str] = self.get_batch_ids(variables=variables)  # type: ignore[no-redef]
+
+        if validator is None:
+            validator = self.get_validator(variables=variables)
+
+        table_columns: List[str] = self.get_table_column_names(
+            batch_ids=batch_ids,
+            validator=validator,
+            variables=variables,
+        )
+
+        effective_column_names: List[str] = self.get_filtered_column_names(
+            column_names=table_columns,
+            batch_ids=batch_ids,
+            validator=validator,
+            variables=variables,
+        )
+
         return effective_column_names
 
     def _get_domains(
diff --git a/great_expectations/validator/metric_configuration.py b/great_expectations/validator/metric_configuration.py
--- a/great_expectations/validator/metric_configuration.py
+++ b/great_expectations/validator/metric_configuration.py
@@ -23,7 +23,6 @@ class MetricConfiguration:
         metric_value_kwargs (optional[dict]): Optional kwargs that define values specific to each Metric.  For instance,
             a Metric that partitions a column can define the method of partitioning (`uniform` bins) and the number of
             bins (`n_bins`) as `metric_value_kwargs`.
-        metric_dependencies (optional[dict]): This is a dict consisting of all Metrics necessary to evaluate the Expectation.
     """
 
     def __init__(
@@ -31,7 +30,6 @@ def __init__(
         metric_name: str,
         metric_domain_kwargs: dict,
         metric_value_kwargs: Optional[dict] = None,
-        metric_dependencies: Optional[dict] = None,
     ) -> None:
         self._metric_name = metric_name
 
@@ -48,8 +46,6 @@ def __init__(
         self._metric_value_kwargs: IDDict = metric_value_kwargs
 
         self._metric_dependencies: IDDict = IDDict({})
-        if metric_dependencies is not None:
-            self._metric_dependencies = IDDict(metric_dependencies)
 
     def __repr__(self):
         return json.dumps(self.to_json_dict(), indent=2)
@@ -82,7 +78,13 @@ def metric_dependencies(self) -> IDDict:
         return self._metric_dependencies
 
     @metric_dependencies.setter
-    def metric_dependencies(self, metric_dependencies) -> None:
+    def metric_dependencies(self, metric_dependencies: dict) -> None:
+        if metric_dependencies is None:
+            metric_dependencies = IDDict({})
+
+        if not isinstance(metric_dependencies, IDDict):
+            metric_dependencies = IDDict(metric_dependencies)
+
         self._metric_dependencies = metric_dependencies
 
     def get_domain(self) -> Domain:


Test patch: