From f5a76a3cc26bd5b25b227eeeec49e8482b2cab86 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 11 Jan 2023 09:08:07 -0500 Subject: [PATCH] [MAINTENANCE] expectations linting (#6739) --- ...ct_column_kl_divergence_to_be_less_than.py | 6 ++-- ..._pair_cramers_phi_value_to_be_less_than.py | 4 +-- ...lumn_pair_values_a_to_be_greater_than_b.py | 4 +-- .../expect_column_pair_values_to_be_equal.py | 4 +-- ...ct_column_quantile_values_to_be_between.py | 2 +- ...expect_column_values_to_be_in_type_list.py | 2 +- ...pect_column_values_to_match_json_schema.py | 2 +- ...ect_column_values_to_match_like_pattern.py | 8 ++--- ...olumn_values_to_match_like_pattern_list.py | 8 ++--- .../expect_column_values_to_match_regex.py | 2 +- ...column_values_to_not_match_like_pattern.py | 8 ++--- ...n_values_to_not_match_like_pattern_list.py | 8 ++--- .../expect_multicolumn_values_to_be_unique.py | 4 +-- ...olumn_values_to_be_unique_within_record.py | 10 +++--- ...expect_table_column_count_to_be_between.py | 4 +-- .../expect_table_column_count_to_equal.py | 9 ++--- ...ect_table_columns_to_match_ordered_list.py | 9 ++--- .../core/expect_table_columns_to_match_set.py | 4 +-- .../expect_table_row_count_to_be_between.py | 4 +-- ...ct_table_row_count_to_equal_other_table.py | 5 +-- .../expectations/expectation.py | 36 +++++++++++-------- .../expectations/metrics/util.py | 2 +- .../regex_based_column_map_expectation.py | 5 +-- .../expectations/row_conditions.py | 15 ++++++-- .../set_based_column_map_expectation.py | 5 +-- setup.cfg | 2 +- 26 files changed, 77 insertions(+), 95 deletions(-) diff --git a/great_expectations/expectations/core/expect_column_kl_divergence_to_be_less_than.py b/great_expectations/expectations/core/expect_column_kl_divergence_to_be_less_than.py index bc16f947419a..6f13149847c5 100644 --- a/great_expectations/expectations/core/expect_column_kl_divergence_to_be_less_than.py +++ b/great_expectations/expectations/core/expect_column_kl_divergence_to_be_less_than.py @@ -366,7 +366,7 @@ def get_validation_dependencies( return validation_dependencies - def _validate( + def _validate( # noqa: C901 - 29 self, configuration: ExpectationConfiguration, metrics: Dict, @@ -528,7 +528,7 @@ def _validate( if "tail_weights" in partition_object: partition_tail_weight_holdout = np.sum(partition_object["tail_weights"]) else: - partition_tail_weight_holdout = 0 + partition_tail_weight_holdout = 0 # noqa: F841 # unused expected_weights = np.array(partition_object["weights"]) * ( 1 - tail_weight_holdout - internal_weight_holdout @@ -1152,7 +1152,7 @@ def _prescriptive_renderer( include_column_name = ( False if runtime_configuration.get("include_column_name") is False else True ) - styling = runtime_configuration.get("styling") + _ = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, [ diff --git a/great_expectations/expectations/core/expect_column_pair_cramers_phi_value_to_be_less_than.py b/great_expectations/expectations/core/expect_column_pair_cramers_phi_value_to_be_less_than.py index cc81f587026b..2c8b60144af7 100644 --- a/great_expectations/expectations/core/expect_column_pair_cramers_phi_value_to_be_less_than.py +++ b/great_expectations/expectations/core/expect_column_pair_cramers_phi_value_to_be_less_than.py @@ -96,9 +96,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, ["column_A", "column_B"] diff --git a/great_expectations/expectations/core/expect_column_pair_values_a_to_be_greater_than_b.py b/great_expectations/expectations/core/expect_column_pair_values_a_to_be_greater_than_b.py index 93960ff9deef..d5ad3900012c 100644 --- a/great_expectations/expectations/core/expect_column_pair_values_a_to_be_greater_than_b.py +++ b/great_expectations/expectations/core/expect_column_pair_values_a_to_be_greater_than_b.py @@ -167,9 +167,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, diff --git a/great_expectations/expectations/core/expect_column_pair_values_to_be_equal.py b/great_expectations/expectations/core/expect_column_pair_values_to_be_equal.py index 15780bf70d3e..f1c5560f21e9 100644 --- a/great_expectations/expectations/core/expect_column_pair_values_to_be_equal.py +++ b/great_expectations/expectations/core/expect_column_pair_values_to_be_equal.py @@ -148,9 +148,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, diff --git a/great_expectations/expectations/core/expect_column_quantile_values_to_be_between.py b/great_expectations/expectations/core/expect_column_quantile_values_to_be_between.py index 47906ba048e8..27de2cbf1d3e 100644 --- a/great_expectations/expectations/core/expect_column_quantile_values_to_be_between.py +++ b/great_expectations/expectations/core/expect_column_quantile_values_to_be_between.py @@ -410,7 +410,7 @@ def _prescriptive_renderer( include_column_name = ( False if runtime_configuration.get("include_column_name") is False else True ) - styling = runtime_configuration.get("styling") + _ = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration["kwargs"], ["column", "quantile_ranges", "row_condition", "condition_parser"], diff --git a/great_expectations/expectations/core/expect_column_values_to_be_in_type_list.py b/great_expectations/expectations/core/expect_column_values_to_be_in_type_list.py index c62d1ee3a69f..3c101fce6098 100644 --- a/great_expectations/expectations/core/expect_column_values_to_be_in_type_list.py +++ b/great_expectations/expectations/core/expect_column_values_to_be_in_type_list.py @@ -285,7 +285,7 @@ def _prescriptive_renderer( ) ] - def _validate_pandas( + def _validate_pandas( # noqa: C901 - 16 self, actual_column_type, expected_types_list, diff --git a/great_expectations/expectations/core/expect_column_values_to_match_json_schema.py b/great_expectations/expectations/core/expect_column_values_to_match_json_schema.py index c1bea62e4abb..ad4a32d59ed4 100644 --- a/great_expectations/expectations/core/expect_column_values_to_match_json_schema.py +++ b/great_expectations/expectations/core/expect_column_values_to_match_json_schema.py @@ -162,7 +162,7 @@ def _prescriptive_renderer( include_column_name = ( False if runtime_configuration.get("include_column_name") is False else True ) - styling = runtime_configuration.get("styling") + _ = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, ["column", "mostly", "json_schema", "row_condition", "condition_parser"], diff --git a/great_expectations/expectations/core/expect_column_values_to_match_like_pattern.py b/great_expectations/expectations/core/expect_column_values_to_match_like_pattern.py index 8e878a35e0d5..360462e5e2bf 100644 --- a/great_expectations/expectations/core/expect_column_values_to_match_like_pattern.py +++ b/great_expectations/expectations/core/expect_column_values_to_match_like_pattern.py @@ -123,11 +123,9 @@ def _prescriptive_renderer( **kwargs ) -> None: runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) - styling = runtime_configuration.get("styling") - params = substitute_none_for_missing( + _ = False if runtime_configuration.get("include_column_name") is False else True + _ = runtime_configuration.get("styling") + params = substitute_none_for_missing( # noqa: F841 # unused configuration.kwargs, ["column", "mostly", "row_condition", "condition_parser"], ) diff --git a/great_expectations/expectations/core/expect_column_values_to_match_like_pattern_list.py b/great_expectations/expectations/core/expect_column_values_to_match_like_pattern_list.py index c4e061fa535d..d9a02f53a657 100644 --- a/great_expectations/expectations/core/expect_column_values_to_match_like_pattern_list.py +++ b/great_expectations/expectations/core/expect_column_values_to_match_like_pattern_list.py @@ -125,11 +125,9 @@ def _prescriptive_renderer( **kwargs ) -> None: runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) - styling = runtime_configuration.get("styling") - params = substitute_none_for_missing( + _ = False if runtime_configuration.get("include_column_name") is False else True + _ = runtime_configuration.get("styling") + params = substitute_none_for_missing( # noqa: F841 # unused configuration.kwargs, ["column", "mostly", "row_condition", "condition_parser"], ) diff --git a/great_expectations/expectations/core/expect_column_values_to_match_regex.py b/great_expectations/expectations/core/expect_column_values_to_match_regex.py index 522c25f3e329..ff5ec8a23092 100644 --- a/great_expectations/expectations/core/expect_column_values_to_match_regex.py +++ b/great_expectations/expectations/core/expect_column_values_to_match_regex.py @@ -290,7 +290,7 @@ def _prescriptive_renderer( template_str = f"{conditional_template_str}, then {template_str}" params.update(conditional_params) - params_with_json_schema = { + params_with_json_schema = { # noqa: F841 # unused "column": {"schema": {"type": "string"}, "value": params.get("column")}, "mostly": {"schema": {"type": "number"}, "value": params.get("mostly")}, "mostly_pct": { diff --git a/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern.py b/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern.py index ac21c6ebcd62..87497c0b4a55 100644 --- a/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern.py +++ b/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern.py @@ -117,11 +117,9 @@ def _prescriptive_renderer( **kwargs ) -> None: runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) - styling = runtime_configuration.get("styling") - params = substitute_none_for_missing( + _ = False if runtime_configuration.get("include_column_name") is False else True + _ = runtime_configuration.get("styling") + params = substitute_none_for_missing( # noqa: F841 # unused configuration.kwargs, ["column", "mostly", "row_condition", "condition_parser"], ) diff --git a/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern_list.py b/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern_list.py index 81c5fcc6d82d..52048a0c9bd0 100644 --- a/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern_list.py +++ b/great_expectations/expectations/core/expect_column_values_to_not_match_like_pattern_list.py @@ -123,11 +123,9 @@ def _prescriptive_renderer( **kwargs ) -> None: runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) - styling = runtime_configuration.get("styling") - params = substitute_none_for_missing( + _ = False if runtime_configuration.get("include_column_name") is False else True + _ = runtime_configuration.get("styling") + params = substitute_none_for_missing( # noqa: F841 # unused configuration.kwargs, ["column", "mostly", "row_condition", "condition_parser"], ) diff --git a/great_expectations/expectations/core/expect_multicolumn_values_to_be_unique.py b/great_expectations/expectations/core/expect_multicolumn_values_to_be_unique.py index fca8e48862a2..c5d5d515fbfa 100644 --- a/great_expectations/expectations/core/expect_multicolumn_values_to_be_unique.py +++ b/great_expectations/expectations/core/expect_multicolumn_values_to_be_unique.py @@ -150,9 +150,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") # NOTE: This expectation is deprecated, please use diff --git a/great_expectations/expectations/core/expect_select_column_values_to_be_unique_within_record.py b/great_expectations/expectations/core/expect_select_column_values_to_be_unique_within_record.py index a574bf771aaf..44f4524ac97c 100644 --- a/great_expectations/expectations/core/expect_select_column_values_to_be_unique_within_record.py +++ b/great_expectations/expectations/core/expect_select_column_values_to_be_unique_within_record.py @@ -160,9 +160,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( @@ -177,9 +175,9 @@ def _prescriptive_renderer( ) if params["mostly"] is not None and params["mostly"] < 1.0: - params_with_json_schema["mostly_pct"]["value"] = num_to_str( - params["mostly"] * 100, precision=15, no_scientific=True - ) + params_with_json_schema["mostly_pct"][ # noqa: F821 # FIXME: this breaks + "value" + ] = num_to_str(params["mostly"] * 100, precision=15, no_scientific=True) template_str = "Values must be unique across columns, at least $mostly_pct % of the time: " else: template_str = "Values must always be unique across columns: " diff --git a/great_expectations/expectations/core/expect_table_column_count_to_be_between.py b/great_expectations/expectations/core/expect_table_column_count_to_be_between.py index 74789b8286e7..43f3ea84cf4b 100644 --- a/great_expectations/expectations/core/expect_table_column_count_to_be_between.py +++ b/great_expectations/expectations/core/expect_table_column_count_to_be_between.py @@ -164,9 +164,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, diff --git a/great_expectations/expectations/core/expect_table_column_count_to_equal.py b/great_expectations/expectations/core/expect_table_column_count_to_equal.py index 03c343881af7..ed007940fc68 100644 --- a/great_expectations/expectations/core/expect_table_column_count_to_equal.py +++ b/great_expectations/expectations/core/expect_table_column_count_to_equal.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Dict, Optional +from typing import Dict, Optional from great_expectations.core import ( ExpectationConfiguration, @@ -18,9 +18,6 @@ ) from great_expectations.render.util import substitute_none_for_missing -if TYPE_CHECKING: - from great_expectations.render.renderer_configuration import AddParamArgs - class ExpectTableColumnCountToEqual(TableExpectation): """Expect the number of columns to equal a value. @@ -133,9 +130,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing(configuration.kwargs, ["value"]) template_str = "Must have exactly $value columns." diff --git a/great_expectations/expectations/core/expect_table_columns_to_match_ordered_list.py b/great_expectations/expectations/core/expect_table_columns_to_match_ordered_list.py index 522ed96ab101..02a89c0df839 100644 --- a/great_expectations/expectations/core/expect_table_columns_to_match_ordered_list.py +++ b/great_expectations/expectations/core/expect_table_columns_to_match_ordered_list.py @@ -1,5 +1,5 @@ from itertools import zip_longest -from typing import TYPE_CHECKING, Dict, Optional +from typing import Dict, Optional from great_expectations.core import ( ExpectationConfiguration, @@ -19,9 +19,6 @@ ) from great_expectations.render.util import substitute_none_for_missing -if TYPE_CHECKING: - from great_expectations.render.renderer_configuration import AddParamArgs - class ExpectTableColumnsToMatchOrderedList(TableExpectation): """Expect the columns to exactly match a specified list. @@ -158,9 +155,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing(configuration.kwargs, ["column_list"]) diff --git a/great_expectations/expectations/core/expect_table_columns_to_match_set.py b/great_expectations/expectations/core/expect_table_columns_to_match_set.py index 60ae640e2ad5..0e4d3954a7f9 100644 --- a/great_expectations/expectations/core/expect_table_columns_to_match_set.py +++ b/great_expectations/expectations/core/expect_table_columns_to_match_set.py @@ -227,9 +227,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, ["column_set", "exact_match"] diff --git a/great_expectations/expectations/core/expect_table_row_count_to_be_between.py b/great_expectations/expectations/core/expect_table_row_count_to_be_between.py index 4896700cfe09..03ec35c2e319 100644 --- a/great_expectations/expectations/core/expect_table_row_count_to_be_between.py +++ b/great_expectations/expectations/core/expect_table_row_count_to_be_between.py @@ -242,9 +242,7 @@ def _prescriptive_renderer( **kwargs, ): runtime_configuration = runtime_configuration or {} - include_column_name = ( - False if runtime_configuration.get("include_column_name") is False else True - ) + _ = False if runtime_configuration.get("include_column_name") is False else True styling = runtime_configuration.get("styling") params = substitute_none_for_missing( configuration.kwargs, # type: ignore[union-attr] diff --git a/great_expectations/expectations/core/expect_table_row_count_to_equal_other_table.py b/great_expectations/expectations/core/expect_table_row_count_to_equal_other_table.py index b09fd8f9f047..be4107207950 100644 --- a/great_expectations/expectations/core/expect_table_row_count_to_equal_other_table.py +++ b/great_expectations/expectations/core/expect_table_row_count_to_equal_other_table.py @@ -1,5 +1,5 @@ from copy import deepcopy -from typing import TYPE_CHECKING, Dict, Optional +from typing import Dict, Optional from great_expectations.core import ( ExpectationConfiguration, @@ -24,9 +24,6 @@ from great_expectations.validator.metric_configuration import MetricConfiguration from great_expectations.validator.validator import ValidationDependencies -if TYPE_CHECKING: - from great_expectations.render.renderer_configuration import AddParamArgs - class ExpectTableRowCountToEqualOtherTable(TableExpectation): """Expect the number of rows to equal the number in another table. diff --git a/great_expectations/expectations/expectation.py b/great_expectations/expectations/expectation.py index c5279765a3b1..103dc43fcb83 100644 --- a/great_expectations/expectations/expectation.py +++ b/great_expectations/expectations/expectation.py @@ -1255,11 +1255,15 @@ def run_diagnostics( """ if debug_logger is not None: - _debug = lambda x: debug_logger.debug(f"(run_diagnostics) {x}") - _error = lambda x: debug_logger.error(f"(run_diagnostics) {x}") + _debug = lambda x: debug_logger.debug( # noqa: E731 + f"(run_diagnostics) {x}" + ) + _error = lambda x: debug_logger.error( # noqa: E731 + f"(run_diagnostics) {x}" + ) else: - _debug = lambda x: x - _error = lambda x: x + _debug = lambda x: x # noqa: E731 + _error = lambda x: x # noqa: E731 library_metadata: AugmentedLibraryMetadata = ( self._get_augmented_library_metadata() @@ -1481,8 +1485,8 @@ def _get_examples( top_level_suppress_test_for = example.get("suppress_test_for") for test in example["tests"]: if ( - test.get("include_in_gallery") == True - or return_only_gallery_examples == False + test.get("include_in_gallery") == True # noqa: E712 + or return_only_gallery_examples == False # noqa: E712 ): copied_test = deepcopy(test) if top_level_only_for: @@ -1737,11 +1741,15 @@ def _get_test_results( """Generate test results. This is an internal method for run_diagnostics.""" if debug_logger is not None: - _debug = lambda x: debug_logger.debug(f"(_get_test_results) {x}") - _error = lambda x: debug_logger.error(f"(_get_test_results) {x}") + _debug = lambda x: debug_logger.debug( # noqa: E731 + f"(_get_test_results) {x}" + ) + _error = lambda x: debug_logger.error( # noqa: E731 + f"(_get_test_results) {x}" + ) else: - _debug = lambda x: x - _error = lambda x: x + _debug = lambda x: x # noqa: E731 + _error = lambda x: x # noqa: E731 _debug("Starting") test_results = [] @@ -1841,7 +1849,7 @@ def _get_test_results( return test_results - def _get_rendered_result_as_string(self, rendered_result) -> str: + def _get_rendered_result_as_string(self, rendered_result) -> str: # noqa: C901 - 16 """Convenience method to get rendered results as strings.""" result: str = "" @@ -1887,7 +1895,7 @@ def _get_rendered_result_as_string(self, rendered_result) -> str: elif isinstance(rendered_result, int): result = repr(rendered_result) - elif rendered_result == None: + elif rendered_result is None: result = "" else: @@ -2232,7 +2240,7 @@ def validate_metric_value_between_configuration( return True - def _validate_metric_value_between( + def _validate_metric_value_between( # noqa: C901 - 21 self, metric_name, configuration: ExpectationConfiguration, @@ -3176,7 +3184,7 @@ def _validate( ) -def _format_map_output( +def _format_map_output( # noqa: C901 - 22 result_format: dict, success: bool, element_count: Optional[int] = None, diff --git a/great_expectations/expectations/metrics/util.py b/great_expectations/expectations/metrics/util.py index dcb06f80ec0a..3a9a4f55809a 100644 --- a/great_expectations/expectations/metrics/util.py +++ b/great_expectations/expectations/metrics/util.py @@ -114,7 +114,7 @@ ) from collections import namedtuple - BigQueryTypes = namedtuple("BigQueryTypes", sorted(sqla_bigquery._type_map)) + BigQueryTypes = namedtuple("BigQueryTypes", sorted(sqla_bigquery._type_map)) # type: ignore[misc] # cannot infer sorted return type bigquery_types_tuple = BigQueryTypes(**sqla_bigquery._type_map) except ImportError: sqla_bigquery = None diff --git a/great_expectations/expectations/regex_based_column_map_expectation.py b/great_expectations/expectations/regex_based_column_map_expectation.py index e65b261f6eb2..19d6b941eda4 100644 --- a/great_expectations/expectations/regex_based_column_map_expectation.py +++ b/great_expectations/expectations/regex_based_column_map_expectation.py @@ -30,6 +30,7 @@ RendererValueType, ) from great_expectations.render.util import ( + num_to_str, parse_row_condition_string_pandas_engine, substitute_none_for_missing, ) @@ -75,7 +76,7 @@ def register_metric( map_metric = "column_values.match_" + regex_snake_name + "_regex" # Define the class using `type`. This allows us to name it dynamically. - new_column_regex_metric_provider = type( + new_column_regex_metric_provider = type( # noqa: F841 # never used f"(ColumnValuesMatch{regex_camel_name}Regex", (RegexColumnMapMetricProvider,), { @@ -239,7 +240,7 @@ def _prescriptive_renderer( template_str = conditional_template_str + ", then " + template_str params.update(conditional_params) - params_with_json_schema = { + params_with_json_schema = { # noqa: F841 # never used "column": {"schema": {"type": "string"}, "value": params.get("column")}, "mostly": {"schema": {"type": "number"}, "value": params.get("mostly")}, "mostly_pct": { diff --git a/great_expectations/expectations/row_conditions.py b/great_expectations/expectations/row_conditions.py index 10de4786f080..d41b47cef6fc 100644 --- a/great_expectations/expectations/row_conditions.py +++ b/great_expectations/expectations/row_conditions.py @@ -1,5 +1,8 @@ +from __future__ import annotations + import enum from dataclasses import dataclass +from typing import TYPE_CHECKING from pyparsing import ( CaselessLiteral, @@ -27,8 +30,12 @@ except ImportError: sa = None +if TYPE_CHECKING: + import sqlalchemy as sa + from sqlalchemy.sql.expression import ColumnElement + -def _set_notnull(s, l, t) -> None: +def _set_notnull(s, l, t) -> None: # noqa: E741 # ambiguous name `l` t["notnull"] = True @@ -114,7 +121,9 @@ def _parse_great_expectations_condition(row_condition: str): # noinspection PyUnresolvedReferences -def parse_condition_to_spark(row_condition: str) -> "pyspark.sql.Column": +def parse_condition_to_spark( + row_condition: str, +) -> "pyspark.sql.Column": # noqa: F821 # TODO: pyspark typing parsed = _parse_great_expectations_condition(row_condition) column = parsed["column"] if "condition_value" in parsed: @@ -148,7 +157,7 @@ def parse_condition_to_spark(row_condition: str) -> "pyspark.sql.Column": def parse_condition_to_sqlalchemy( row_condition: str, -) -> "sqlalchemy.sql.expression.ColumnElement": +) -> ColumnElement: parsed = _parse_great_expectations_condition(row_condition) column = parsed["column"] if "condition_value" in parsed: diff --git a/great_expectations/expectations/set_based_column_map_expectation.py b/great_expectations/expectations/set_based_column_map_expectation.py index d02dfcbb4b23..d0540786a2ca 100644 --- a/great_expectations/expectations/set_based_column_map_expectation.py +++ b/great_expectations/expectations/set_based_column_map_expectation.py @@ -29,6 +29,7 @@ RendererValueType, ) from great_expectations.render.util import ( + num_to_str, parse_row_condition_string_pandas_engine, substitute_none_for_missing, ) @@ -66,7 +67,7 @@ def register_metric( map_metric = "column_values.match_" + set_snake_name + "_set" # Define the class using `type`. This allows us to name it dynamically. - new_column_set_metric_provider = type( + new_column_set_metric_provider = type( # noqa: F841 # never used f"(ColumnValuesMatch{set_camel_name}Set", (SetColumnMapMetricProvider,), { @@ -243,7 +244,7 @@ def _prescriptive_renderer( template_str = conditional_template_str + ", then " + template_str params.update(conditional_params) - params_with_json_schema = { + params_with_json_schema = { # noqa: F841 # never used "column": {"schema": {"type": "string"}, "value": params.get("column")}, "mostly": {"schema": {"type": "number"}, "value": params.get("mostly")}, "mostly_pct": { diff --git a/setup.cfg b/setup.cfg index b3f5b17a9d71..89672e77c545 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,7 @@ exclude = .git, versioneer*, examples/*, # TODO: remove the items below and fix linting issues - great_expectations/expectations, # 122 warnings + great_expectations/expectations/metrics, # 57 warnings great_expectations/dataset, # 52 warnings tests/checkpoint, # 15 warnings tests/cli, # 34 warnings