From e70a1e9bfca512c07ea78eef171adceb9744cb2b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:49:48 +0545 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#10663) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- dvc/pathspec_math.py | 6 ++---- dvc/repo/experiments/run.py | 2 +- dvc/testing/benchmarks/fixtures.py | 3 +-- pyproject.toml | 4 ++-- tests/func/experiments/test_set_params.py | 2 +- tests/func/plots/test_show.py | 7 ++----- tests/func/test_merge_driver.py | 2 +- tests/func/test_repo_index.py | 12 ++++++------ tests/integration/plots/test_plots.py | 7 ++----- tests/unit/command/test_dataset.py | 2 +- tests/unit/fs/test_dvc_info.py | 6 +++--- tests/unit/test_config.py | 3 +-- tests/unit/test_logger.py | 8 ++------ 14 files changed, 26 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f89ea1ece..ca012f87c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: sort-simple-yaml - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.8.4' + rev: 'v0.9.0' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/dvc/pathspec_math.py b/dvc/pathspec_math.py index 8f252ac586..88fbf9cda7 100644 --- a/dvc/pathspec_math.py +++ b/dvc/pathspec_math.py @@ -27,11 +27,9 @@ def _remove_slash(rule): def _match_all_level(rule): if rule[:-1].find("/") >= 0 and not rule.startswith("**/"): - if rule.startswith("/"): - rule = rule[1:] + rule = rule.removeprefix("/") return False, rule - if rule.startswith("**/"): - rule = rule[3:] + rule = rule.removeprefix("**/") return True, rule diff --git a/dvc/repo/experiments/run.py b/dvc/repo/experiments/run.py index 6de5f16801..3f08e9e835 100644 --- a/dvc/repo/experiments/run.py +++ b/dvc/repo/experiments/run.py @@ -93,7 +93,7 @@ def run( # noqa: C901, PLR0912 for idx, sweep_overrides in enumerate(sweeps): if hydra_sweep and name_prefix is not None: - kwargs["name"] = f"{name_prefix}-{idx+1}" + kwargs["name"] = f"{name_prefix}-{idx + 1}" queue_entry = repo.experiments.queue_one( repo.experiments.celery_queue, targets=targets, diff --git a/dvc/testing/benchmarks/fixtures.py b/dvc/testing/benchmarks/fixtures.py index c6f981f527..5f4be16fc3 100644 --- a/dvc/testing/benchmarks/fixtures.py +++ b/dvc/testing/benchmarks/fixtures.py @@ -138,8 +138,7 @@ def dvc_bin(request, make_dvc_bin): version = Version(parse(dvc_version).base_version) if version not in spec: pytest.skip( - f"Version {dvc_version} " - f"does not satisfy requirement {spec!r}: {reason}" + f"Version {dvc_version} does not satisfy requirement {spec!r}: {reason}" ) return make_dvc_bin diff --git a/pyproject.toml b/pyproject.toml index 01453f8815..680794c8e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -264,14 +264,14 @@ show-fixes = true [tool.ruff.lint] ignore = [ - "N818", "S101", "ISC001", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117", + "N818", "S101", "A005", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117", "TRY003", "TRY300", "PERF203", "PLR2004", "PLW2901", "LOG007", ] select = [ "F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "DTZ", "T10", "EXE", "ISC", "ICN", "LOG", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "SLOT", "SIM", "TID", "TC", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY", - "FLY", "PERF", "FURB", "RUF", "RUF027", "RUF029", "RUF034", "RUF036", + "FLY", "PERF", "FURB", "RUF", "RUF027", "RUF029", "RUF036", ] preview = true explicit-preview-rules = true diff --git a/tests/func/experiments/test_set_params.py b/tests/func/experiments/test_set_params.py index 946508ecc4..a479b2ce59 100644 --- a/tests/func/experiments/test_set_params.py +++ b/tests/func/experiments/test_set_params.py @@ -133,7 +133,7 @@ def test_hydra_sweep_prefix_name(tmp_dir, params_repo, dvc): db_values = ["mysql", "postgresql"] param = "+db=" + ",".join(db_values) dvc.experiments.run(params=[param], queue=True, name=prefix) - expected_names = [f"{prefix}-{i+1}" for i, _ in enumerate(db_values)] + expected_names = [f"{prefix}-{i + 1}" for i, _ in enumerate(db_values)] exp_names = [entry.name for entry in dvc.experiments.celery_queue.iter_queued()] for name, expected in zip(exp_names, expected_names): assert name == expected diff --git a/tests/func/plots/test_show.py b/tests/func/plots/test_show.py index 8cb9327e92..2bacbb4e8b 100644 --- a/tests/func/plots/test_show.py +++ b/tests/func/plots/test_show.py @@ -205,11 +205,8 @@ def _get_plot_defn(rel_dir: str) -> dict: dvclive_metrics_dir.gen( { - "Error.tsv": "step\tError\n" "0\t0.11\n" "1\t0.22\n" "2\t0.44\n", - "Max_Leaf_Nodes.tsv": "step\tMax_Leaf_Nodes\n" - "0\t5\n" - "1\t50\n" - "2\t500\n", + "Error.tsv": "step\tError\n0\t0.11\n1\t0.22\n2\t0.44\n", + "Max_Leaf_Nodes.tsv": "step\tMax_Leaf_Nodes\n0\t5\n1\t50\n2\t500\n", } ) diff --git a/tests/func/test_merge_driver.py b/tests/func/test_merge_driver.py index bc0e1de2f7..9e87eb8ea5 100644 --- a/tests/func/test_merge_driver.py +++ b/tests/func/test_merge_driver.py @@ -132,7 +132,7 @@ def test_merge_different_output_options(tmp_dir, dvc, caplog): ) (tmp_dir / "their").write_text( - "outs:\n" + r"outs:\n" "- md5: f987654321.dir\n" " hash: md5\n" " path: path\n" diff --git a/tests/func/test_repo_index.py b/tests/func/test_repo_index.py index b78cf9779a..ebcbee8538 100644 --- a/tests/func/test_repo_index.py +++ b/tests/func/test_repo_index.py @@ -114,13 +114,13 @@ def assert_index_equal(first, second, strict=True, ordered=True): assert len(first) == len(second), "Index have different no. of stages" assert set(first) == set(second), "Index does not have same stages" if ordered: - assert list(first) == list( - second - ), "Index does not have same sequence of stages" + assert list(first) == list(second), ( + "Index does not have same sequence of stages" + ) if strict: - assert set(map(id, first)) == set( - map(id, second) - ), "Index is not strictly equal" + assert set(map(id, first)) == set(map(id, second)), ( + "Index is not strictly equal" + ) def test_skip_graph_checks(dvc, mocker): diff --git a/tests/integration/plots/test_plots.py b/tests/integration/plots/test_plots.py index 8d39ae92ee..32723f2672 100644 --- a/tests/integration/plots/test_plots.py +++ b/tests/integration/plots/test_plots.py @@ -553,11 +553,8 @@ def test_nested_x_defn_collection(tmp_dir, dvc, scm, capsys): ) dvclive_metrics_dir.gen( { - "Error.tsv": "step\tError\n" "0\t0.11\n" "1\t0.22\n" "2\t0.44\n", - "Max_Leaf_Nodes.tsv": "step\tMax_Leaf_Nodes\n" - "0\t5\n" - "1\t50\n" - "2\t500\n", + "Error.tsv": "step\tError\n0\t0.11\n1\t0.22\n2\t0.44\n", + "Max_Leaf_Nodes.tsv": "step\tMax_Leaf_Nodes\n0\t5\n1\t50\n2\t500\n", } ) (other_logger_dir / "multiple_metrics.json").dump( diff --git a/tests/unit/command/test_dataset.py b/tests/unit/command/test_dataset.py index 290075328c..38240e5761 100644 --- a/tests/unit/command/test_dataset.py +++ b/tests/unit/command/test_dataset.py @@ -106,7 +106,7 @@ def test_add_already_exists(dvc, caplog, mocker): "missing": "Updating mydataset (s3://bucket/path)\n", "unchanged": "Nothing to update\n", "updated": ( - "Updating mydataset (s3://bucket/path)\n" + r"Updating mydataset (s3://bucket/path)\n" "M\tbaz\n" "A\tfoobar\n" "D\tfoo\n" diff --git a/tests/unit/fs/test_dvc_info.py b/tests/unit/fs/test_dvc_info.py index 3edae45d6d..52d651ae1f 100644 --- a/tests/unit/fs/test_dvc_info.py +++ b/tests/unit/fs/test_dvc_info.py @@ -123,6 +123,6 @@ def test_info_on_subrepos(make_tmp_dir, tmp_dir, dvc, scm, dvcfs): for path in ["subrepo", "subrepo/foo", "subrepo/foobar"]: info = dvcfs.info(path) - assert info["repo"].root_dir == str( - subrepo - ), f"repo root didn't match for {path}" + assert info["repo"].root_dir == str(subrepo), ( + f"repo root didn't match for {path}" + ) diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 931da8114b..92ba7810d3 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -130,6 +130,5 @@ def test_feature_section_supports_arbitrary_values(caplog): assert "random_key_1" not in data assert "random_key_2" not in data assert ( - "'feature.random_key_1', 'feature.random_key_2' " - "config options are unsupported" + "'feature.random_key_1', 'feature.random_key_2' config options are unsupported" ) in caplog.text diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py index a812a1c5df..d7bad94894 100644 --- a/tests/unit/test_logger.py +++ b/tests/unit/test_logger.py @@ -104,9 +104,7 @@ def test_exception_under_verbose(self, caplog, dt): logger.exception("") expected = ( - "{red}{datetime}{nc} " - "{red}ERROR{nc}: description\n" - "{stack_trace}".format( + "{red}{datetime}{nc} {red}ERROR{nc}: description\n{stack_trace}".format( stack_trace=stack_trace, **colors, datetime=dt, @@ -144,9 +142,7 @@ def test_tb_only(self, caplog, dt): logger.exception("something", extra={"tb_only": True}) expected = ( - "{red}{datetime}{nc} " - "{red}ERROR{nc}: something\n" - "{stack_trace}".format( + "{red}{datetime}{nc} {red}ERROR{nc}: something\n{stack_trace}".format( stack_trace=stack_trace, **colors, datetime=dt,