Skip to content

Commit 356dfa0

Browse files
[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 (सौगात) <suagatchhetri@outlook.com>
1 parent 0f4e8a2 commit 356dfa0

File tree

14 files changed

+27
-24
lines changed

14 files changed

+27
-24
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ repos:
2222
- id: sort-simple-yaml
2323
- id: trailing-whitespace
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: 'v0.14.13'
25+
rev: 'v0.15.8'
2626
hooks:
2727
- id: ruff-check
2828
args: [--fix, --exit-non-zero-on-fix]
2929
- id: ruff-format
3030
- repo: https://github.com/codespell-project/codespell
31-
rev: v2.4.1
31+
rev: v2.4.2
3232
hooks:
3333
- id: codespell
3434
additional_dependencies: ["tomli"]

dvc/__pyinstaller/hook-celery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
_EXCLUDES = ("celery.bin", "celery.contrib")
99
hiddenimports = collect_submodules(
1010
"celery",
11-
filter=lambda name: not any(
12-
is_module_or_submodule(name, module) for module in _EXCLUDES
11+
filter=lambda name: (
12+
not any(is_module_or_submodule(name, module) for module in _EXCLUDES)
1313
),
1414
)

dvc/repo/experiments/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def _log_reproduced(self, revs: Iterable[str], tmp_dir: bool = False):
188188
rev_names = self.get_exact_name(revs)
189189
for rev in revs:
190190
name = rev_names[rev]
191-
names.append(name if name else rev[:7])
191+
names.append(name or rev[:7])
192192
ui.write("\nRan experiment(s): {}".format(", ".join(names)))
193193
if tmp_dir:
194194
ui.write(

dvc/repo/experiments/collect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def collect(
328328
name=baseline_names.get(baseline_rev),
329329
data=baseline_data.data,
330330
error=baseline_data.error,
331-
experiments=experiments if experiments else None,
331+
experiments=experiments or None,
332332
)
333333
)
334334
return result

dvc/repo/experiments/executor/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def commit(
757757
logger.debug("Commit to current experiment branch '%s'", branch)
758758
else:
759759
baseline_rev = scm.get_ref(EXEC_BASELINE)
760-
name = exp_name if exp_name else f"exp-{exp_hash[:5]}"
760+
name = exp_name or f"exp-{exp_hash[:5]}"
761761
ref_info = ExpRefInfo(baseline_rev, name)
762762
branch = str(ref_info)
763763
old_ref = None

dvc/repo/experiments/refs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ExpRefInfo:
3434

3535
def __init__(self, baseline_sha: str, name: Optional[str] = None):
3636
self.baseline_sha = baseline_sha
37-
self.name: str = name if name else ""
37+
self.name: str = name or ""
3838

3939
def __str__(self):
4040
return "/".join(self.parts)

dvc/repo/experiments/stash.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def format_message(
6767
branch: Optional[str] = None,
6868
) -> str:
6969
msg = cls.MESSAGE_FORMAT.format(
70-
rev=rev, baseline_rev=baseline_rev, name=name if name else ""
70+
rev=rev, baseline_rev=baseline_rev, name=name or ""
7171
)
7272
branch_msg = f":{branch}" if branch else ""
7373
return f"{msg}{branch_msg}"
@@ -124,9 +124,7 @@ def stash_revs(self) -> dict[str, ApplyStashEntry]:
124124

125125
@classmethod
126126
def format_message(cls, head_rev: str, rev: str, name: Optional[str] = None) -> str:
127-
return cls.MESSAGE_FORMAT.format(
128-
head_rev=head_rev, rev=rev, name=name if name else ""
129-
)
127+
return cls.MESSAGE_FORMAT.format(head_rev=head_rev, rev=rev, name=name or "")
130128

131129
@contextmanager
132130
def preserve_workspace(

dvc/repo/experiments/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def exp_commits(
200200
) -> Iterable[str]:
201201
"""Iterate over all experiment commits."""
202202
shas: set[str] = set()
203-
refs = ref_infos if ref_infos else exp_refs(scm)
203+
refs = ref_infos or exp_refs(scm)
204204
for ref_info in refs:
205205
shas.update(scm.branch_revs(str(ref_info), ref_info.baseline_sha))
206206
yield from shas

dvc/repo/scm_context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from dvc.utils.collections import ensure_list
1111

1212
if TYPE_CHECKING:
13+
from typing_extensions import Self
14+
1315
from dvc.repo import Repo
1416
from dvc.scm import Base
1517

@@ -96,7 +98,7 @@ def ignore_remove(self, path: str) -> None:
9698
@contextmanager
9799
def __call__(
98100
self, autostage: Optional[bool] = None, quiet: Optional[bool] = None
99-
) -> Iterator["SCMContext"]:
101+
) -> Iterator["Self"]:
100102
try:
101103
yield self
102104
except Exception:
@@ -131,9 +133,10 @@ def __call__(
131133

132134
self.files_to_track = set()
133135

134-
def __enter__(self) -> "SCMContext":
136+
def __enter__(self) -> "Self":
135137
self._cm = self()
136-
return self._cm.__enter__()
138+
self._cm.__enter__()
139+
return self
137140

138141
def __exit__(self, *exc_args) -> None:
139142
assert self._cm

dvc/testing/path_info.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pathlib
33
import posixpath
44
import sys
5-
from typing import Callable, ClassVar
5+
from typing import Callable, ClassVar, Union
66
from urllib.parse import urlparse
77

88
from dvc.utils import relpath
@@ -79,15 +79,17 @@ def isin(self, other):
7979
and self._cparts[:n] == other._cparts # type: ignore[attr-defined]
8080
)
8181

82-
def relative_to(self, other, *args, **kwargs):
82+
def relative_to(
83+
self, *other: Union[str, "os.PathLike[str]"], **kwargs
84+
) -> "PathInfo":
8385
# pathlib relative_to raises exception when one path is not a direct
8486
# descendant of the other when os.path.relpath would return abspath.
8587
# For DVC PathInfo we only need the relpath behavior.
8688
# See: https://bugs.python.org/issue40358
8789
try:
88-
path = super().relative_to(other, *args, **kwargs)
90+
path = super().relative_to(*other, **kwargs)
8991
except ValueError:
90-
path = relpath(self, other)
92+
path = relpath(self, other[0])
9193
return self.__class__(path)
9294

9395

0 commit comments

Comments
 (0)