diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 938530113..d568d3229 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: hooks: - id: isort - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.247' + rev: 'v0.0.254' hooks: - id: ruff - repo: https://github.com/codespell-project/codespell diff --git a/dvc/dvcfile.py b/dvc/dvcfile.py index 9f7dc42d5..a44bc095b 100644 --- a/dvc/dvcfile.py +++ b/dvc/dvcfile.py @@ -409,11 +409,10 @@ class Lockfile(FileMixin): if version == LOCKFILE_VERSION.V1: logger.info("Migrating lock file '%s' from v1 to v2", self.relpath) migrate_lock_v1_to_v2(data, self.latest_version_info) - else: - if not data: - data.update(self.latest_version_info) - # order is important, meta should always be at the top - logger.info("Generating lock file '%s'", self.relpath) + elif not data: + data.update(self.latest_version_info) + # order is important, meta should always be at the top + logger.info("Generating lock file '%s'", self.relpath) data["stages"] = data.get("stages", {}) modified = data["stages"].get(stage.name, {}) != stage_data.get( diff --git a/dvc/parsing/interpolate.py b/dvc/parsing/interpolate.py index 413c10cbb..5fd0d58c6 100644 --- a/dvc/parsing/interpolate.py +++ b/dvc/parsing/interpolate.py @@ -102,9 +102,8 @@ def _(obj: dict): # noqa: C901 if isinstance(v, bool): if v: result += f"--{k} " - else: - if config.get("bool", "store_true") == "boolean_optional": - result += f"--no-{k} " + elif config.get("bool", "store_true") == "boolean_optional": + result += f"--no-{k} " elif isinstance(v, str): result += f"--{k} {escape_str(v)} " diff --git a/dvc/repo/experiments/init.py b/dvc/repo/experiments/init.py index 20e7b282f..d3f0b8ee4 100644 --- a/dvc/repo/experiments/init.py +++ b/dvc/repo/experiments/init.py @@ -218,13 +218,12 @@ def init( provided=overrides, stream=stream, ) + elif "live" in overrides: + # suppress `metrics`/`plots` if live is selected. + defaults.pop("metrics", None) + defaults.pop("plots", None) else: - if "live" in overrides: - # suppress `metrics`/`plots` if live is selected. - defaults.pop("metrics", None) - defaults.pop("plots", None) - else: - defaults.pop("live", None) # suppress live otherwise + defaults.pop("live", None) # suppress live otherwise context: Dict[str, str] = {**defaults, **overrides} assert "cmd" in context diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py index 7cde987b8..e374add13 100644 --- a/dvc/repo/experiments/show.py +++ b/dvc/repo/experiments/show.py @@ -412,10 +412,9 @@ def move_properties_to_head(result: Dict[str, Dict[str, Dict[str, Any]]]): if rev_result["status"] == ExpStatus.Running.name: head["status"] = ExpStatus.Running.name rev_result["status"] = ExpStatus.Success.name - else: - if rev_result["checkpoint_tip"] == rev: - head = rev_result - checkpoint = True + elif rev_result["checkpoint_tip"] == rev: + head = rev_result + checkpoint = True def show( # noqa: PLR0913 diff --git a/dvc/repo/experiments/utils.py b/dvc/repo/experiments/utils.py index 9f3902190..d6b5c22fd 100644 --- a/dvc/repo/experiments/utils.py +++ b/dvc/repo/experiments/utils.py @@ -154,12 +154,11 @@ def push_refspec( for ref in scm.iter_refs(base=src): refname = ref.split("/")[-1] refspecs.append(f"{ref}:{dest}{refname}") + elif dest.endswith("/"): + refname = src.split("/")[-1] + refspecs.append(f"{src}:{dest}/{refname}") else: - if dest.endswith("/"): - refname = src.split("/")[-1] - refspecs.append(f"{src}:{dest}/{refname}") - else: - refspecs.append(f"{src}:{dest}") + refspecs.append(f"{src}:{dest}") try: results = scm.push_refspecs( diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index b5536a58e..cfcb87358 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -440,12 +440,9 @@ def _resolve_definitions( result, unpacked, ) - else: - if _matches(targets, config_path, plot_id): - adjusted_props = _adjust_sources(fs, plot_props, config_dir) - dpath.util.merge( - result, {"data": {plot_id: {**adjusted_props, **props}}} - ) + elif _matches(targets, config_path, plot_id): + adjusted_props = _adjust_sources(fs, plot_props, config_dir) + dpath.util.merge(result, {"data": {plot_id: {**adjusted_props, **props}}}) return result diff --git a/pyproject.toml b/pyproject.toml index 2a5c0d771..f14a6e737 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -230,7 +230,7 @@ ignored-argument-names = "_.*|args|kwargs" [tool.ruff] # external flake8 codes that should be preserved external = ["B301", "C901", "E302", "W601"] -ignore = ["N818", "S101", "PT004", "PT007", "PT019", "SIM105", "SIM108", "SIM110", "SIM111", "SIM117", "TRY003", "TRY200", "TRY300", "TRY301", "PLR2004", "RUF005"] +ignore = ["N818", "S101", "PT004", "PT007", "PT019", "SIM105", "SIM108", "SIM110", "SIM117", "TRY003", "TRY200", "TRY300", "TRY301", "PLR2004", "PLW2901", "RUF005"] select = ["F", "E", "W", "C90", "N", "UP", "YTT", "S", "BLE", "B", "A", "C4", "T10", "ISC", "ICN", "G", "INP", "PIE", "T20", "PT", "Q", "RET501", "RET504", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY", "RUF"] show-source = true target-version = "py38"