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/config/base.py b/great_expectations/rule_based_profiler/config/base.py
--- a/great_expectations/rule_based_profiler/config/base.py
+++ b/great_expectations/rule_based_profiler/config/base.py
@@ -128,15 +128,15 @@ class Meta:
 
     __config_class__ = DomainBuilderConfig
 
-    class_name = fields.String(
-        required=True,
-        allow_none=False,
-    )
     module_name = fields.String(
         required=False,
         allow_none=True,
         missing="great_expectations.rule_based_profiler.domain_builder",
     )
+    class_name = fields.String(
+        required=True,
+        allow_none=False,
+    )
     batch_request = fields.Raw(
         required=False,
         allow_none=True,
@@ -176,15 +176,15 @@ class Meta:
         required=True,
         allow_none=False,
     )
-    class_name = fields.String(
-        required=True,
-        allow_none=False,
-    )
     module_name = fields.String(
         required=False,
         allow_none=True,
         missing="great_expectations.rule_based_profiler.parameter_builder",
     )
+    class_name = fields.String(
+        required=True,
+        allow_none=False,
+    )
     json_serialize = fields.Boolean(
         required=False,
         allow_none=True,
@@ -225,15 +225,15 @@ class Meta:
 
     __config_class__ = ExpectationConfigurationBuilderConfig
 
-    class_name = fields.String(
-        required=True,
-        allow_none=False,
-    )
     module_name = fields.String(
         required=False,
         allow_none=True,
         missing="great_expectations.rule_based_profiler.expectation_configuration_builder",
     )
+    class_name = fields.String(
+        required=True,
+        allow_none=False,
+    )
     expectation_type = fields.Str(
         required=True,
         error_messages={
@@ -510,21 +510,20 @@ class RuleBasedProfilerConfigSchema(Schema):
 
     class Meta:
         unknown = INCLUDE
+        fields = (
+            "name",
+            "config_version",
+            "module_name",
+            "class_name",
+            "variables",
+            "rules",
+        )
+        ordered = True
 
     name = fields.String(
         required=True,
         allow_none=False,
     )
-    class_name = fields.String(
-        required=False,
-        allow_none=True,
-        missing="RuleBasedProfiler",
-    )
-    module_name = fields.String(
-        required=False,
-        allow_none=True,
-        missing="great_expectations.rule_based_profiler",
-    )
     config_version = fields.Float(
         required=True,
         allow_none=False,
@@ -533,6 +532,16 @@ class Meta:
             "invalid": "config version is not supported; it must be 1.0 per the current version of Great Expectations"
         },
     )
+    module_name = fields.String(
+        required=False,
+        allow_none=True,
+        missing="great_expectations.rule_based_profiler",
+    )
+    class_name = fields.String(
+        required=False,
+        allow_none=True,
+        missing="RuleBasedProfiler",
+    )
     variables = fields.Dict(
         keys=fields.String(
             required=True,


Test patch:
diff --git a/tests/integration/profiling/rule_based_profilers/test_profiler_basic_workflows.py b/tests/integration/profiling/rule_based_profilers/test_profiler_basic_workflows.py
--- a/tests/integration/profiling/rule_based_profilers/test_profiler_basic_workflows.py
+++ b/tests/integration/profiling/rule_based_profilers/test_profiler_basic_workflows.py
@@ -129,7 +129,9 @@ def test_add_rule_and_run_profiler(data_context_with_taxi_data):
         expectation_configuration_builders=[default_expectation_configuration_builder],
     )
     my_rbp: RuleBasedProfiler = RuleBasedProfiler(
-        name="my_simple_rbp", data_context=context, config_version=1.0
+        name="my_simple_rbp",
+        config_version=1.0,
+        data_context=context,
     )
     my_rbp.add_rule(rule=simple_rule)
     res: ExpectationSuite = my_rbp.run()
@@ -179,7 +181,11 @@ def test_profiler_parameter_builder_added(data_context_with_taxi_data):
         parameter_builders=[numeric_range_parameter_builder],
         expectation_configuration_builders=[config_builder],
     )
-    my_rbp = RuleBasedProfiler(name="my_rbp", data_context=context, config_version=1.0)
+    my_rbp = RuleBasedProfiler(
+        name="my_rbp",
+        config_version=1.0,
+        data_context=context,
+    )
     my_rbp.add_rule(rule=simple_rule)
     res: ExpectationSuite = my_rbp.run()
     assert len(res.expectations) == 4
@@ -229,8 +235,10 @@ def test_profiler_save_and_load(data_context_with_taxi_data):
         parameter_builders=[numeric_range_parameter_builder],
         expectation_configuration_builders=[config_builder],
     )
-    my_rbp: RuleBasedProfiler = RuleBasedProfiler(
-        name="my_rbp", data_context=context, config_version=1.0
+    my_rbp = RuleBasedProfiler(
+        name="my_rbp",
+        config_version=1.0,
+        data_context=context,
     )
     res: dict = my_rbp.config.to_json_dict()
     assert res == {
diff --git a/tests/rule_based_profiler/test_rule_based_profiler.py b/tests/rule_based_profiler/test_rule_based_profiler.py
--- a/tests/rule_based_profiler/test_rule_based_profiler.py
+++ b/tests/rule_based_profiler/test_rule_based_profiler.py
@@ -1265,7 +1265,9 @@ def test_add_single_rule(
     sample_rule_dict: dict,
 ):
     profiler: RuleBasedProfiler = RuleBasedProfiler(
-        name="my_rbp", data_context=mock_data_context, config_version=1.0
+        name="my_rbp",
+        config_version=1.0,
+        data_context=mock_data_context,
     )
     first_rule: Rule = Rule(
         name="first_rule",
@@ -1273,7 +1275,7 @@ def test_add_single_rule(
         expectation_configuration_builders=mock_expectation_configuration_builder,
     )
     first_rule.to_json_dict = MagicMock(return_value=sample_rule_dict)
-    profiler.add_rule(first_rule)
+    profiler.add_rule(rule=first_rule)
     assert len(profiler.rules) == 1
 
     duplicate_of_first_rule: Rule = Rule(
@@ -1282,7 +1284,7 @@ def test_add_single_rule(
         expectation_configuration_builders=mock_expectation_configuration_builder,
     )
     duplicate_of_first_rule.to_json_dict = MagicMock(return_value=sample_rule_dict)
-    profiler.add_rule(duplicate_of_first_rule)
+    profiler.add_rule(rule=duplicate_of_first_rule)
     assert len(profiler.rules) == 1
 
 
@@ -1301,7 +1303,9 @@ def test_add_rule_overwrite_first_rule(
 ):
 
     profiler: RuleBasedProfiler = RuleBasedProfiler(
-        name="my_rbp", data_context=mock_data_context, config_version=1.0
+        name="my_rbp",
+        config_version=1.0,
+        data_context=mock_data_context,
     )
     first_rule: Rule = Rule(
         name="first_rule",
@@ -1309,7 +1313,7 @@ def test_add_rule_overwrite_first_rule(
         expectation_configuration_builders=mock_expectation_configuration_builder,
     )
     first_rule.to_json_dict = MagicMock(return_value=sample_rule_dict)
-    profiler.add_rule(first_rule)
+    profiler.add_rule(rule=first_rule)
     assert len(profiler.rules) == 1
 
 
@@ -1327,7 +1331,9 @@ def test_add_rule_add_second_rule(
     sample_rule_dict: dict,
 ):
     profiler: RuleBasedProfiler = RuleBasedProfiler(
-        name="my_rbp", data_context=mock_data_context, config_version=1.0
+        name="my_rbp",
+        config_version=1.0,
+        data_context=mock_data_context,
     )
     first_rule: Rule = Rule(
         name="first_rule",
@@ -1335,7 +1341,7 @@ def test_add_rule_add_second_rule(
         expectation_configuration_builders=mock_expectation_configuration_builder,
     )
     first_rule.to_json_dict = MagicMock(return_value=sample_rule_dict)
-    profiler.add_rule(first_rule)
+    profiler.add_rule(rule=first_rule)
     assert len(profiler.rules) == 1
 
     second_rule: Rule = Rule(
@@ -1344,7 +1350,7 @@ def test_add_rule_add_second_rule(
         expectation_configuration_builders=mock_expectation_configuration_builder,
     )
     second_rule.to_json_dict = MagicMock(return_value=sample_rule_dict)
-    profiler.add_rule(second_rule)
+    profiler.add_rule(rule=second_rule)
     assert len(profiler.rules) == 2
 
 
@@ -1354,7 +1360,9 @@ def test_add_rule_bad_rule(
     sample_rule_dict: dict,
 ):
     profiler: RuleBasedProfiler = RuleBasedProfiler(
-        name="my_rbp", data_context=mock_data_context, config_version=1.0
+        name="my_rbp",
+        config_version=1.0,
+        data_context=mock_data_context,
     )
     not_a_rule: dict = {
         "name": "first_rule",
@@ -1362,7 +1370,8 @@ def test_add_rule_bad_rule(
         "expectation_configuration_builder": "expectation_configuration_builder",
     }
     with pytest.raises(AttributeError) as e:
-        profiler.add_rule(not_a_rule)
+        # noinspection PyTypeChecker
+        profiler.add_rule(rule=not_a_rule)
     assert "'dict' object has no attribute 'name'" in str(e.value)