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 (#10443)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,13 +22,13 @@ repos:
|
||||
- id: sort-simple-yaml
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.4.4'
|
||||
rev: 'v0.4.7'
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.2.6
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: codespell
|
||||
additional_dependencies: ["tomli"]
|
||||
|
||||
+1
-1
@@ -285,7 +285,7 @@ def _open(
|
||||
if TYPE_CHECKING:
|
||||
from dvc.fs import FileSystem
|
||||
|
||||
fs: Union["FileSystem", DataFileSystem, DVCFileSystem]
|
||||
fs: Union[FileSystem, DataFileSystem, DVCFileSystem]
|
||||
if os.path.isabs(path):
|
||||
fs = DataFileSystem(index=_repo.index.data["local"])
|
||||
fs_path = path
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ class CmdBase(ABC):
|
||||
|
||||
os.chdir(args.cd)
|
||||
|
||||
self.repo: "Repo" = Repo(uninitialized=self.UNINITIALIZED)
|
||||
self.config: "Config" = self.repo.config
|
||||
self.repo: Repo = Repo(uninitialized=self.UNINITIALIZED)
|
||||
self.config: Config = self.repo.config
|
||||
self.args = args
|
||||
|
||||
def do_run(self):
|
||||
|
||||
@@ -42,7 +42,7 @@ class CmdDatasetAdd(CmdBase):
|
||||
if rev := dataset.lock.rev:
|
||||
ver = rev
|
||||
|
||||
ver_part: Optional["Text"] = None
|
||||
ver_part: Optional[Text] = None
|
||||
if ver:
|
||||
ver_part = ui.rich_text.assemble(" @ ", (ver, "repr.number"))
|
||||
text = ui.rich_text.assemble("(", (url, "repr.url"), ver_part or "", ")")
|
||||
|
||||
@@ -72,7 +72,7 @@ class CmdPlots(CmdBase):
|
||||
html_template_path = os.path.join(self.repo.dvc_dir, html_template_path)
|
||||
return html_template_path
|
||||
|
||||
def run(self) -> int: # noqa: C901, PLR0911, PLR0912
|
||||
def run(self) -> int: # noqa: C901, PLR0911
|
||||
from pathlib import Path
|
||||
|
||||
from dvc.render.match import match_defs_renderers
|
||||
|
||||
@@ -68,7 +68,7 @@ def prepare_stages_data(
|
||||
class CmdStageList(CmdBase):
|
||||
def _get_stages(self) -> Iterable["Stage"]:
|
||||
if self.args.all:
|
||||
stages: list["Stage"] = self.repo.index.stages
|
||||
stages: list[Stage] = self.repo.index.stages
|
||||
logger.trace("%d no. of stages found", len(stages))
|
||||
return stages
|
||||
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ class TabularData(MutableSequence[Sequence["CellT"]]):
|
||||
if key not in keys:
|
||||
self.add_column(key)
|
||||
|
||||
row: list["CellT"] = [
|
||||
row: list[CellT] = [
|
||||
with_value(d.get(key), self._fill_value) for key in self.keys()
|
||||
]
|
||||
self.append(row)
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ def _spawn(
|
||||
env: Optional[Mapping[str, str]] = None,
|
||||
output_file: Optional[str] = None,
|
||||
) -> int:
|
||||
file: "AbstractContextManager[Any]" = nullcontext()
|
||||
file: AbstractContextManager[Any] = nullcontext()
|
||||
kwargs = {}
|
||||
if output_file:
|
||||
file = open(output_file, "ab") # noqa: SIM115
|
||||
|
||||
@@ -37,7 +37,7 @@ class AbstractDependency(Dependency):
|
||||
"""Dependency without workspace/fs/fs_path"""
|
||||
|
||||
def __init__(self, stage: "Stage", info: dict[str, Any], *args, **kwargs):
|
||||
self.repo: "Repo" = stage.repo
|
||||
self.repo: Repo = stage.repo
|
||||
self.stage = stage
|
||||
self.fs = None
|
||||
self.fs_path = None
|
||||
|
||||
+1
-1
@@ -429,7 +429,7 @@ class _DVCFileSystem(AbstractFileSystem):
|
||||
ignore_subrepos = kwargs.get("ignore_subrepos", True)
|
||||
return self._info(key, path, ignore_subrepos=ignore_subrepos)
|
||||
|
||||
def _info( # noqa: C901, PLR0912
|
||||
def _info( # noqa: C901
|
||||
self, key, path, ignore_subrepos=True, check_ignored=True
|
||||
):
|
||||
repo, dvc_fs, subkey = self._get_subrepo_info(key)
|
||||
|
||||
+4
-4
@@ -390,7 +390,7 @@ class Output:
|
||||
self.can_push = push
|
||||
|
||||
self.fs_path = self._parse_path(self.fs, fs_path)
|
||||
self.obj: Optional["HashFile"] = None
|
||||
self.obj: Optional[HashFile] = None
|
||||
|
||||
self.remote = remote
|
||||
|
||||
@@ -902,7 +902,7 @@ class Output:
|
||||
def get_obj(
|
||||
self, filter_info: Optional[str] = None, **kwargs
|
||||
) -> Optional["HashFile"]:
|
||||
obj: Optional["HashFile"] = None
|
||||
obj: Optional[HashFile] = None
|
||||
if self.obj:
|
||||
obj = self.obj
|
||||
elif self.files:
|
||||
@@ -1158,7 +1158,7 @@ class Output:
|
||||
logger.warning(msg)
|
||||
return {}
|
||||
|
||||
obj: Optional["HashFile"]
|
||||
obj: Optional[HashFile]
|
||||
if self.is_dir_checksum:
|
||||
obj = self._collect_used_dir_cache(**kwargs)
|
||||
else:
|
||||
@@ -1353,7 +1353,7 @@ class Output:
|
||||
cache = self.cache if self.use_cache else self.local_cache
|
||||
assert isinstance(cache, HashFileDB)
|
||||
|
||||
new: "HashFile"
|
||||
new: HashFile
|
||||
try:
|
||||
assert self.hash_name
|
||||
staging, meta, obj = self._build(
|
||||
|
||||
@@ -563,10 +563,10 @@ class MatrixDefinition:
|
||||
iterable = self.resolved_iterable
|
||||
assert isinstance(iterable, Mapping)
|
||||
|
||||
ret: dict[str, "DictStrAny"] = {}
|
||||
ret: dict[str, DictStrAny] = {}
|
||||
matrix = {key: enumerate(v) for key, v in iterable.items()}
|
||||
for combination in product(*matrix.values()):
|
||||
d: "DictStrAny" = {}
|
||||
d: DictStrAny = {}
|
||||
fragments: list[str] = []
|
||||
for k, (i, v) in zip(matrix.keys(), combination):
|
||||
d[k] = v
|
||||
|
||||
@@ -184,12 +184,12 @@ class Repo:
|
||||
# used by DVCFileSystem to determine if it should traverse subrepos
|
||||
self.subrepos = subrepos
|
||||
|
||||
self.cloud: "DataCloud" = DataCloud(self)
|
||||
self.stage: "StageLoad" = StageLoad(self)
|
||||
self.cloud: DataCloud = DataCloud(self)
|
||||
self.stage: StageLoad = StageLoad(self)
|
||||
|
||||
self.lock: "LockBase"
|
||||
self.lock: LockBase
|
||||
self.cache: CacheManager
|
||||
self.state: "StateBase"
|
||||
self.state: StateBase
|
||||
if isinstance(self.fs, GitFileSystem) or not self.dvc_dir:
|
||||
self.lock = LockNoop()
|
||||
self.state = StateNoop()
|
||||
|
||||
@@ -137,14 +137,12 @@ class Artifacts:
|
||||
|
||||
assert not (version and stage)
|
||||
name = _reformat_name(name)
|
||||
tags: list["GitTag"] = find(
|
||||
name=name, version=version, stage=stage, scm=self.scm
|
||||
)
|
||||
tags: list[GitTag] = find(name=name, version=version, stage=stage, scm=self.scm)
|
||||
if not tags:
|
||||
raise ArtifactNotFoundError(name, version=version, stage=stage)
|
||||
if version or stage:
|
||||
return tags[-1].target
|
||||
gto_tags: list["GTOTag"] = sort_versions(parse_tag(tag) for tag in tags)
|
||||
gto_tags: list[GTOTag] = sort_versions(parse_tag(tag) for tag in tags)
|
||||
return gto_tags[0].tag.target
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -242,7 +242,7 @@ class DatasetNotFoundError(DvcException, KeyError):
|
||||
|
||||
class Datasets(Mapping[str, Dataset]):
|
||||
def __init__(self, repo: "Repo") -> None:
|
||||
self.repo: "Repo" = repo
|
||||
self.repo: Repo = repo
|
||||
|
||||
def __repr__(self):
|
||||
return repr(dict(self))
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ def _diff(old, new, data_keys, with_missing=False):
|
||||
from dvc_data.index.diff import ADD, DELETE, MODIFY, RENAME
|
||||
from dvc_data.index.diff import diff as idiff
|
||||
|
||||
ret: "dict[str, list[dict]]" = {
|
||||
ret: dict[str, list[dict]] = {
|
||||
"added": [],
|
||||
"deleted": [],
|
||||
"modified": [],
|
||||
|
||||
@@ -119,7 +119,7 @@ class Experiments:
|
||||
**kwargs,
|
||||
):
|
||||
"""Reproduce and checkout a single (standalone) experiment."""
|
||||
exp_queue: "BaseStashQueue" = (
|
||||
exp_queue: BaseStashQueue = (
|
||||
self.tempdir_queue if tmp_dir else self.workspace_queue
|
||||
)
|
||||
self.queue_one(exp_queue, **kwargs)
|
||||
|
||||
@@ -25,7 +25,7 @@ def apply(repo: "Repo", rev: str, **kwargs):
|
||||
from dvc.repo.checkout import checkout as dvc_checkout
|
||||
from dvc.scm import RevError, resolve_rev
|
||||
|
||||
exps: "Experiments" = repo.experiments
|
||||
exps: Experiments = repo.experiments
|
||||
|
||||
is_stash: bool = False
|
||||
|
||||
@@ -57,7 +57,7 @@ def apply(repo: "Repo", rev: str, **kwargs):
|
||||
|
||||
|
||||
def _apply(repo: "Repo", rev: str, name: Optional[str] = None, is_stash: bool = False):
|
||||
exps: "Experiments" = repo.experiments
|
||||
exps: Experiments = repo.experiments
|
||||
|
||||
with exps.apply_stash.preserve_workspace(rev, name=name):
|
||||
with repo.scm.detach_head(rev, force=True):
|
||||
|
||||
@@ -174,7 +174,7 @@ def collect_active(
|
||||
"""
|
||||
if not baseline_revs:
|
||||
return {}
|
||||
result: dict[str, list["ExpRange"]] = {}
|
||||
result: dict[str, list[ExpRange]] = {}
|
||||
exps = repo.experiments
|
||||
for queue in (exps.workspace_queue, exps.tempdir_queue, exps.celery_queue):
|
||||
for baseline, active_exps in queue.collect_active_data(
|
||||
@@ -220,7 +220,7 @@ def collect_successful(
|
||||
Returns:
|
||||
Dict mapping baseline revision to successful experiments.
|
||||
"""
|
||||
result: dict[str, list["ExpRange"]] = {}
|
||||
result: dict[str, list[ExpRange]] = {}
|
||||
for baseline_rev in baseline_revs:
|
||||
result[baseline_rev] = list(_collect_baseline(repo, baseline_rev, **kwargs))
|
||||
return result
|
||||
@@ -304,7 +304,7 @@ def collect(
|
||||
)
|
||||
|
||||
workspace_data = collect_rev(repo, "workspace", **kwargs)
|
||||
result: list["ExpState"] = [workspace_data]
|
||||
result: list[ExpState] = [workspace_data]
|
||||
queued = collect_queued(repo, baseline_revs, **kwargs) if not hide_queued else {}
|
||||
active = collect_active(repo, baseline_revs, **kwargs)
|
||||
failed = collect_failed(repo, baseline_revs, **kwargs) if not hide_failed else {}
|
||||
|
||||
@@ -199,7 +199,7 @@ class BaseExecutor(ABC):
|
||||
@classmethod
|
||||
def from_info(cls, info: "ExecutorInfo") -> "Self":
|
||||
if info.result_hash:
|
||||
result: Optional["ExecutorResult"] = ExecutorResult(
|
||||
result: Optional[ExecutorResult] = ExecutorResult(
|
||||
info.result_hash,
|
||||
(ExpRefInfo.from_ref(info.result_ref) if info.result_ref else None),
|
||||
info.result_force,
|
||||
@@ -470,7 +470,7 @@ class BaseExecutor(ABC):
|
||||
cls._set_log_level(log_level)
|
||||
|
||||
exp_hash: Optional[str] = None
|
||||
exp_ref: Optional["ExpRefInfo"] = None
|
||||
exp_ref: Optional[ExpRefInfo] = None
|
||||
repro_force: bool = False
|
||||
|
||||
if info.name:
|
||||
@@ -559,7 +559,7 @@ class BaseExecutor(ABC):
|
||||
)
|
||||
|
||||
ref: Optional[str] = dvc.scm.get_ref(EXEC_BRANCH, follow=False)
|
||||
exp_ref: Optional["ExpRefInfo"] = ExpRefInfo.from_ref(ref) if ref else None
|
||||
exp_ref: Optional[ExpRefInfo] = ExpRefInfo.from_ref(ref) if ref else None
|
||||
if cls.WARN_UNTRACKED:
|
||||
untracked = dvc.scm.untracked_files()
|
||||
if untracked:
|
||||
|
||||
@@ -201,7 +201,7 @@ class WorkspaceExecutor(BaseLocalExecutor):
|
||||
@classmethod
|
||||
def from_stash_entry(cls, repo: "Repo", entry: "ExpStashEntry", **kwargs):
|
||||
root_dir = repo.scm.root_dir
|
||||
executor: "WorkspaceExecutor" = cls._from_stash_entry(
|
||||
executor: WorkspaceExecutor = cls._from_stash_entry(
|
||||
repo, entry, root_dir, **kwargs
|
||||
)
|
||||
logger.debug("Init workspace executor in '%s'", root_dir)
|
||||
|
||||
@@ -30,7 +30,7 @@ def pull( # noqa: C901
|
||||
pull_cache: bool = False,
|
||||
**kwargs,
|
||||
) -> Iterable[str]:
|
||||
exp_ref_set: set["ExpRefInfo"] = set()
|
||||
exp_ref_set: set[ExpRefInfo] = set()
|
||||
if all_commits:
|
||||
exp_ref_set.update(exp_refs(repo.scm, git_remote))
|
||||
elif exp_names:
|
||||
@@ -97,7 +97,7 @@ def _pull(
|
||||
def group_result(refspec):
|
||||
return results[str(refspec)]
|
||||
|
||||
pull_result: Mapping[SyncStatus, list["ExpRefInfo"]] = group_by(group_result, refs)
|
||||
pull_result: Mapping[SyncStatus, list[ExpRefInfo]] = group_by(group_result, refs)
|
||||
|
||||
return pull_result
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ def push(
|
||||
push_cache: bool = False,
|
||||
**kwargs: Any,
|
||||
) -> dict[str, Any]:
|
||||
exp_ref_set: set["ExpRefInfo"] = set()
|
||||
exp_ref_set: set[ExpRefInfo] = set()
|
||||
assert isinstance(repo.scm, Git)
|
||||
if all_commits:
|
||||
exp_ref_set.update(exp_refs(repo.scm))
|
||||
@@ -162,7 +162,7 @@ def _push(
|
||||
def group_result(refspec):
|
||||
return results[str(refspec)]
|
||||
|
||||
pull_result: Mapping[SyncStatus, list["ExpRefInfo"]] = group_by(group_result, refs)
|
||||
pull_result: Mapping[SyncStatus, list[ExpRefInfo]] = group_by(group_result, refs)
|
||||
|
||||
return pull_result
|
||||
|
||||
|
||||
@@ -470,11 +470,11 @@ class LocalCeleryQueue(BaseStashQueue):
|
||||
exp_names = [exp_names]
|
||||
results: dict[str, ExpRefAndQueueEntry] = {}
|
||||
|
||||
exp_ref_match: dict[str, Optional["ExpRefInfo"]] = resolve_name(
|
||||
exp_ref_match: dict[str, Optional[ExpRefInfo]] = resolve_name(
|
||||
self.scm, exp_names, git_remote
|
||||
)
|
||||
if not git_remote:
|
||||
queue_entry_match: dict[str, Optional["QueueEntry"]] = (
|
||||
queue_entry_match: dict[str, Optional[QueueEntry]] = (
|
||||
self.match_queue_entry_by_name(
|
||||
exp_names, self.iter_queued(), self.iter_done()
|
||||
)
|
||||
@@ -613,7 +613,7 @@ class LocalCeleryQueue(BaseStashQueue):
|
||||
"""Map exp refs to any available successful executors."""
|
||||
from dvc.repo.experiments.serialize import ExpExecutor, LocalExpExecutor
|
||||
|
||||
result: dict[str, "ExpExecutor"] = {}
|
||||
result: dict[str, ExpExecutor] = {}
|
||||
for entry, exec_result in self.iter_success():
|
||||
if baseline_revs and entry.baseline_rev not in baseline_revs:
|
||||
continue
|
||||
|
||||
@@ -21,11 +21,11 @@ def remove_tasks( # noqa: C901, PLR0912
|
||||
"""
|
||||
from celery.result import AsyncResult
|
||||
|
||||
stash_revs: dict[str, "ExpStashEntry"] = {}
|
||||
failed_stash_revs: list["ExpStashEntry"] = []
|
||||
done_entry_set: set["QueueEntry"] = set()
|
||||
stash_revs: dict[str, ExpStashEntry] = {}
|
||||
failed_stash_revs: list[ExpStashEntry] = []
|
||||
done_entry_set: set[QueueEntry] = set()
|
||||
stash_rev_all = celery_queue.stash.stash_revs
|
||||
failed_rev_all: dict[str, "ExpStashEntry"] = {}
|
||||
failed_rev_all: dict[str, ExpStashEntry] = {}
|
||||
if celery_queue.failed_stash:
|
||||
failed_rev_all = celery_queue.failed_stash.stash_revs
|
||||
for entry in queue_entries:
|
||||
@@ -90,17 +90,17 @@ def celery_clear(
|
||||
"""
|
||||
|
||||
removed: list[str] = []
|
||||
entry_list: list["QueueEntry"] = []
|
||||
entry_list: list[QueueEntry] = []
|
||||
if queued:
|
||||
queue_entries: list["QueueEntry"] = list(self.iter_queued())
|
||||
queue_entries: list[QueueEntry] = list(self.iter_queued())
|
||||
entry_list.extend(queue_entries)
|
||||
removed.extend(_get_names(queue_entries))
|
||||
if failed:
|
||||
failed_tasks: list["QueueDoneResult"] = list(self.iter_failed())
|
||||
failed_tasks: list[QueueDoneResult] = list(self.iter_failed())
|
||||
entry_list.extend([result.entry for result in failed_tasks])
|
||||
removed.extend(_get_names(failed_tasks))
|
||||
if success:
|
||||
success_tasks: list["QueueDoneResult"] = list(self.iter_success())
|
||||
success_tasks: list[QueueDoneResult] = list(self.iter_success())
|
||||
entry_list.extend([result.entry for result in success_tasks])
|
||||
removed.extend(_get_names(success_tasks))
|
||||
|
||||
@@ -125,7 +125,7 @@ def celery_remove(self: "LocalCeleryQueue", revs: Collection[str]) -> list[str]:
|
||||
|
||||
remained: list[str] = []
|
||||
removed: list[str] = []
|
||||
entry_to_remove: list["QueueEntry"] = []
|
||||
entry_to_remove: list[QueueEntry] = []
|
||||
for name, entry in match_results.items():
|
||||
if entry:
|
||||
entry_to_remove.append(entry)
|
||||
|
||||
@@ -34,17 +34,17 @@ def remove( # noqa: C901, PLR0912
|
||||
removed: list[str] = []
|
||||
if not any([exp_names, queue, all_commits, rev]):
|
||||
return removed
|
||||
celery_queue: "LocalCeleryQueue" = repo.experiments.celery_queue
|
||||
celery_queue: LocalCeleryQueue = repo.experiments.celery_queue
|
||||
|
||||
if queue:
|
||||
removed.extend(celery_queue.clear(queued=True))
|
||||
|
||||
assert isinstance(repo.scm, Git)
|
||||
|
||||
exp_ref_list: list["ExpRefInfo"] = []
|
||||
queue_entry_list: list["QueueEntry"] = []
|
||||
exp_ref_list: list[ExpRefInfo] = []
|
||||
queue_entry_list: list[QueueEntry] = []
|
||||
if exp_names:
|
||||
results: dict[str, "ExpRefAndQueueEntry"] = (
|
||||
results: dict[str, ExpRefAndQueueEntry] = (
|
||||
celery_queue.get_ref_and_entry_by_names(exp_names, git_remote)
|
||||
)
|
||||
remained: list[str] = []
|
||||
@@ -94,7 +94,7 @@ def _resolve_exp_by_baseline(
|
||||
) -> dict[str, "ExpRefInfo"]:
|
||||
assert isinstance(repo.scm, Git)
|
||||
|
||||
commit_ref_dict: dict[str, "ExpRefInfo"] = {}
|
||||
commit_ref_dict: dict[str, ExpRefInfo] = {}
|
||||
rev_dict = iter_revs(repo.scm, rev, num)
|
||||
rev_set = set(rev_dict.keys())
|
||||
ref_info_dict = exp_refs_by_baseline(repo.scm, rev_set, git_remote)
|
||||
|
||||
@@ -117,7 +117,7 @@ def _build_rows(
|
||||
**kwargs,
|
||||
) -> Iterator[tuple["CellT", ...]]:
|
||||
for baseline in baseline_states:
|
||||
row: dict[str, "CellT"] = dict.fromkeys(all_headers, fill_value)
|
||||
row: dict[str, CellT] = dict.fromkeys(all_headers, fill_value)
|
||||
row["Experiment"] = ""
|
||||
if baseline.name:
|
||||
row["rev"] = baseline.name
|
||||
@@ -232,7 +232,7 @@ def _exp_range_rows(
|
||||
logger.debug("Returning tip commit for legacy checkpoint exp")
|
||||
exp = first(exp_range.revs)
|
||||
if exp:
|
||||
row: dict[str, "CellT"] = dict.fromkeys(all_headers, fill_value)
|
||||
row: dict[str, CellT] = dict.fromkeys(all_headers, fill_value)
|
||||
row["Experiment"] = exp.name or ""
|
||||
row["rev"] = exp.rev[:7] if Git.is_sha(exp.rev) else exp.rev
|
||||
row["typ"] = "branch_base" if is_base else "branch_commit"
|
||||
|
||||
@@ -199,7 +199,7 @@ def exp_commits(
|
||||
scm: "Git", ref_infos: Optional[Iterable[ExpRefInfo]] = None
|
||||
) -> Iterable[str]:
|
||||
"""Iterate over all experiment commits."""
|
||||
shas: set["str"] = set()
|
||||
shas: set[str] = set()
|
||||
refs = ref_infos if ref_infos else exp_refs(scm)
|
||||
for ref_info in refs:
|
||||
shas.update(scm.branch_revs(str(ref_info), ref_info.baseline_sha))
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ def fetch( # noqa: PLR0913
|
||||
|
||||
|
||||
def _log_unversioned(data: list["DataIndex"]) -> tuple[list["DataIndex"], int]:
|
||||
ret: list["DataIndex"] = []
|
||||
ret: list[DataIndex] = []
|
||||
unversioned: list[str] = []
|
||||
for fs_index in data:
|
||||
remote = fs_index.storage_map[()].remote
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ def gc( # noqa: C901, PLR0912, PLR0913
|
||||
repos = []
|
||||
all_repos = [Repo(path) for path in repos]
|
||||
|
||||
odb_to_obj_ids: "ObjectContainer" = {}
|
||||
odb_to_obj_ids: ObjectContainer = {}
|
||||
with ExitStack() as stack:
|
||||
for repo in all_repos:
|
||||
stack.enter_context(repo.lock)
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ def get(
|
||||
from dvc.fs import download
|
||||
from dvc.fs.data import DataFileSystem
|
||||
|
||||
fs: Union[DataFileSystem, "DVCFileSystem"]
|
||||
fs: Union[DataFileSystem, DVCFileSystem]
|
||||
if os.path.isabs(path):
|
||||
fs = DataFileSystem(index=repo.index.data["local"])
|
||||
fs_path = fs.from_os_path(path)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ def check_acyclic(graph: "DiGraph") -> None:
|
||||
except nx.NetworkXNoCycle:
|
||||
return
|
||||
|
||||
stages: set["Stage"] = set()
|
||||
stages: set[Stage] = set()
|
||||
for from_node, to_node, _ in edges:
|
||||
stages.add(from_node)
|
||||
stages.add(to_node)
|
||||
|
||||
+12
-12
@@ -300,7 +300,7 @@ class Index:
|
||||
self._artifacts = artifacts or {}
|
||||
self._datasets: dict[str, list[dict[str, Any]]] = datasets or {}
|
||||
self._datasets_lock: dict[str, list[dict[str, Any]]] = datasets_lock or {}
|
||||
self._collected_targets: dict[int, list["StageInfo"]] = {}
|
||||
self._collected_targets: dict[int, list[StageInfo]] = {}
|
||||
|
||||
@cached_property
|
||||
def rev(self) -> Optional[str]:
|
||||
@@ -416,7 +416,7 @@ class Index:
|
||||
|
||||
@cached_property
|
||||
def out_data_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
by_workspace: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
by_workspace: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
|
||||
by_workspace["repo"] = set()
|
||||
by_workspace["local"] = set()
|
||||
@@ -470,7 +470,7 @@ class Index:
|
||||
|
||||
@cached_property
|
||||
def data_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
by_workspace: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
by_workspace: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
|
||||
by_workspace["repo"] = set()
|
||||
by_workspace["local"] = set()
|
||||
@@ -488,7 +488,7 @@ class Index:
|
||||
def metric_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
from .metrics.show import _collect_top_level_metrics
|
||||
|
||||
by_workspace: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
by_workspace: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
|
||||
by_workspace["repo"] = set()
|
||||
|
||||
@@ -509,7 +509,7 @@ class Index:
|
||||
def param_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
from .params.show import _collect_top_level_params
|
||||
|
||||
by_workspace: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
by_workspace: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
by_workspace["repo"] = set()
|
||||
|
||||
param_paths = _collect_top_level_params(self.repo)
|
||||
@@ -525,7 +525,7 @@ class Index:
|
||||
|
||||
@cached_property
|
||||
def plot_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
by_workspace: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
by_workspace: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
|
||||
by_workspace["repo"] = set()
|
||||
|
||||
@@ -548,7 +548,7 @@ class Index:
|
||||
|
||||
@cached_property
|
||||
def data(self) -> "dict[str, DataIndex]":
|
||||
prefix: "DataIndexKey"
|
||||
prefix: DataIndexKey
|
||||
loaded = False
|
||||
|
||||
index = self.repo.data_index
|
||||
@@ -627,7 +627,7 @@ class Index:
|
||||
jobs: Optional[int] = None,
|
||||
push: bool = False,
|
||||
) -> "ObjectContainer":
|
||||
used: "ObjectContainer" = defaultdict(set)
|
||||
used: ObjectContainer = defaultdict(set)
|
||||
pairs = self.collect_targets(targets, recursive=recursive, with_deps=with_deps)
|
||||
for stage, filter_info in pairs:
|
||||
for odb, objs in stage.get_used_objs(
|
||||
@@ -748,7 +748,7 @@ class IndexView:
|
||||
|
||||
@cached_property
|
||||
def out_data_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
by_workspace: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
by_workspace: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
|
||||
by_workspace["repo"] = set()
|
||||
by_workspace["local"] = set()
|
||||
@@ -764,7 +764,7 @@ class IndexView:
|
||||
|
||||
@cached_property
|
||||
def _data_prefixes(self) -> dict[str, "_DataPrefixes"]:
|
||||
prefixes: dict[str, "_DataPrefixes"] = defaultdict(
|
||||
prefixes: dict[str, _DataPrefixes] = defaultdict(
|
||||
lambda: _DataPrefixes(set(), set())
|
||||
)
|
||||
for out, filter_info in self._filtered_outs:
|
||||
@@ -781,7 +781,7 @@ class IndexView:
|
||||
|
||||
@cached_property
|
||||
def data_keys(self) -> dict[str, set["DataIndexKey"]]:
|
||||
ret: dict[str, set["DataIndexKey"]] = defaultdict(set)
|
||||
ret: dict[str, set[DataIndexKey]] = defaultdict(set)
|
||||
|
||||
for out, filter_info in self._filtered_outs:
|
||||
if not out.use_cache:
|
||||
@@ -811,7 +811,7 @@ class IndexView:
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
data: dict[str, Union["DataIndex", "DataIndexView"]] = {}
|
||||
data: dict[str, Union[DataIndex, DataIndexView]] = {}
|
||||
for workspace, data_index in self._index.data.items():
|
||||
if self.stages:
|
||||
data[workspace] = view(data_index, partial(key_filter, workspace))
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ def _ls(
|
||||
recursive: Optional[bool] = None,
|
||||
dvc_only: bool = False,
|
||||
):
|
||||
fs: "DVCFileSystem" = repo.dvcfs
|
||||
fs: DVCFileSystem = repo.dvcfs
|
||||
fs_path = fs.from_os_path(path)
|
||||
|
||||
fs_path = fs.info(fs_path)["name"]
|
||||
|
||||
@@ -146,7 +146,7 @@ def _cached_clone(url, rev):
|
||||
|
||||
|
||||
@wrap_with(threading.Lock())
|
||||
def _clone_default_branch(url, rev): # noqa: PLR0912
|
||||
def _clone_default_branch(url, rev):
|
||||
"""Get or create a clean clone of the url.
|
||||
|
||||
The cloned is reactualized with git pull unless rev is a known sha.
|
||||
|
||||
@@ -29,7 +29,7 @@ def collect_stages(
|
||||
recursive: bool = False,
|
||||
glob: bool = False,
|
||||
) -> list["Stage"]:
|
||||
stages: list["Stage"] = []
|
||||
stages: list[Stage] = []
|
||||
for target in targets:
|
||||
stages.extend(repo.stage.collect(target, recursive=recursive, glob=glob))
|
||||
return ldistinct(stages)
|
||||
@@ -166,10 +166,10 @@ def _reproduce(
|
||||
) -> list["Stage"]:
|
||||
assert on_error in ("fail", "keep-going", "ignore")
|
||||
|
||||
result: list["Stage"] = []
|
||||
failed: list["Stage"] = []
|
||||
to_skip: dict["Stage", "Stage"] = {}
|
||||
ret: Optional["Stage"] = None
|
||||
result: list[Stage] = []
|
||||
failed: list[Stage] = []
|
||||
to_skip: dict[Stage, Stage] = {}
|
||||
ret: Optional[Stage] = None
|
||||
|
||||
force_state = dict.fromkeys(stages, force)
|
||||
|
||||
@@ -228,7 +228,7 @@ def reproduce(
|
||||
if not kwargs.get("interactive", False):
|
||||
kwargs["interactive"] = self.config["core"].get("interactive", False)
|
||||
|
||||
stages: list["Stage"] = []
|
||||
stages: list[Stage] = []
|
||||
if not all_pipelines:
|
||||
targets_list = ensure_list(targets or PROJECT_FILE)
|
||||
stages = collect_stages(self, targets_list, recursive=recursive, glob=glob)
|
||||
|
||||
@@ -21,7 +21,7 @@ class SCMContext:
|
||||
def __init__(self, scm: "Base", config: Optional[dict[str, Any]] = None) -> None:
|
||||
from funcy import get_in
|
||||
|
||||
self.scm: "Base" = scm
|
||||
self.scm: Base = scm
|
||||
self.autostage: bool = get_in(
|
||||
config or {}, ["core", "autostage"], default=False
|
||||
)
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ def locked(f):
|
||||
|
||||
class StageLoad:
|
||||
def __init__(self, repo: "Repo") -> None:
|
||||
self.repo: "Repo" = repo
|
||||
self.repo: Repo = repo
|
||||
|
||||
@property
|
||||
def fs(self):
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ def update( # noqa: C901
|
||||
raise InvalidArgumentError("--remote can't be used without --to-remote")
|
||||
|
||||
import_stages = set()
|
||||
other_stage_infos: list["StageInfo"] = []
|
||||
other_stage_infos: list[StageInfo] = []
|
||||
|
||||
for stage_info in self.index.collect_targets(targets, recursive=recursive):
|
||||
if stage_info.stage.is_import:
|
||||
|
||||
@@ -166,7 +166,7 @@ def update_worktree_stages(repo: "Repo", stage_infos: Iterable["StageInfo"]):
|
||||
|
||||
view = IndexView(repo.index, stage_infos, outs_filter=outs_filter)
|
||||
local_index = view.data["repo"]
|
||||
remote_indexes: dict[str, tuple["Remote", "DataIndex"]] = {}
|
||||
remote_indexes: dict[str, tuple[Remote, DataIndex]] = {}
|
||||
for stage in view.stages:
|
||||
for out in stage.outs:
|
||||
_update_worktree_out(repo, out, local_index, remote_indexes)
|
||||
|
||||
@@ -290,7 +290,7 @@ class Stage(params.StageParams):
|
||||
)
|
||||
|
||||
def short_description(self) -> Optional["str"]:
|
||||
desc: Optional["str"] = None
|
||||
desc: Optional[str] = None
|
||||
if self.desc:
|
||||
with suppress(ValueError):
|
||||
# try to use first non-empty line as a description
|
||||
@@ -658,7 +658,7 @@ class Stage(params.StageParams):
|
||||
def checkout(
|
||||
self, allow_missing: bool = False, **kwargs
|
||||
) -> dict[str, list["StrPath"]]:
|
||||
stats: dict[str, list["StrPath"]] = defaultdict(list)
|
||||
stats: dict[str, list[StrPath]] = defaultdict(list)
|
||||
if self.is_partial_import:
|
||||
return stats
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class StageLoader(Mapping):
|
||||
from dvc.output import Output, merge_file_meta_from_cloud
|
||||
|
||||
assert isinstance(lock_data, dict)
|
||||
items: Iterable[tuple[str, "Output"]] = chain(
|
||||
items: Iterable[tuple[str, Output]] = chain(
|
||||
((StageParams.PARAM_DEPS, dep) for dep in stage.deps),
|
||||
((StageParams.PARAM_OUTS, out) for out in stage.outs),
|
||||
)
|
||||
|
||||
@@ -256,6 +256,7 @@ module = [
|
||||
|
||||
[tool.codespell]
|
||||
ignore-words-list = "ba,datas,fo,uptodate,cachable,falsy"
|
||||
skip = "CODE_OF_CONDUCT.md"
|
||||
|
||||
[tool.ruff]
|
||||
output-format = "full"
|
||||
|
||||
Reference in New Issue
Block a user