mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
[pre-commit.ci] pre-commit autoupdate (#10981)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
This commit is contained in:
co-authored by
Saugat Pachhai
parent
0f4e8a23c8
commit
356dfa0327
@@ -22,13 +22,13 @@ repos:
|
||||
- id: sort-simple-yaml
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.14.13'
|
||||
rev: 'v0.15.8'
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.4.1
|
||||
rev: v2.4.2
|
||||
hooks:
|
||||
- id: codespell
|
||||
additional_dependencies: ["tomli"]
|
||||
|
||||
@@ -8,7 +8,7 @@ from PyInstaller.utils.hooks import collect_submodules, is_module_or_submodule
|
||||
_EXCLUDES = ("celery.bin", "celery.contrib")
|
||||
hiddenimports = collect_submodules(
|
||||
"celery",
|
||||
filter=lambda name: not any(
|
||||
is_module_or_submodule(name, module) for module in _EXCLUDES
|
||||
filter=lambda name: (
|
||||
not any(is_module_or_submodule(name, module) for module in _EXCLUDES)
|
||||
),
|
||||
)
|
||||
|
||||
@@ -188,7 +188,7 @@ class Experiments:
|
||||
rev_names = self.get_exact_name(revs)
|
||||
for rev in revs:
|
||||
name = rev_names[rev]
|
||||
names.append(name if name else rev[:7])
|
||||
names.append(name or rev[:7])
|
||||
ui.write("\nRan experiment(s): {}".format(", ".join(names)))
|
||||
if tmp_dir:
|
||||
ui.write(
|
||||
|
||||
@@ -328,7 +328,7 @@ def collect(
|
||||
name=baseline_names.get(baseline_rev),
|
||||
data=baseline_data.data,
|
||||
error=baseline_data.error,
|
||||
experiments=experiments if experiments else None,
|
||||
experiments=experiments or None,
|
||||
)
|
||||
)
|
||||
return result
|
||||
|
||||
@@ -757,7 +757,7 @@ class BaseExecutor(ABC):
|
||||
logger.debug("Commit to current experiment branch '%s'", branch)
|
||||
else:
|
||||
baseline_rev = scm.get_ref(EXEC_BASELINE)
|
||||
name = exp_name if exp_name else f"exp-{exp_hash[:5]}"
|
||||
name = exp_name or f"exp-{exp_hash[:5]}"
|
||||
ref_info = ExpRefInfo(baseline_rev, name)
|
||||
branch = str(ref_info)
|
||||
old_ref = None
|
||||
|
||||
@@ -34,7 +34,7 @@ class ExpRefInfo:
|
||||
|
||||
def __init__(self, baseline_sha: str, name: Optional[str] = None):
|
||||
self.baseline_sha = baseline_sha
|
||||
self.name: str = name if name else ""
|
||||
self.name: str = name or ""
|
||||
|
||||
def __str__(self):
|
||||
return "/".join(self.parts)
|
||||
|
||||
@@ -67,7 +67,7 @@ class ExpStash(Stash):
|
||||
branch: Optional[str] = None,
|
||||
) -> str:
|
||||
msg = cls.MESSAGE_FORMAT.format(
|
||||
rev=rev, baseline_rev=baseline_rev, name=name if name else ""
|
||||
rev=rev, baseline_rev=baseline_rev, name=name or ""
|
||||
)
|
||||
branch_msg = f":{branch}" if branch else ""
|
||||
return f"{msg}{branch_msg}"
|
||||
@@ -124,9 +124,7 @@ class ApplyStash(Stash):
|
||||
|
||||
@classmethod
|
||||
def format_message(cls, head_rev: str, rev: str, name: Optional[str] = None) -> str:
|
||||
return cls.MESSAGE_FORMAT.format(
|
||||
head_rev=head_rev, rev=rev, name=name if name else ""
|
||||
)
|
||||
return cls.MESSAGE_FORMAT.format(head_rev=head_rev, rev=rev, name=name or "")
|
||||
|
||||
@contextmanager
|
||||
def preserve_workspace(
|
||||
|
||||
@@ -200,7 +200,7 @@ def exp_commits(
|
||||
) -> Iterable[str]:
|
||||
"""Iterate over all experiment commits."""
|
||||
shas: set[str] = set()
|
||||
refs = ref_infos if ref_infos else exp_refs(scm)
|
||||
refs = ref_infos or exp_refs(scm)
|
||||
for ref_info in refs:
|
||||
shas.update(scm.branch_revs(str(ref_info), ref_info.baseline_sha))
|
||||
yield from shas
|
||||
|
||||
@@ -10,6 +10,8 @@ from dvc.utils import relpath
|
||||
from dvc.utils.collections import ensure_list
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Self
|
||||
|
||||
from dvc.repo import Repo
|
||||
from dvc.scm import Base
|
||||
|
||||
@@ -96,7 +98,7 @@ class SCMContext:
|
||||
@contextmanager
|
||||
def __call__(
|
||||
self, autostage: Optional[bool] = None, quiet: Optional[bool] = None
|
||||
) -> Iterator["SCMContext"]:
|
||||
) -> Iterator["Self"]:
|
||||
try:
|
||||
yield self
|
||||
except Exception:
|
||||
@@ -131,9 +133,10 @@ class SCMContext:
|
||||
|
||||
self.files_to_track = set()
|
||||
|
||||
def __enter__(self) -> "SCMContext":
|
||||
def __enter__(self) -> "Self":
|
||||
self._cm = self()
|
||||
return self._cm.__enter__()
|
||||
self._cm.__enter__()
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc_args) -> None:
|
||||
assert self._cm
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import pathlib
|
||||
import posixpath
|
||||
import sys
|
||||
from typing import Callable, ClassVar
|
||||
from typing import Callable, ClassVar, Union
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from dvc.utils import relpath
|
||||
@@ -79,15 +79,17 @@ class PathInfo(pathlib.PurePath, _BasePath):
|
||||
and self._cparts[:n] == other._cparts # type: ignore[attr-defined]
|
||||
)
|
||||
|
||||
def relative_to(self, other, *args, **kwargs):
|
||||
def relative_to(
|
||||
self, *other: Union[str, "os.PathLike[str]"], **kwargs
|
||||
) -> "PathInfo":
|
||||
# pathlib relative_to raises exception when one path is not a direct
|
||||
# descendant of the other when os.path.relpath would return abspath.
|
||||
# For DVC PathInfo we only need the relpath behavior.
|
||||
# See: https://bugs.python.org/issue40358
|
||||
try:
|
||||
path = super().relative_to(other, *args, **kwargs)
|
||||
path = super().relative_to(*other, **kwargs)
|
||||
except ValueError:
|
||||
path = relpath(self, other)
|
||||
path = relpath(self, other[0])
|
||||
return self.__class__(path)
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ def test_new_simple(tmp_dir, scm, dvc, exp_stage, mocker, name, workspace):
|
||||
if workspace:
|
||||
assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 2"
|
||||
|
||||
exp_name = name if name else ref_info.name
|
||||
exp_name = name or ref_info.name
|
||||
assert dvc.experiments.get_exact_name([exp])[exp] == exp_name
|
||||
assert resolve_rev(scm, exp_name) == exp
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_exp_save(tmp_dir, dvc, scm, name):
|
||||
assert ref_info
|
||||
assert ref_info.baseline_sha == baseline
|
||||
|
||||
exp_name = name if name else ref_info.name
|
||||
exp_name = name or ref_info.name
|
||||
assert dvc.experiments.get_exact_name([exp])[exp] == exp_name
|
||||
assert resolve_rev(scm, exp_name) == exp
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ def test_diff_show_markdown_and_hash(mocker, show_hash, dvc):
|
||||
cmd = args.func(args)
|
||||
|
||||
diff = {}
|
||||
show_hash = show_hash if show_hash else False
|
||||
show_hash = show_hash or False
|
||||
mock_show_markdown = mocker.patch("dvc.commands.diff._show_markdown")
|
||||
mocker.patch("dvc.repo.Repo.diff", return_value=diff.copy())
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ def test_help(caplog, capsys, command_tuples):
|
||||
out, err = capsys.readouterr()
|
||||
|
||||
# validate metavars are all in lowercase
|
||||
usage = "\n".join(takewhile(lambda o: bool(o), out.splitlines()))
|
||||
usage = "\n".join(takewhile(bool, out.splitlines()))
|
||||
|
||||
message = (
|
||||
"metavars not lowercased, you are likely missing formatter_class=XXX "
|
||||
|
||||
Reference in New Issue
Block a user