Repository: great-expectations/great_expectations
Pull request #6858 (2023-01-20 18:34:42)

[DOCS] Add public API docstring for `expect_column_values_to_be_between` `validate_configuration`
Changes proposed in this pull request:
- DX-237
- Add docstring

### Definition of Done
- [X] My code follows the Great Expectations [style guide](https://docs.greatexpectations.io/docs/contributing/style_guides/code_style)
- [X] I have performed a [self-review](https://docs.greatexpectations.io/docs/contributing/contributing_checklist) of my own code
- [X] I have commented my code, particularly in hard-to-understand areas
- [X] I have made corresponding changes to the documentation
- [X] I have added [unit tests](https://docs.greatexpectations.io/docs/contributing/contributing_test#writing-unit-and-integration-tests) where applicable and made sure that new and existing tests are passing.
- [X] I have run any local integration tests and made sure that nothing is broken.


netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *niobium-lead-7998* processing.


|  Name | Link |
|---------------------------------|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 1b3afc09fd79690afa117e158a8859752389c7ff |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/niobium-lead-7998/deploys/63cadec4b81bd20008527006 |
codesee-maps[bot]: <details>
<summary><b>👇 <a href="https://app.codesee.io/r/reviews?pr=6858&src=https%3A%2F%2Fgithub.com%2Fgreat-expectations%2Fgreat_expectations">Click on the image</a> for a new way to code review</b>
</summary>

  - Make big changes easier — review code in small groups of related files
  - Know where to start — see the whole change at a glance
  - Take a code tour — explore the change with an interactive tour
  - Make comments and review — all fully sync’ed with github

    [Try it now!](https://app.codesee.io/r/reviews?pr=6858&src=https%3A%2F%2Fgithub.com%2Fgreat-expectations%2Fgreat_expectations)
</details>

[![Review these changes using an interactive CodeSee Map](https://s3.us-east-2.amazonaws.com/maps.codesee.io/images/github/great-expectations/great_expectations/6858/72f859f5/1b3afc09fd79690afa117e158a8859752389c7ff.svg)](https://app.codesee.io/r/reviews?pr=6858&src=https%3A%2F%2Fgithub.com%2Fgreat-expectations%2Fgreat_expectations)

#### Legend
![CodeSee Map Legend](https://app.codesee.io/Legend_v2.png)

Patch:
diff --git a/great_expectations/expectations/core/expect_column_values_to_be_between.py b/great_expectations/expectations/core/expect_column_values_to_be_between.py
index f55a4e5d5..616f9fa71 100644
--- a/great_expectations/expectations/core/expect_column_values_to_be_between.py
+++ b/great_expectations/expectations/core/expect_column_values_to_be_between.py
@@ -1,9 +1,11 @@
 from typing import TYPE_CHECKING, List, Optional
 
+import great_expectations.exceptions as gx_exceptions
 from great_expectations.core import (
     ExpectationConfiguration,
     ExpectationValidationResult,
 )
+from great_expectations.core._docs_decorators import public_api
 from great_expectations.expectations.expectation import (
     ColumnMapExpectation,
     render_evaluation_parameter_string,
@@ -235,20 +237,32 @@ class ExpectColumnValuesToBeBetween(ColumnMapExpectation):
         "strict_max",
     )
 
+    @public_api
     def validate_configuration(
         self, configuration: Optional[ExpectationConfiguration] = None
     ) -> None:
-        """
-        Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
-        necessary configuration arguments have been provided for the validation of the expectation.
+        """Validates the configuration of an Expectation.
+
+        For `expect_column_values_to_be_between` it is required that:
+
+        - One of `min_value` or `max_value` is not `None`.
+
+        - `min_value` and `max_value` are one of the following types: `datetime`, `float`, `int`, or `dict`
+
+        - If `min_value` or `max_value` is a `dict`, it is assumed to be an Evaluation Parameter, and therefore the
+          dictionary keys must be `$PARAMETER`.
+
+        The configuration will also be validated using each of the `validate_configuration` methods in its Expectation
+        superclass hierarchy.
 
         Args:
-            configuration (OPTIONAL[ExpectationConfiguration]): \
-                An optional Expectation Configuration entry that will be used to configure the expectation
-        Returns:
-            None. Raises InvalidExpectationConfigurationError if the config is not validated successfully
-        """
+            configuration: An `ExpectationConfiguration` to validate. If no configuration is provided, it will be pulled
+                           from the configuration attribute of the Expectation instance.
 
+        Raises:
+            InvalidExpectationConfigurationError: The configuration does not contain the values required by the
+                                                  Expectation.
+        """
         # Setting up a configuration
         super().validate_configuration(configuration)
         configuration = configuration or self.configuration
@@ -259,9 +273,12 @@ class ExpectColumnValuesToBeBetween(ColumnMapExpectation):
             min_val = configuration.kwargs["min_value"]
         if "max_value" in configuration.kwargs:
             max_val = configuration.kwargs["max_value"]
-        assert (
-            min_val is not None or max_val is not None
-        ), "min_value and max_value cannot both be None"
+        try:
+            assert (
+                min_val is not None or max_val is not None
+            ), "min_value and max_value cannot both be None"
+        except AssertionError as e:
+            raise gx_exceptions.InvalidExpectationConfigurationError(str(e))
 
         self.validate_metric_value_between_configuration(configuration=configuration)
 


Test patch:
diff --git a/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py b/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py
index 74c2c135c..203d6c735 100644
--- a/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py
+++ b/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py
@@ -16,6 +16,7 @@ from ruamel.yaml.comments import CommentedMap
 # To support python 3.7 we must import Protocol from typing_extensions instead of typing
 from typing_extensions import Protocol
 
+import great_expectations.exceptions as gx_exceptions
 from great_expectations import DataContext
 from great_expectations.core import (
     ExpectationConfiguration,
@@ -989,7 +990,7 @@ def test_bobby_expect_column_values_to_be_between_auto_yes_default_profiler_conf
         "batch_id": "90bb41c1fbd7c71c05dbc8695320af71",
     }
 
-    with pytest.raises(AssertionError) as e:
+    with pytest.raises(gx_exceptions.InvalidExpectationConfigurationError) as e:
         # noinspection PyUnusedLocal
         result = validator.expect_column_values_to_be_between(
             column=column_name,
@@ -1169,7 +1170,7 @@ def test_bobby_expect_column_values_to_be_between_auto_yes_default_profiler_conf
             "batch_id": "90bb41c1fbd7c71c05dbc8695320af71",
         }
 
-        with pytest.raises(AssertionError) as e:
+        with pytest.raises(gx_exceptions.InvalidExpectationConfigurationError) as e:
             # noinspection PyUnusedLocal
             result = validator.expect_column_values_to_be_between(
                 column=column_name,
@@ -1422,7 +1423,7 @@ def test_bobby_expect_column_values_to_be_between_auto_yes_default_profiler_conf
             "batch_id": "90bb41c1fbd7c71c05dbc8695320af71",
         }
 
-        with pytest.raises(AssertionError) as e:
+        with pytest.raises(gx_exceptions.InvalidExpectationConfigurationError) as e:
             # noinspection PyUnusedLocal
             result = validator.expect_column_values_to_be_between(
                 column=column_name,