From 48b56c83dc896af1c0172846cdf368da05d89eea Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Mar 2023 13:05:31 +0000 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#9168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.254 → v0.0.257](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.254...v0.0.257) - [github.com/codespell-project/codespell: v2.2.2 → v2.2.4](https://github.com/codespell-project/codespell/compare/v2.2.2...v2.2.4) * pre-commit: fix ruff errors * pre-commit: fix flake8 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: David de la Iglesia Castro --- .pre-commit-config.yaml | 4 ++-- dvc/commands/check_ignore.py | 2 +- dvc/commands/plots.py | 2 +- dvc/config_schema.py | 4 ++-- dvc/dvcfile.py | 2 +- dvc/info.py | 2 +- dvc/render/converter/vega.py | 1 - tests/func/experiments/test_experiments.py | 2 +- tests/func/experiments/test_init.py | 10 +++++----- tests/func/test_get.py | 2 +- tests/func/test_init.py | 2 +- tests/func/test_lock.py | 2 +- tests/unit/test_logger.py | 4 ++-- tests/unit/test_progress.py | 14 +++++++------- tests/unit/utils/test_humanize.py | 4 ++-- 15 files changed, 28 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d568d3229..2fdb8600f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,11 +43,11 @@ repos: hooks: - id: isort - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.254' + rev: 'v0.0.257' hooks: - id: ruff - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell additional_dependencies: ["tomli"] diff --git a/dvc/commands/check_ignore.py b/dvc/commands/check_ignore.py index 69a33291d..b1a996474 100644 --- a/dvc/commands/check_ignore.py +++ b/dvc/commands/check_ignore.py @@ -39,7 +39,7 @@ class CmdCheckIgnore(CmdBase): target = input() except (KeyboardInterrupt, EOFError): break - if target == "": + if not target: break if not self._check_one_file(target): ret = 0 diff --git a/dvc/commands/plots.py b/dvc/commands/plots.py index d368e67ce..b99975948 100644 --- a/dvc/commands/plots.py +++ b/dvc/commands/plots.py @@ -84,7 +84,7 @@ class CmdPlots(CmdBase): if html_template_path and not os.path.isabs(html_template_path): assert self.repo.dvc_dir html_template_path = os.path.join(self.repo.dvc_dir, html_template_path) - return html_template_path # noqa: RET504 + return html_template_path def run(self) -> int: # noqa: C901, PLR0911, PLR0912 from pathlib import Path diff --git a/dvc/config_schema.py b/dvc/config_schema.py index d49202141..65feb931d 100644 --- a/dvc/config_schema.py +++ b/dvc/config_schema.py @@ -62,9 +62,9 @@ def ByUrl(mapping): # noqa: N802 parsed = urlparse(data["url"]) # Windows absolute paths should really have scheme == "" (local) - if os.name == "nt" and len(parsed.scheme) == 1 and parsed.netloc == "": + if os.name == "nt" and len(parsed.scheme) == 1 and not parsed.netloc: return schemas[""](data) - if parsed.netloc == "": + if not parsed.netloc: return schemas[""](data) if parsed.scheme not in schemas: raise Invalid(f"Unsupported URL type {parsed.scheme}://") diff --git a/dvc/dvcfile.py b/dvc/dvcfile.py index a44bc095b..bef337f5d 100644 --- a/dvc/dvcfile.py +++ b/dvc/dvcfile.py @@ -366,7 +366,7 @@ def get_lockfile_schema(d): def migrate_lock_v1_to_v2(d, version_info): - stages = {k: v for k, v in d.items()} + stages = dict(d) for key in stages: d.pop(key) diff --git a/dvc/info.py b/dvc/info.py index 733a6e22e..9db32f72f 100644 --- a/dvc/info.py +++ b/dvc/info.py @@ -139,7 +139,7 @@ def _get_supported_remotes(): def get_fs_type(path): partition = {} for part in psutil.disk_partitions(all=True): - if part.fstype != "": + if part.fstype: try: mountpoint = pathlib.Path(part.mountpoint).resolve() partition[mountpoint] = part.fstype + " on " + part.device diff --git a/dvc/render/converter/vega.py b/dvc/render/converter/vega.py index 6cf62c4a6..9fb413700 100644 --- a/dvc/render/converter/vega.py +++ b/dvc/render/converter/vega.py @@ -56,7 +56,6 @@ def _verify_field(file2datapoints: Dict[str, List], filename: str, field: str): datapoint = first(file2datapoints[filename]) if field not in datapoint: raise FieldNotFoundError(field, datapoint.keys()) - return def _get_xs(properties: Dict, file2datapoints: Dict[str, List[Dict]]): diff --git a/tests/func/experiments/test_experiments.py b/tests/func/experiments/test_experiments.py index 4c786aeab..a96f0c332 100644 --- a/tests/func/experiments/test_experiments.py +++ b/tests/func/experiments/test_experiments.py @@ -620,7 +620,7 @@ def test_run_env(tmp_dir, dvc, scm, mocker): ) dvc.experiments.run() assert (tmp_dir / "DVC_EXP_BASELINE_REV").read_text().strip() == baseline - assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() != "" + assert (tmp_dir / "DVC_EXP_NAME").read_text().strip() assert (tmp_dir / "STUDIO_REPO_URL").read_text().strip() == "REPO_URL" dvc.experiments.run(name="foo") diff --git a/tests/func/experiments/test_init.py b/tests/func/experiments/test_init.py index e41e20373..95a2d98e8 100644 --- a/tests/func/experiments/test_init.py +++ b/tests/func/experiments/test_init.py @@ -166,7 +166,7 @@ def test_when_params_is_omitted_in_interactive_mode(tmp_dir, scm, dvc): } } assert not (tmp_dir / "dvc.lock").exists() - assert (tmp_dir / "script.py").read_text() == "" + assert not (tmp_dir / "script.py").read_text() assert (tmp_dir / "data").is_dir() scm._reset() assert scm.is_tracked("dvc.yaml") @@ -194,7 +194,7 @@ def test_init_interactive_params_validation(tmp_dir, dvc, capsys): } } } - assert (tmp_dir / "script.py").read_text() == "" + assert not (tmp_dir / "script.py").read_text() assert (tmp_dir / "data").is_dir() out, err = capsys.readouterr() @@ -226,7 +226,7 @@ def test_init_with_no_defaults_interactive(tmp_dir, dvc): } } } - assert (tmp_dir / "script.py").read_text() == "" + assert not (tmp_dir / "script.py").read_text() assert (tmp_dir / "data").is_dir() @@ -275,7 +275,7 @@ def test_init_default(tmp_dir, scm, dvc, interactive, overrides, inp, capsys): } } assert not (tmp_dir / "dvc.lock").exists() - assert (tmp_dir / "script.py").read_text() == "" + assert not (tmp_dir / "script.py").read_text() assert (tmp_dir / "data").is_dir() scm._reset() assert scm.is_tracked("dvc.yaml") @@ -345,7 +345,7 @@ def test_init_interactive_live(tmp_dir, scm, dvc, interactive, overrides, inp, c } } assert not (tmp_dir / "dvc.lock").exists() - assert (tmp_dir / "script.py").read_text() == "" + assert not (tmp_dir / "script.py").read_text() assert (tmp_dir / "data").is_dir() scm._reset() assert scm.is_tracked("dvc.yaml") diff --git a/tests/func/test_get.py b/tests/func/test_get.py index cce2f0e98..f26053aeb 100644 --- a/tests/func/test_get.py +++ b/tests/func/test_get.py @@ -217,7 +217,7 @@ def test_get_url_positive(tmp_dir, erepo_dir, caplog, local_cloud): caplog.clear() with caplog.at_level(logging.ERROR, logger="dvc"): assert main(["get", os.fspath(erepo_dir), "foo", "--show-url"]) == 0 - assert caplog.text == "" + assert not caplog.text def test_get_url_not_existing(tmp_dir, erepo_dir, caplog): diff --git a/tests/func/test_init.py b/tests/func/test_init.py index e53b7d3a8..7944d5b1a 100644 --- a/tests/func/test_init.py +++ b/tests/func/test_init.py @@ -65,7 +65,7 @@ def test_init_quiet_should_not_display_welcome_screen(tmp_dir, scm, caplog): ret = main(["init", "--quiet"]) assert ret == 0 - assert caplog.text == "" + assert not caplog.text def test_allow_init_dvc_subdir(tmp_dir, scm, monkeypatch): diff --git a/tests/func/test_lock.py b/tests/func/test_lock.py index 3c615fdbe..ee170c8e2 100644 --- a/tests/func/test_lock.py +++ b/tests/func/test_lock.py @@ -27,7 +27,7 @@ def test_unlock_lock_failed(tmp_dir, dvc, request, mocker): # repro of a stage) in with. We should see LockError exception here. with lock: lock.unlock() - lock_ext.lock() # imitate an exernal process had time to lock it + lock_ext.lock() # imitate an external process had time to lock it request.addfinalizer(lock_ext.unlock) with pytest.raises(LockError): lock.lock() diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py index 5e14c1922..1673c6fcf 100644 --- a/tests/unit/test_logger.py +++ b/tests/unit/test_logger.py @@ -200,13 +200,13 @@ class TestColorFormatter: formatter.format(debug_record) captured = capsys.readouterr() - assert captured.out == "" + assert not captured.out # when the message is actually visible with caplog.at_level(logging.INFO, logger="dvc"): logger.info("some info") captured = capsys.readouterr() - assert captured.out == "" + assert not captured.out def test_handlers(): diff --git a/tests/unit/test_progress.py b/tests/unit/test_progress.py index 075315648..903636097 100644 --- a/tests/unit/test_progress.py +++ b/tests/unit/test_progress.py @@ -9,8 +9,8 @@ def test_quiet_logging(caplog, capsys): for _ in Tqdm(range(10)): pass out_err = capsys.readouterr() - assert out_err.out == "" - assert out_err.err == "" + assert not out_err.out + assert not out_err.err def test_quiet_logging_disable_false(caplog, capsys, mocker): @@ -20,8 +20,8 @@ def test_quiet_logging_disable_false(caplog, capsys, mocker): for _ in Tqdm(range(10), disable=False): pass out_err = capsys.readouterr() - assert out_err.out == "" - assert out_err.err == "" + assert not out_err.out + assert not out_err.err def test_quiet_notty(caplog, capsys): @@ -29,11 +29,11 @@ def test_quiet_notty(caplog, capsys): for _ in Tqdm(range(10)): pass out_err = capsys.readouterr() - assert out_err.out == "" + assert not out_err.out if env2bool("DVC_IGNORE_ISATTY"): assert "0/10" in out_err.err else: - assert out_err.err == "" + assert not out_err.err def test_default(caplog, capsys, mocker): @@ -44,5 +44,5 @@ def test_default(caplog, capsys, mocker): pass out_err = capsys.readouterr() - assert out_err.out == "" + assert not out_err.out assert "0/10" in out_err.err diff --git a/tests/unit/utils/test_humanize.py b/tests/unit/utils/test_humanize.py index 67674018a..494370737 100644 --- a/tests/unit/utils/test_humanize.py +++ b/tests/unit/utils/test_humanize.py @@ -34,8 +34,8 @@ def test_get_summary(): del stats["modified"] assert get_summary(stats.items()) == "3 files added" - assert get_summary([]) == "" - assert get_summary([("x", 0), ("y", [])]) == "" + assert not get_summary([]) + assert not get_summary([("x", 0), ("y", [])]) assert get_summary([("x", 1), ("y", [])]) == "1 file x"