Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] ruff 0.2.2 #9538

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
hooks:
- id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.2.2"
hooks:
- id: ruff
files: ^(great_expectations|assets|contrib|scripts|tasks\.py|tests) # TODO: add docs/ etc.
Expand Down
2 changes: 1 addition & 1 deletion contrib/cli/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ cookiecutter==2.1.1 # Project templating
mypy==1.7.1 # Type checker
pydantic>=1.0 # Needed for mypy plugin
pytest>=5.3.5 # Test framework
ruff==0.1.14 # Linting / code style
ruff==0.2.2 # Linting / code style
twine==3.7.1 # Packaging
wheel==0.38.1 # Packaging
4 changes: 2 additions & 2 deletions contrib/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# root linter settings are defined in the file below
extend = "../pyproject.toml"

extend-ignore = [
lint.extend-ignore = [
# https://github.com/charliermarsh/ruff#flake8-type-checking-tch
# This is likely to be a high-touch rule that most contribs don't need to care about.
"TCH001",
Expand All @@ -19,6 +19,6 @@ extend-ignore = [
"NPY002", # these methods are deprecated in numpy 2 but will not be removed
]

[isort]
[lint.isort]
known-first-party = ["great_expectations", "tests"]
known-third-party = ["dataprofiler", "capitalone_dataprofiler_expectations"]
2 changes: 1 addition & 1 deletion great_expectations/dataset/pandas_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def get_column_value_counts(self, column, sort="value", collate=None):
# Having values of multiple types in a object dtype column (e.g., strings and floats)
# raises a TypeError when the sorting method performs comparisons.
# Related to the noqa E721 below: numpy / pandas implements equality, see https://github.com/astral-sh/ruff/issues/9570
if self[column].dtype == object: # noqa: E721
if self[column].dtype == object:
counts.index = counts.index.astype(str)
counts.sort_index(inplace=True)
elif sort == "counts":
Expand Down
2 changes: 1 addition & 1 deletion great_expectations/dataset/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extend = "../../pyproject.toml"

# relaxing linting rules for legacy dataset module
extend-ignore = [
lint.extend-ignore = [
# https://github.com/charliermarsh/ruff#pyflakes-f
"F841", # unused-variable
# https://github.com/charliermarsh/ruff#error-e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _prescriptive_template(
if not params.column_A or not params.column_B:
template_str += "$column has a bogus `expect_column_pair_values_A_to_be_greater_than_B` expectation. "

if not params.mostly or params.mostly.value == 1.0: # noqa: PLR2004
if not params.mostly or params.mostly.value == 1.0:
if not params.or_equal:
template_str += "Values in $column_A must always be greater than those in $column_B."
else:
Expand Down Expand Up @@ -160,7 +160,7 @@ def _prescriptive_renderer(
template_str = "$column has a bogus `expect_column_pair_values_A_to_be_greater_than_B` expectation."
params["row_condition"] = None

if params["mostly"] is None or params["mostly"] == 1.0: # noqa: PLR2004
if params["mostly"] is None or params["mostly"] == 1.0:
if params["or_equal"] in [None, False]:
template_str = "Values in $column_A must always be greater than those in $column_B."
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _prescriptive_template(
if not params.column_A or not params.column_B:
template_str += "Unrecognized kwargs for expect_column_pair_values_to_be_equal: missing column. "

if not params.mostly or params.mostly.value == 1.0: # noqa: PLR2004
if not params.mostly or params.mostly.value == 1.0:
template_str += "Values in $column_A and $column_B must always be equal."
else:
renderer_configuration = cls._add_mostly_pct_param(
Expand Down Expand Up @@ -149,7 +149,7 @@ def _prescriptive_renderer(
template_str = " unrecognized kwargs for expect_column_pair_values_to_be_equal: missing column."
params["row_condition"] = None

if params["mostly"] is None or params["mostly"] == 1.0: # noqa: PLR2004
if params["mostly"] is None or params["mostly"] == 1.0:
template_str = "Values in $column_A and $column_B must always be equal."
else:
params["mostly_pct"] = num_to_str(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _prescriptive_template( # noqa: PLR0912
renderer_configuration=renderer_configuration
)

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -200,7 +200,7 @@ def _prescriptive_renderer(
if (params["min_value"] is None) and (params["max_value"] is None):
template_str = "may have any number of unique values."
else: # noqa: PLR5501
if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _prescriptive_template( # noqa: PLR0912
renderer_configuration=renderer_configuration
)

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -277,7 +277,7 @@ def _prescriptive_renderer(
else:
at_least_str, at_most_str = handle_strict_min_max(params)

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _prescriptive_template(
template_str = "values may have any length."
else:
template_str = "values must be $value characters long"
if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -148,7 +148,7 @@ def _prescriptive_renderer(
template_str = "values may have any length."
else:
template_str = "values must be $value characters long"
if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _prescriptive_template(
else:
template_str += f"values must be {at_least_str} $min_value"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -220,7 +220,7 @@ def _prescriptive_renderer(
at_least_str, at_most_str = handle_strict_min_max(params)

mostly_str = ""
if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _prescriptive_template(

template_str = "values must be parseable by dateutil"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -127,7 +127,7 @@ def _prescriptive_renderer(

template_str = "values must be parseable by dateutil"

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _prescriptive_template(
else:
template_str = "values must be less than or equal to previous values"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -155,7 +155,7 @@ def _prescriptive_renderer(
else:
template_str = "values must be less than or equal to previous values"

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _prescriptive_template(
)
template_str += f"values must belong to this set: {value_set_str}"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -214,7 +214,7 @@ def _prescriptive_renderer(

template_str = f"values must belong to this set: {values_string}"

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _prescriptive_template(
renderer_configuration=renderer_configuration,
)

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -213,7 +213,7 @@ def _prescriptive_renderer(
[f"$v__{i!s}" for i, v in enumerate(params["type_list"])]
)

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _prescriptive_template(
else:
template_str = "values must be greater than or equal to previous values"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -155,7 +155,7 @@ def _prescriptive_renderer(
else:
template_str = "values must be greater than or equal to previous values"

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _prescriptive_template(

template_str = "values must be parseable as JSON"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -135,7 +135,7 @@ def _prescriptive_renderer(

template_str = "values must be parseable as JSON"

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _prescriptive_template(

params = renderer_configuration.params

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -144,7 +144,7 @@ def _prescriptive_renderer(
["column", "mostly", "row_condition", "condition_parser"],
)

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _prescriptive_template(

params = renderer_configuration.params

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -209,7 +209,7 @@ def _prescriptive_renderer(
["column", "type_", "mostly", "row_condition", "condition_parser"],
)

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _prescriptive_template(
else:
template_str = "values must be unique"

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -143,7 +143,7 @@ def _prescriptive_renderer( # type: ignore[override] # TODO: Fix this type igno
else:
template_str = "values must be unique"

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _prescriptive_template(
value=formatted_json,
)

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -164,7 +164,7 @@ def _prescriptive_renderer(
params[
"formatted_json"
] = f"<pre>{json.dumps(params.get('json_schema'), indent=4)}</pre>"
if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _prescriptive_renderer(

template_str = "Values must match the following like patterns: " + values_string

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _prescriptive_template(
)
else:
template_str = "values must match this regular expression: $regex"
if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -185,7 +185,7 @@ def _prescriptive_renderer(
)
else:
template_str = "values must match this regular expression: $regex"
if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _prescriptive_template(
+ values_string
)

if params.mostly and params.mostly.value < 1.0: # noqa: PLR2004
if params.mostly and params.mostly.value < 1.0:
renderer_configuration = cls._add_mostly_pct_param(
renderer_configuration=renderer_configuration
)
Expand Down Expand Up @@ -211,7 +211,7 @@ def _prescriptive_renderer(
+ values_string
)

if params["mostly"] is not None and params["mostly"] < 1.0: # noqa: PLR2004
if params["mostly"] is not None and params["mostly"] < 1.0:
params["mostly_pct"] = num_to_str(
params["mostly"] * 100, no_scientific=True
)
Expand Down