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/cli/cli.py b/great_expectations/cli/cli.py
--- a/great_expectations/cli/cli.py
+++ b/great_expectations/cli/cli.py
@@ -20,12 +20,12 @@
 class CLIState:
     def __init__(
         self,
-        v2_api: bool = False,
+        v3_api: bool = True,
         config_file_location: Optional[str] = None,
         data_context: DataContext = None,
         assume_yes: bool = False,
     ):
-        self.v2_api = v2_api
+        self.v3_api = v3_api
         self.config_file_location = config_file_location
         self._data_context = data_context
         self.assume_yes = assume_yes
@@ -40,15 +40,14 @@ def data_context(self, data_context):
         self._data_context = data_context
 
     def __repr__(self):
-        return f"CLIState(v2_api={self.v2_api}, config_file_location={self.config_file_location})"
+        return f"CLIState(v3_api={self.v3_api}, config_file_location={self.config_file_location})"
 
 
 class CLI(click.MultiCommand):
     def list_commands(self, ctx):
         # note that if --help is called this method is invoked before any flags
         # are parsed or context set.
-
-        return [
+        commands = [
             "checkpoint",
             "datasource",
             "docs",
@@ -56,15 +55,16 @@ def list_commands(self, ctx):
             "project",
             "store",
             "suite",
-            "validation_operator",
         ]
 
+        return commands
+
     def get_command(self, ctx, name):
         module_name = name.replace("-", "_")
         legacy_module = ""
-
-        if self.is_v2_api(ctx):
+        if not self.is_v3_api(ctx):
             legacy_module += ".v012"
+
         try:
             requested_module = f"great_expectations.cli{legacy_module}.{module_name}"
             module = importlib.import_module(requested_module)
@@ -88,27 +88,27 @@ def print_ctx_debugging(ctx):
         print(f"ctx.find_root().protected_args: {ctx.find_root().protected_args}")
 
     @staticmethod
-    def is_v2_api(ctx):
-        """Determine if v2 api is requested by searching context params."""
+    def is_v3_api(ctx):
+        """Determine if v3 api is requested by searching context params."""
         if ctx.params:
-            return ctx.params and "v2_api" in ctx.params.keys() and ctx.params["v2_api"]
+            return ctx.params and "v3_api" in ctx.params.keys() and ctx.params["v3_api"]
 
         root_ctx_params = ctx.find_root().params
         return (
             root_ctx_params
-            and "v2_api" in root_ctx_params.keys()
-            and root_ctx_params["v2_api"]
+            and "v3_api" in root_ctx_params.keys()
+            and root_ctx_params["v3_api"]
         )
 
 
 @click.group(cls=CLI, name="great_expectations")
 @click.version_option(version=ge_version)
 @click.option(
-    "--v2-api/--v3-api",
-    "v2_api",
+    "--v3-api/--v2-api",
+    "v3_api",
     is_flag=True,
     default=True,
-    help="Default to v2 (Batch Kwargs) API. Use --v3-api for v3 (Batch Request) API",
+    help="Default to v3 (Batch Request) API. Use --v2-api for v2 (Batch Kwargs) API",
 )
 @click.option(
     "--verbose",
@@ -133,7 +133,7 @@ def is_v2_api(ctx):
     help='Assume "yes" for all prompts.',
 )
 @click.pass_context
-def cli(ctx, v2_api, verbose, config_file_location, assume_yes):
+def cli(ctx, v3_api, verbose, config_file_location, assume_yes):
     """
     Welcome to the great_expectations CLI!
 
@@ -148,13 +148,13 @@ def cli(ctx, v2_api, verbose, config_file_location, assume_yes):
         # more control over console UI.
         logger.setLevel(logging.DEBUG)
     ctx.obj = CLIState(
-        v2_api=v2_api, config_file_location=config_file_location, assume_yes=assume_yes
+        v3_api=v3_api, config_file_location=config_file_location, assume_yes=assume_yes
     )
 
-    if v2_api:
-        cli_message("Using v2 (Batch Kwargs) API")
-    else:
+    if v3_api:
         cli_message("Using v3 (Batch Request) API")
+    else:
+        cli_message("Using v2 (Batch Kwargs) API")
 
 
 def main():
diff --git a/great_expectations/cli/cli_messages.py b/great_expectations/cli/cli_messages.py
--- a/great_expectations/cli/cli_messages.py
+++ b/great_expectations/cli/cli_messages.py
@@ -51,10 +51,10 @@
 HOW_TO_CUSTOMIZE = f"""\n<cyan>You can customize your configuration in many ways. Here are some examples:</cyan>
 
   <cyan>Use the CLI to:</cyan>
-    - Run `<green>great_expectations --v3-api datasource new</green>` to connect to your data.
-    - Run `<green>great_expectations --v3-api checkpoint new <checkpoint_name></green>` to bundle data with Expectation Suite(s) in a Checkpoint for later re-validation.
-    - Run `<green>great_expectations --v3-api suite --help</green>` to create, edit, list, profile Expectation Suites.
-    - Run `<green>great_expectations --v3-api docs --help</green>` to build and manage Data Docs sites.
+    - Run `<green>great_expectations datasource new</green>` to connect to your data.
+    - Run `<green>great_expectations checkpoint new <checkpoint_name></green>` to bundle data with Expectation Suite(s) in a Checkpoint for later re-validation.
+    - Run `<green>great_expectations suite --help</green>` to create, edit, list, profile Expectation Suites.
+    - Run `<green>great_expectations docs --help</green>` to build and manage Data Docs sites.
 
   <cyan>Edit your configuration in {DataContext.GE_YML} to:</cyan>
     - Move Stores to the cloud
diff --git a/great_expectations/cli/toolkit.py b/great_expectations/cli/toolkit.py
--- a/great_expectations/cli/toolkit.py
+++ b/great_expectations/cli/toolkit.py
@@ -34,7 +34,7 @@
 
 EXIT_UPGRADE_CONTINUATION_MESSAGE = (
     "\nOk, exiting now. To upgrade at a later time, use the following command: "
-    "<cyan>great_expectations --v3-api project upgrade</cyan>\n\nTo learn more about the upgrade "
+    "<cyan>great_expectations project upgrade</cyan>\n\nTo learn more about the upgrade "
     "process, visit "
     "<cyan>https://docs.greatexpectations.io/docs/guides/miscellaneous/migration_guide#migrating-to-the-batch-request-v3-api"
     "</cyan>.\n"


Test patch:
diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py
--- a/tests/cli/test_cli.py
+++ b/tests/cli/test_cli.py
@@ -36,8 +36,8 @@ def test_cli_command_help(caplog, invocation):
     assert (
         """Options:
   --version                Show the version and exit.
-  --v2-api / --v3-api      Default to v2 (Batch Kwargs) API. Use --v3-api for v3
-                           (Batch Request) API"""
+  --v3-api / --v2-api      Default to v3 (Batch Request) API. Use --v2-api for
+                           v2 (Batch Kwargs) API"""
         in result.output
     )
     assert (
diff --git a/tests/cli/upgrade_helpers/test_upgrade_helper.py b/tests/cli/upgrade_helpers/test_upgrade_helper.py
--- a/tests/cli/upgrade_helpers/test_upgrade_helper.py
+++ b/tests/cli/upgrade_helpers/test_upgrade_helper.py
@@ -87,7 +87,7 @@ def test_upgrade_helper_intervention_on_cli_command(
         in stdout
     )
     assert (
-        "Ok, exiting now. To upgrade at a later time, use the following command: [36mgreat_expectations --v3-api project "
+        "Ok, exiting now. To upgrade at a later time, use the following command: [36mgreat_expectations project "
         "upgrade[0m" in stdout
     )
     assert (
diff --git a/tests/integration/docusaurus/setup/configuring_data_docs/how_to_host_and_share_data_docs_on_gcs.py b/tests/integration/docusaurus/setup/configuring_data_docs/how_to_host_and_share_data_docs_on_gcs.py
--- a/tests/integration/docusaurus/setup/configuring_data_docs/how_to_host_and_share_data_docs_on_gcs.py
+++ b/tests/integration/docusaurus/setup/configuring_data_docs/how_to_host_and_share_data_docs_on_gcs.py
@@ -162,7 +162,7 @@ def server_error(e):
     yaml.dump(great_expectations_yaml, f)
 
 build_data_docs_command = """
-great_expectations --v3-api docs build --site-name gs_site
+great_expectations docs build --site-name gs_site
 """
 
 result = subprocess.Popen(
diff --git a/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_a_validation_result_store_in_gcs.py b/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_a_validation_result_store_in_gcs.py
--- a/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_a_validation_result_store_in_gcs.py
+++ b/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_a_validation_result_store_in_gcs.py
@@ -196,7 +196,7 @@
 
 # list validation stores
 list_validation_stores_command = """
-great_expectations --v3-api store list
+great_expectations store list
 """
 
 result = subprocess.run(
diff --git a/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_an_expectation_store_in_gcs.py b/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_an_expectation_store_in_gcs.py
--- a/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_an_expectation_store_in_gcs.py
+++ b/tests/integration/docusaurus/setup/configuring_metadata_stores/how_to_configure_an_expectation_store_in_gcs.py
@@ -132,7 +132,7 @@
 
 # list expectation stores
 list_expectation_stores_command = """
-great_expectations --v3-api store list
+great_expectations store list
 """
 
 result = subprocess.run(
@@ -159,7 +159,7 @@
 
 # list expectation suites
 list_expectation_suites_command = """
-great_expectations --v3-api suite list
+great_expectations suite list
 """
 
 result = subprocess.run(
diff --git a/tests/integration/docusaurus/validation/checkpoints/how_to_pass_an_in_memory_dataframe_to_a_checkpoint.py b/tests/integration/docusaurus/validation/checkpoints/how_to_pass_an_in_memory_dataframe_to_a_checkpoint.py
--- a/tests/integration/docusaurus/validation/checkpoints/how_to_pass_an_in_memory_dataframe_to_a_checkpoint.py
+++ b/tests/integration/docusaurus/validation/checkpoints/how_to_pass_an_in_memory_dataframe_to_a_checkpoint.py
@@ -48,7 +48,7 @@
 
 # CLI
 datasource_cli = """
-great_expectations --v3-api datasource new
+great_expectations datasource new
 """
 
 # NOTE: The following code is only for testing and can be ignored by users.
diff --git a/tests/test_fixtures/configuration_for_testing_v2_v3_migration/v3/running_checkpoint.sh b/tests/test_fixtures/configuration_for_testing_v2_v3_migration/v3/running_checkpoint.sh
--- a/tests/test_fixtures/configuration_for_testing_v2_v3_migration/v3/running_checkpoint.sh
+++ b/tests/test_fixtures/configuration_for_testing_v2_v3_migration/v3/running_checkpoint.sh
@@ -1 +1 @@
-great_expectations --v3-api checkpoint run test_v3_checkpoint
+great_expectations checkpoint run test_v3_checkpoint