mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-12 15:28:21 +01:00
[pre-commit.ci] pre-commit autoupdate (#10350)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix ruff errors --------- 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
7df58ce404
commit
49709a4810
@@ -22,7 +22,7 @@ repos:
|
||||
- id: sort-simple-yaml
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.2.2'
|
||||
rev: 'v0.3.2'
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
||||
@@ -3,6 +3,7 @@ DVC
|
||||
----
|
||||
Make your data science projects reproducible and shareable.
|
||||
"""
|
||||
|
||||
import dvc.logger
|
||||
from dvc.build import PKG # noqa: F401
|
||||
from dvc.version import __version__, version_tuple # noqa: F401
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Main entry point for DVC command line tool."""
|
||||
|
||||
import sys
|
||||
|
||||
from dvc.cli import main
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Main parser for the dvc cli."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from functools import lru_cache
|
||||
|
||||
+2
-4
@@ -88,12 +88,10 @@ class TabularData(MutableSequence[Sequence["CellT"]]):
|
||||
return list(it)
|
||||
|
||||
@overload
|
||||
def __setitem__(self, item: int, value: Sequence["CellT"]) -> None:
|
||||
...
|
||||
def __setitem__(self, item: int, value: Sequence["CellT"]) -> None: ...
|
||||
|
||||
@overload
|
||||
def __setitem__(self, item: slice, value: Iterable[Sequence["CellT"]]) -> None:
|
||||
...
|
||||
def __setitem__(self, item: slice, value: Iterable[Sequence["CellT"]]) -> None: ...
|
||||
|
||||
def __setitem__(self, item, value) -> None:
|
||||
it = value
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""DVC config objects."""
|
||||
|
||||
import os
|
||||
import re
|
||||
from contextlib import contextmanager
|
||||
|
||||
@@ -22,9 +22,12 @@ def download_progress(to: "Output") -> Iterator[Callable[[int], Any]]:
|
||||
from dvc.ui import ui
|
||||
from dvc.ui._rich_progress import DbDownloadProgress
|
||||
|
||||
with log_durations(logger.debug, f"Saving to {to}"), DbDownloadProgress(
|
||||
console=ui.error_console,
|
||||
) as progress:
|
||||
with (
|
||||
log_durations(logger.debug, f"Saving to {to}"),
|
||||
DbDownloadProgress(
|
||||
console=ui.error_console,
|
||||
) as progress,
|
||||
):
|
||||
task = progress.add_task("Saving", total=None, output=to)
|
||||
yield lambda n: progress.advance(task, advance=n)
|
||||
progress.update(task, description="Saved", total=0)
|
||||
|
||||
+3
-4
@@ -68,10 +68,9 @@ def is_git_ignored(repo, path):
|
||||
def check_dvcfile_path(repo, path):
|
||||
if not is_valid_filename(path):
|
||||
raise StageFileBadNameError(
|
||||
"bad DVC file name '{}'. DVC files should be named "
|
||||
"'{}' or have a '.dvc' suffix (e.g. '{}.dvc').".format(
|
||||
relpath(path), PROJECT_FILE, os.path.basename(path)
|
||||
)
|
||||
f"bad DVC file name '{relpath(path)}'. DVC files should be named "
|
||||
f"'{PROJECT_FILE}' or have a '.dvc' suffix "
|
||||
f"(e.g. '{os.path.basename(path)}.dvc')."
|
||||
)
|
||||
|
||||
if is_git_ignored(repo, path):
|
||||
|
||||
+3
-3
@@ -1,4 +1,5 @@
|
||||
"""Exceptions raised by the dvc."""
|
||||
|
||||
import errno
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
@@ -270,9 +271,8 @@ class NoOutputInExternalRepoError(DvcException):
|
||||
from dvc.utils import relpath
|
||||
|
||||
super().__init__(
|
||||
"Output '{}' not found in target repository '{}'".format(
|
||||
relpath(path, external_repo_path), external_repo_url
|
||||
)
|
||||
f"Output {relpath(path, external_repo_path)!r} "
|
||||
f"not found in target repository '{external_repo_url}'"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Manages progress bars for DVC repo."""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from threading import RLock
|
||||
|
||||
@@ -96,9 +96,10 @@ class TempDirExecutor(BaseLocalExecutor):
|
||||
temp_merge: stash_rev,
|
||||
temp_baseline: entry.baseline_rev,
|
||||
}
|
||||
with get_exp_rwlock(
|
||||
repo, writes=[temp_head, temp_merge, temp_baseline]
|
||||
), self.set_temp_refs(scm, temp_ref_dict):
|
||||
with (
|
||||
get_exp_rwlock(repo, writes=[temp_head, temp_merge, temp_baseline]),
|
||||
self.set_temp_refs(scm, temp_ref_dict),
|
||||
):
|
||||
# Executor will be initialized with an empty git repo that
|
||||
# we populate by pushing:
|
||||
# EXEC_HEAD - the base commit for this experiment
|
||||
|
||||
@@ -474,10 +474,10 @@ class LocalCeleryQueue(BaseStashQueue):
|
||||
self.scm, exp_names, git_remote
|
||||
)
|
||||
if not git_remote:
|
||||
queue_entry_match: dict[
|
||||
str, Optional["QueueEntry"]
|
||||
] = self.match_queue_entry_by_name(
|
||||
exp_names, self.iter_queued(), self.iter_done()
|
||||
queue_entry_match: dict[str, Optional["QueueEntry"]] = (
|
||||
self.match_queue_entry_by_name(
|
||||
exp_names, self.iter_queued(), self.iter_done()
|
||||
)
|
||||
)
|
||||
|
||||
for exp_name in exp_names:
|
||||
|
||||
@@ -44,9 +44,9 @@ def remove( # noqa: C901, PLR0912
|
||||
exp_ref_list: list["ExpRefInfo"] = []
|
||||
queue_entry_list: list["QueueEntry"] = []
|
||||
if exp_names:
|
||||
results: dict[
|
||||
str, "ExpRefAndQueueEntry"
|
||||
] = celery_queue.get_ref_and_entry_by_names(exp_names, git_remote)
|
||||
results: dict[str, "ExpRefAndQueueEntry"] = (
|
||||
celery_queue.get_ref_and_entry_by_names(exp_names, git_remote)
|
||||
)
|
||||
remained: list[str] = []
|
||||
for name, result in results.items():
|
||||
if not result.exp_ref_info and not result.queue_entry:
|
||||
|
||||
+2
-6
@@ -25,15 +25,11 @@ def build_outs_trie(stages):
|
||||
overlapping = out
|
||||
if parent and overlapping:
|
||||
msg = (
|
||||
"The output paths:\n'{}'('{}')\n'{}'('{}')\n"
|
||||
f"The output paths:\n'{parent!s}'('{parent.stage.addressing}')\n"
|
||||
f"'{overlapping!s}'('{overlapping.stage.addressing}')\n"
|
||||
"overlap and are thus in the same tracked directory.\n"
|
||||
"To keep reproducibility, outputs should be in separate "
|
||||
"tracked directories or tracked individually."
|
||||
).format(
|
||||
str(parent),
|
||||
parent.stage.addressing,
|
||||
str(overlapping),
|
||||
overlapping.stage.addressing,
|
||||
)
|
||||
raise OverlappingOutputPathsError(parent, overlapping, msg)
|
||||
|
||||
|
||||
+4
-6
@@ -1,4 +1,5 @@
|
||||
"""Manages source control systems (e.g. Git)."""
|
||||
|
||||
import os
|
||||
from collections.abc import Iterator, Mapping
|
||||
from contextlib import contextmanager
|
||||
@@ -70,8 +71,7 @@ def SCM(
|
||||
*,
|
||||
search_parent_directories: bool = ...,
|
||||
no_scm: Literal[False] = ...,
|
||||
) -> "Git":
|
||||
...
|
||||
) -> "Git": ...
|
||||
|
||||
|
||||
@overload
|
||||
@@ -80,8 +80,7 @@ def SCM(
|
||||
*,
|
||||
search_parent_directories: bool = ...,
|
||||
no_scm: Literal[True],
|
||||
) -> "NoSCM":
|
||||
...
|
||||
) -> "NoSCM": ...
|
||||
|
||||
|
||||
@overload
|
||||
@@ -90,8 +89,7 @@ def SCM(
|
||||
*,
|
||||
search_parent_directories: bool = ...,
|
||||
no_scm: bool = ...,
|
||||
) -> Union["Git", "NoSCM"]:
|
||||
...
|
||||
) -> Union["Git", "NoSCM"]: ...
|
||||
|
||||
|
||||
def SCM(root_dir, *, search_parent_directories=True, no_scm=False):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Tests for modifications to an existing dataset.
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import random
|
||||
|
||||
@@ -39,9 +39,7 @@ def apply_diff(src, dest): # noqa: C901
|
||||
dest[i] = value
|
||||
else:
|
||||
raise AssertionError( # noqa: TRY004
|
||||
"Can't apply diff from {} to {}".format(
|
||||
src.__class__.__name__, dest.__class__.__name__
|
||||
)
|
||||
f"Can't apply diff from {type(src).__name__} to {type(dest).__name__}"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Common utilities for serialize."""
|
||||
|
||||
import os
|
||||
from contextlib import AbstractContextManager, contextmanager
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional, Protocol, TextIO, Union
|
||||
@@ -15,25 +16,21 @@ if TYPE_CHECKING:
|
||||
class DumperFn(Protocol):
|
||||
def __call__(
|
||||
self, path: "StrPath", data: Any, fs: Optional["FileSystem"] = None
|
||||
) -> Any:
|
||||
...
|
||||
) -> Any: ...
|
||||
|
||||
|
||||
class DumpersFn(Protocol):
|
||||
def __call__(self, data: Any, stream: TextIO) -> Any:
|
||||
...
|
||||
def __call__(self, data: Any, stream: TextIO) -> Any: ...
|
||||
|
||||
|
||||
class ModifierFn(Protocol):
|
||||
def __call__(
|
||||
self, path: "StrPath", fs: Optional["FileSystem"] = None
|
||||
) -> AbstractContextManager[dict]:
|
||||
...
|
||||
) -> AbstractContextManager[dict]: ...
|
||||
|
||||
|
||||
class LoaderFn(Protocol):
|
||||
def __call__(self, path: "StrPath", fs: Optional["FileSystem"] = None) -> Any:
|
||||
...
|
||||
def __call__(self, path: "StrPath", fs: Optional["FileSystem"] = None) -> Any: ...
|
||||
|
||||
|
||||
ReadType = Union[bytes, None, str]
|
||||
|
||||
@@ -6,6 +6,7 @@ Used for parsing dvc.yaml, dvc.lock and .dvc files.
|
||||
|
||||
Not to be confused with strictyaml, a python library with similar motivations.
|
||||
"""
|
||||
|
||||
import re
|
||||
import typing
|
||||
from contextlib import suppress
|
||||
|
||||
@@ -43,7 +43,6 @@ from global repo template to creating everything inplace, which:
|
||||
- does not create unnecessary files
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -453,15 +453,11 @@ def test_show_csv(tmp_dir, scm, dvc, exp_stage, capsys):
|
||||
in cap.out
|
||||
)
|
||||
assert (
|
||||
"{},{},branch_base,{},,2,2,{}".format(
|
||||
ref_info1.name, rev1[:7], _get_rev_isotimestamp(rev1), data_hash
|
||||
)
|
||||
f"{ref_info1.name},{rev1[:7]},branch_base,{_get_rev_isotimestamp(rev1)},,2,2,{data_hash}"
|
||||
in cap.out
|
||||
)
|
||||
assert (
|
||||
"{},{},branch_commit,{},,3,3,{}".format(
|
||||
ref_info2.name, rev2[:7], _get_rev_isotimestamp(rev2), data_hash
|
||||
)
|
||||
f"{ref_info2.name},{rev2[:7]},branch_commit,{_get_rev_isotimestamp(rev2)},,3,3,{data_hash}"
|
||||
in cap.out
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Negative tests for the parametrization."""
|
||||
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Testing happy paths for the foreach."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
Reference in New Issue
Block a user