Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (iterative#10443)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Jun 3, 2024
1 parent 0e38ccc commit c741562
Show file tree
Hide file tree
Showing 43 changed files with 92 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion dvc/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dvc/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def __init__(self, args: Any):

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):
Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def display(cls, name: str, dataset: "Dataset", action: str = "Adding"):
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 "", ")")
Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _html_template_path(self):
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
Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion dvc/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def row_from_dict(self, d: Mapping[str, "CellT"]) -> None:
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)
Expand Down
2 changes: 1 addition & 1 deletion dvc/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dvc/dependency/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dvc/fs/dvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def info(self, path, **kwargs):
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)
Expand Down
8 changes: 4 additions & 4 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def __init__( # noqa: PLR0913
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

Expand Down Expand Up @@ -902,7 +902,7 @@ def verify_metric(self):
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:
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def get_used_objs( # noqa: PLR0911
logger.warning(msg)
return {}

obj: Optional["HashFile"]
obj: Optional[HashFile]
if self.is_dir_checksum:
obj = self._collect_used_dir_cache(**kwargs)
else:
Expand Down Expand Up @@ -1353,7 +1353,7 @@ def add( # noqa: C901
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(
Expand Down
4 changes: 2 additions & 2 deletions dvc/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,10 @@ def normalized_iterable(self) -> dict[str, "DictStrAny"]:
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
Expand Down
8 changes: 4 additions & 4 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ def __init__( # noqa: PLR0915, PLR0913
# 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()
Expand Down
6 changes: 2 additions & 4 deletions dvc/repo/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,12 @@ def get_rev(

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
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def __str__(self) -> str:

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))
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def reproduce_one(
**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)
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/experiments/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions dvc/repo/experiments/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {}
Expand Down
6 changes: 3 additions & 3 deletions dvc/repo/experiments/executor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def info(self) -> "ExecutorInfo":
@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,
Expand Down Expand Up @@ -470,7 +470,7 @@ def reproduce(
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:
Expand Down Expand Up @@ -559,7 +559,7 @@ def _repro_commit(
)

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:
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/executor/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def __init__(self, *args, **kwargs):
@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)
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/experiments/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/experiments/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions dvc/repo/experiments/queue/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ def get_ref_and_entry_by_names(
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()
)
Expand Down Expand Up @@ -613,7 +613,7 @@ def collect_success_executors(
"""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
Expand Down
18 changes: 9 additions & 9 deletions dvc/repo/experiments/queue/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))

Expand All @@ -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)
Expand Down
Loading

0 comments on commit c741562

Please sign in to comment.