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/checkpoint/checkpoint.py b/great_expectations/checkpoint/checkpoint.py
--- a/great_expectations/checkpoint/checkpoint.py
+++ b/great_expectations/checkpoint/checkpoint.py
@@ -144,7 +144,7 @@ def run(  # noqa: C901 - complexity 19
         run_name_template: Optional[str] = None,
         expectation_suite_name: Optional[str] = None,
         batch_request: Optional[
-            Union[FluentBatchRequest, BatchRequestBase, dict]
+            Union[BatchRequestBase, FluentBatchRequest, dict]
         ] = None,
         validator: Optional[Validator] = None,
         action_list: Optional[List[dict]] = None,
@@ -446,7 +446,7 @@ def _run_validation(
             )
 
             batch_request: Union[
-                FluentBatchRequest, BatchRequest, RuntimeBatchRequest
+                BatchRequest, FluentBatchRequest, RuntimeBatchRequest
             ] = substituted_validation_dict.get("batch_request")
             expectation_suite_name: str = substituted_validation_dict.get(
                 "expectation_suite_name"
@@ -741,7 +741,9 @@ def __init__(
         template_name: Optional[str] = None,
         run_name_template: Optional[str] = None,
         expectation_suite_name: Optional[str] = None,
-        batch_request: Optional[Union[BatchRequestBase, dict]] = None,
+        batch_request: Optional[
+            Union[BatchRequestBase, FluentBatchRequest, dict]
+        ] = None,
         validator: Optional[Validator] = None,
         action_list: Optional[List[dict]] = None,
         evaluation_parameters: Optional[dict] = None,
@@ -821,7 +823,9 @@ def run_with_runtime_args(
         template_name: Optional[str] = None,
         run_name_template: Optional[str] = None,
         expectation_suite_name: Optional[str] = None,
-        batch_request: Optional[Union[BatchRequestBase, dict]] = None,
+        batch_request: Optional[
+            Union[BatchRequestBase, FluentBatchRequest, dict]
+        ] = None,
         validator: Optional[Validator] = None,
         action_list: Optional[List[dict]] = None,
         evaluation_parameters: Optional[dict] = None,
@@ -1369,7 +1373,7 @@ def __init__(
         run_name_template: Optional[str] = None,
         expectation_suite_name: Optional[str] = None,
         batch_request: Optional[
-            Union[FluentBatchRequest, BatchRequestBase, dict]
+            Union[BatchRequestBase, FluentBatchRequest, dict]
         ] = None,
         validator: Optional[Validator] = None,
         action_list: Optional[List[dict]] = None,
@@ -1437,7 +1441,9 @@ def run(
         template_name: Optional[str] = None,
         run_name_template: Optional[str] = None,
         expectation_suite_name: Optional[str] = None,
-        batch_request: Optional[Union[BatchRequestBase, dict]] = None,
+        batch_request: Optional[
+            Union[BatchRequestBase, FluentBatchRequest, dict]
+        ] = None,
         validator: Optional[Validator] = None,
         action_list: Optional[List[dict]] = None,
         evaluation_parameters: Optional[dict] = None,
diff --git a/great_expectations/data_context/data_context/abstract_data_context.py b/great_expectations/data_context/data_context/abstract_data_context.py
--- a/great_expectations/data_context/data_context/abstract_data_context.py
+++ b/great_expectations/data_context/data_context/abstract_data_context.py
@@ -2208,7 +2208,7 @@ def run_checkpoint(
         template_name: str | None = None,
         run_name_template: str | None = None,
         expectation_suite_name: str | None = None,
-        batch_request: BatchRequestBase | dict | None = None,
+        batch_request: BatchRequestBase | FluentBatchRequest | dict | None = None,
         action_list: list[dict] | None = None,
         evaluation_parameters: dict | None = None,
         runtime_configuration: dict | None = None,
@@ -2284,7 +2284,7 @@ def _run_checkpoint(
         template_name: str | None = None,
         run_name_template: str | None = None,
         expectation_suite_name: str | None = None,
-        batch_request: BatchRequestBase | dict | None = None,
+        batch_request: BatchRequestBase | FluentBatchRequest | dict | None = None,
         action_list: list[dict] | None = None,
         evaluation_parameters: dict | None = None,
         runtime_configuration: dict | None = None,


Test patch:
diff --git a/tests/checkpoint/conftest.py b/tests/checkpoint/conftest.py
--- a/tests/checkpoint/conftest.py
+++ b/tests/checkpoint/conftest.py
@@ -38,8 +38,7 @@ def titanic_data_context_with_fluent_pandas_datasources_stats_enabled_and_expect
 
     batching_regex = r"^Titanic_1911\.csv"
     glob_directive = "*.csv"
-    # noinspection PyUnusedLocal
-    data_asset = datasource.add_csv_asset(
+    datasource.add_csv_asset(
         name="Titanic_1911",
         batching_regex=batching_regex,
         glob_directive=glob_directive,
@@ -70,8 +69,7 @@ def titanic_data_context_with_fluent_pandas_and_spark_datasources_stats_enabled_
 
     batching_regex = r"^Titanic_1911\.csv"
     glob_directive = "*.csv"
-    # noinspection PyUnusedLocal
-    data_asset = datasource.add_csv_asset(
+    datasource.add_csv_asset(
         name="Titanic_1911",
         batching_regex=batching_regex,
         glob_directive=glob_directive,
@@ -195,7 +193,6 @@ def titanic_spark_data_context_with_v013_datasource_with_checkpoints_v1_with_emp
                     - airflow_run_id
     """
 
-    # noinspection PyUnusedLocal
     context.test_yaml_config(
         name="my_datasource", yaml_config=datasource_config, pretty_print=False
     )
diff --git a/tests/checkpoint/test_checkpoint_with_fluent_datasources.py b/tests/checkpoint/test_checkpoint_with_fluent_datasources.py
--- a/tests/checkpoint/test_checkpoint_with_fluent_datasources.py
+++ b/tests/checkpoint/test_checkpoint_with_fluent_datasources.py
@@ -1088,12 +1088,43 @@ def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_
     assert result["success"]
 
 
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_validations_batch_request_sql_asset_in_checkpoint_run_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    checkpoint: Checkpoint = Checkpoint(
+        name="my_checkpoint",
+        data_context=context,
+        config_version=1,
+        run_name_template="%Y-%M-foo-bar-template",
+        expectation_suite_name="my_expectation_suite",
+        action_list=common_action_list,
+    )
+
+    result = checkpoint.run(validations=[{"batch_request": batch_request}])
+
+    assert len(context.validations_store.list_keys()) == 1
+    assert result["success"]
+
+
 @pytest.mark.integration
 @mock.patch(
     "great_expectations.core.usage_statistics.usage_statistics.UsageStatisticsHandler.emit"
 )
 @pytest.mark.slow  # 1.31s
-def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_multi_validation(
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_multi_validation_pandasdf_and_sparkdf(
     mock_emit,
     titanic_data_context_with_fluent_pandas_and_spark_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
     common_action_list,
@@ -1154,6 +1185,46 @@ def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_
     assert num_data_asset_validate_events == 4
 
 
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_multi_validation_batch_request_sql_asset_objects_in_validations_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request_0: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    batch_request_1: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_10",
+    )
+
+    checkpoint: Checkpoint = Checkpoint(
+        name="my_checkpoint",
+        data_context=context,
+        config_version=1,
+        run_name_template="%Y-%M-foo-bar-template",
+        expectation_suite_name="my_expectation_suite",
+        action_list=common_action_list,
+        validations=[
+            {"batch_request": batch_request_0},
+            {"batch_request": batch_request_1},
+        ],
+    )
+
+    result = checkpoint.run()
+
+    assert len(context.validations_store.list_keys()) == 2
+    assert result["success"]
+
+
 @pytest.mark.integration
 def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_batch_data_in_top_level_batch_request_pandasdf(
     titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
@@ -1214,6 +1285,69 @@ def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_
     assert result["success"]
 
 
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_sql_asset_in_top_level_batch_request_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    checkpoint: Checkpoint = Checkpoint(
+        name="my_checkpoint",
+        data_context=context,
+        config_version=1,
+        run_name_template="%Y-%M-foo-bar-template",
+        expectation_suite_name="my_expectation_suite",
+        action_list=common_action_list,
+        batch_request=batch_request,
+    )
+
+    result = checkpoint.run()
+
+    assert len(context.validations_store.list_keys()) == 1
+    assert result["success"]
+
+
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_sql_asset_in_checkpoint_run_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    checkpoint: Checkpoint = Checkpoint(
+        name="my_checkpoint",
+        data_context=context,
+        config_version=1,
+        run_name_template="%Y-%M-foo-bar-template",
+        expectation_suite_name="my_expectation_suite",
+        action_list=common_action_list,
+    )
+
+    result = checkpoint.run(batch_request=batch_request)
+
+    assert len(context.validations_store.list_keys()) == 1
+    assert result["success"]
+
+
 @pytest.mark.integration
 def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_dataframe_asset_in_context_run_checkpoint_pandasdf(
     titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
@@ -1284,6 +1418,42 @@ def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_
     assert result["success"]
 
 
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_batch_request_sql_asset_in_context_run_checkpoint_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    # add checkpoint config
+    checkpoint_config: dict = {
+        "class_name": "Checkpoint",
+        "name": "my_checkpoint",
+        "config_version": 1,
+        "run_name_template": "%Y-%M-foo-bar-template",
+        "expectation_suite_name": "my_expectation_suite",
+        "action_list": common_action_list,
+    }
+
+    context.add_checkpoint(**checkpoint_config)
+
+    result = context.run_checkpoint(
+        checkpoint_name="my_checkpoint", batch_request=batch_request
+    )
+
+    assert len(context.validations_store.list_keys()) == 1
+    assert result["success"]
+
+
 @pytest.mark.integration
 def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_validations_batch_request_dataframe_in_context_run_checkpoint_pandasdf(
     titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
@@ -1356,6 +1526,43 @@ def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_
     assert result["success"]
 
 
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_validations_batch_request_sql_asset_in_context_run_checkpoint_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    # add checkpoint config
+    checkpoint_config: dict = {
+        "class_name": "Checkpoint",
+        "name": "my_checkpoint",
+        "config_version": 1,
+        "run_name_template": "%Y-%M-foo-bar-template",
+        "expectation_suite_name": "my_expectation_suite",
+        "action_list": common_action_list,
+    }
+
+    context.add_checkpoint(**checkpoint_config)
+
+    result = context.run_checkpoint(
+        checkpoint_name="my_checkpoint",
+        validations=[{"batch_request": batch_request}],
+    )
+
+    assert len(context.validations_store.list_keys()) == 1
+    assert result["success"]
+
+
 @pytest.mark.integration
 def test_newstyle_checkpoint_instantiates_and_produces_a_printable_validation_result_with_batch_request_dataframe_pandasdf(
     titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
@@ -2094,3 +2301,35 @@ def test_newstyle_checkpoint_instantiates_and_produces_a_correct_validation_resu
         ]
         == 1
     )
+
+
+@pytest.mark.integration
+def test_newstyle_checkpoint_instantiates_and_produces_a_validation_result_when_run_single_runtime_batch_request_sql_asset_in_validations_sqlalchemy(
+    titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    common_action_list,
+    sa,
+):
+    context: FileDataContext = titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    # create expectation suite
+    context.add_expectation_suite("my_expectation_suite")
+
+    batch_request: FluentBatchRequest = FluentBatchRequest(
+        datasource_name="my_sqlite_datasource",
+        data_asset_name="table_partitioned_by_date_column__A_query_asset_limit_5",
+    )
+
+    checkpoint: Checkpoint = Checkpoint(
+        name="my_checkpoint",
+        data_context=context,
+        config_version=1,
+        run_name_template="%Y-%M-foo-bar-template",
+        expectation_suite_name="my_expectation_suite",
+        action_list=common_action_list,
+        validations=[{"batch_request": batch_request}],
+    )
+
+    result = checkpoint.run()
+
+    assert len(context.validations_store.list_keys()) == 1
+    assert result["success"]
diff --git a/tests/conftest.py b/tests/conftest.py
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -874,7 +874,6 @@ def data_context_with_connection_to_metrics_db(
                         table_name: multi_column_sums
                         class_name: Asset
     """
-    # noinspection PyUnusedLocal
     _: Datasource = context.test_yaml_config(
         name="my_datasource", yaml_config=datasource_config, pretty_print=False
     )
@@ -1007,7 +1006,6 @@ def titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_em
                     - airflow_run_id
     """
 
-    # noinspection PyUnusedLocal
     _: Datasource = context.test_yaml_config(
         name="my_datasource", yaml_config=datasource_config, pretty_print=False
     )
@@ -1044,7 +1042,6 @@ def titanic_v013_multi_datasource_pandas_data_context_with_checkpoints_v1_with_e
                         - data_asset_name
     """
 
-    # noinspection PyUnusedLocal
     _: BaseDatasource = context.add_datasource(
         "my_additional_datasource", **yaml.load(datasource_config)
     )
@@ -1100,7 +1097,6 @@ def titanic_v013_multi_datasource_pandas_and_sqlalchemy_execution_engine_data_co
             name: whole_table
         """
 
-        # noinspection PyUnusedLocal
         _: BaseDatasource = context.add_datasource(
             "my_sqlite_db_datasource", **yaml.load(datasource_config)
         )
@@ -1567,14 +1563,12 @@ def titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with
 
     batching_regex = r"(?P<name>.+)\.csv"
     glob_directive = "*.csv"
-    # noinspection PyUnusedLocal
     datasource.add_csv_asset(
         name="exploration", batching_regex=batching_regex, glob_directive=glob_directive
     )
 
     batching_regex = r"(.+)_(?P<timestamp>\d{8})_(?P<size>\d{4})\.csv"
     glob_directive = "*.csv"
-    # noinspection PyUnusedLocal
     datasource.add_csv_asset(
         name="users", batching_regex=batching_regex, glob_directive=glob_directive
     )
@@ -1592,7 +1586,6 @@ def titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with
     df = pd.read_csv(filepath_or_buffer=csv_source_path)
 
     dataframe_asset_name = "my_dataframe_asset"
-    # noinspection PyUnusedLocal
     datasource.add_dataframe_asset(name=dataframe_asset_name, dataframe=df)
 
     # noinspection PyProtectedMember
@@ -1623,14 +1616,12 @@ def titanic_data_context_with_fluent_pandas_and_spark_datasources_with_checkpoin
 
     batching_regex = r"(?P<name>.+)\.csv"
     glob_directive = "*.csv"
-    # noinspection PyUnusedLocal
     datasource.add_csv_asset(
         name="exploration", batching_regex=batching_regex, glob_directive=glob_directive
     )
 
     batching_regex = r"(.+)_(?P<timestamp>\d{8})_(?P<size>\d{4})\.csv"
     glob_directive = "*.csv"
-    # noinspection PyUnusedLocal
     datasource.add_csv_asset(
         name="users", batching_regex=batching_regex, glob_directive=glob_directive
     )
@@ -1649,7 +1640,6 @@ def titanic_data_context_with_fluent_pandas_and_spark_datasources_with_checkpoin
     spark_df = spark_df_from_pandas_df(spark_session, pandas_df)
 
     dataframe_asset_name = "my_dataframe_asset"
-    # noinspection PyUnusedLocal
     datasource.add_dataframe_asset(name=dataframe_asset_name, dataframe=spark_df)
 
     # noinspection PyProtectedMember
@@ -1658,6 +1648,37 @@ def titanic_data_context_with_fluent_pandas_and_spark_datasources_with_checkpoin
     return context
 
 
+@pytest.fixture
+def titanic_data_context_with_fluent_pandas_and_sqlite_datasources_with_checkpoints_v1_with_empty_store_stats_enabled(
+    titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with_empty_store_stats_enabled,
+    db_file,
+    sa,
+):
+    context = titanic_data_context_with_fluent_pandas_datasources_with_checkpoints_v1_with_empty_store_stats_enabled
+
+    datasource_name = "my_sqlite_datasource"
+    connection_string = f"sqlite:///{db_file}"
+    datasource = context.sources.add_sqlite(
+        name=datasource_name,
+        connection_string=connection_string,
+    )
+
+    query = "SELECT * from table_partitioned_by_date_column__A LIMIT 5"
+    datasource.add_query_asset(
+        name="table_partitioned_by_date_column__A_query_asset_limit_5", query=query
+    )
+
+    query = "SELECT * from table_partitioned_by_date_column__A LIMIT 10"
+    datasource.add_query_asset(
+        name="table_partitioned_by_date_column__A_query_asset_limit_10", query=query
+    )
+
+    # noinspection PyProtectedMember
+    context._save_project_config()
+
+    return context
+
+
 @pytest.fixture
 def empty_context_with_checkpoint(empty_data_context):
     context = empty_data_context