From 7e75b0616fe26d3176688c2213d0aa0adb1735c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 07:34:46 +0545 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#10635) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- dvc/api/__init__.py | 2 +- dvc/daemon.py | 2 +- dvc/fs/__init__.py | 2 +- dvc/output.py | 2 +- dvc/repo/du.py | 2 +- dvc/repo/experiments/queue/base.py | 4 ++-- dvc/repo/experiments/remove.py | 2 +- dvc/repo/ls.py | 6 +++--- dvc/utils/serialize/_common.py | 2 +- pyproject.toml | 4 ++-- tests/func/test_import.py | 4 ++-- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eff27cb28..377983587 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: sort-simple-yaml - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.7.4' + rev: 'v0.8.0' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/dvc/api/__init__.py b/dvc/api/__init__.py index 3bc5634f8..f9a892fa0 100644 --- a/dvc/api/__init__.py +++ b/dvc/api/__init__.py @@ -1,7 +1,7 @@ from dvc.fs.dvc import _DVCFileSystem as DVCFileSystem from .artifacts import artifacts_show -from .data import get_url, open, read +from .data import get_url, open, read # noqa: A004 from .dataset import get as get_dataset from .experiments import exp_save, exp_show from .scm import all_branches, all_commits, all_tags diff --git a/dvc/daemon.py b/dvc/daemon.py index 90deebd81..432cc2ce5 100644 --- a/dvc/daemon.py +++ b/dvc/daemon.py @@ -164,7 +164,7 @@ def _spawn( return _detached_subprocess(executable + args, env=env, **kwargs) -def daemonize(args: list[str], executable: Union[None, str, list[str]] = None) -> None: +def daemonize(args: list[str], executable: Union[str, list[str], None] = None) -> None: if os.name not in ("posix", "nt"): return diff --git a/dvc/fs/__init__.py b/dvc/fs/__init__.py index c89f20343..cf3998a69 100644 --- a/dvc/fs/__init__.py +++ b/dvc/fs/__init__.py @@ -20,7 +20,7 @@ from dvc_objects.fs import ( # noqa: F401 system, utils, ) -from dvc_objects.fs.base import AnyFSPath, FileSystem # noqa: F401, TCH001 +from dvc_objects.fs.base import AnyFSPath, FileSystem # noqa: F401, TC001 from dvc_objects.fs.errors import ( # noqa: F401 AuthError, ConfigError, diff --git a/dvc/output.py b/dvc/output.py index 00acb4ca7..48acf499b 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -431,7 +431,7 @@ class Output: self.meta.nfiles = len(self.files) self.meta.size = sum(filter(None, (f.get("size") for f in self.files))) self.meta.remote = first(f.get("remote") for f in self.files) - elif self.meta.nfiles or self.hash_info and self.hash_info.isdir: + elif self.meta.nfiles or (self.hash_info and self.hash_info.isdir): self.meta.isdir = True if not self.hash_info and self.hash_name not in ("md5", "md5-dos2unix"): md5 = getattr(self.meta, "md5", None) diff --git a/dvc/repo/du.py b/dvc/repo/du.py index 99eaf6394..e274ff3b2 100644 --- a/dvc/repo/du.py +++ b/dvc/repo/du.py @@ -6,7 +6,7 @@ def du( path: Optional[str] = None, rev: Optional[str] = None, summarize: bool = False, - config: Union[None, dict[str, Any], str] = None, + config: Union[dict[str, Any], str, None] = None, remote: Optional[str] = None, remote_config: Optional[dict] = None, ): diff --git a/dvc/repo/experiments/queue/base.py b/dvc/repo/experiments/queue/base.py index ab686fbb2..527673cd1 100644 --- a/dvc/repo/experiments/queue/base.py +++ b/dvc/repo/experiments/queue/base.py @@ -609,9 +609,9 @@ class BaseStashQueue(ABC): result[exp_name] = entry_name_dict[exp_name] continue if self.scm.is_sha(exp_name): - for rev in entry_rev_dict: + for rev, entry in entry_rev_dict.items(): if rev.startswith(exp_name.lower()): - result[exp_name] = entry_rev_dict[rev] + result[exp_name] = entry break return result diff --git a/dvc/repo/experiments/remove.py b/dvc/repo/experiments/remove.py index bcc2511cf..ef6ee086a 100644 --- a/dvc/repo/experiments/remove.py +++ b/dvc/repo/experiments/remove.py @@ -24,7 +24,7 @@ logger = logger.getChild(__name__) @scm_context def remove( # noqa: C901, PLR0912 repo: "Repo", - exp_names: Union[None, str, list[str]] = None, + exp_names: Union[str, list[str], None] = None, rev: Optional[Union[list[str], str]] = None, all_commits: bool = False, num: int = 1, diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py index 7717c11b9..57e799d9e 100644 --- a/dvc/repo/ls.py +++ b/dvc/repo/ls.py @@ -8,7 +8,7 @@ if TYPE_CHECKING: def _open_repo( url: str, rev: Optional[str] = None, - config: Union[None, dict[str, Any], str] = None, + config: Union[dict[str, Any], str, None] = None, remote: Optional[str] = None, remote_config: Optional[dict] = None, ): @@ -49,7 +49,7 @@ def ls( rev: Optional[str] = None, recursive: Optional[bool] = None, dvc_only: bool = False, - config: Union[None, dict[str, Any], str] = None, + config: Union[dict[str, Any], str, None] = None, remote: Optional[str] = None, remote_config: Optional[dict] = None, maxdepth: Optional[int] = None, @@ -90,7 +90,7 @@ def ls_tree( path: Optional[str] = None, rev: Optional[str] = None, dvc_only: bool = False, - config: Union[None, dict[str, Any], str] = None, + config: Union[dict[str, Any], str, None] = None, remote: Optional[str] = None, remote_config: Optional[dict] = None, maxdepth: Optional[int] = None, diff --git a/dvc/utils/serialize/_common.py b/dvc/utils/serialize/_common.py index e9eafd513..12b085fa1 100644 --- a/dvc/utils/serialize/_common.py +++ b/dvc/utils/serialize/_common.py @@ -33,7 +33,7 @@ class LoaderFn(Protocol): def __call__(self, path: "StrPath", fs: Optional["FileSystem"] = None) -> Any: ... -ReadType = Union[bytes, None, str] +ReadType = Union[bytes, str, None] ParserFn = Callable[[ReadType, "StrPath"], dict] diff --git a/pyproject.toml b/pyproject.toml index 903c7f577..3bc70fa2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -270,8 +270,8 @@ ignore = [ select = [ "F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "DTZ", "T10", "EXE", "ISC", "ICN", "LOG", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", - "SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY", - "FLY", "PERF", "FURB", "RUF", "RUF022", "RUF023", "RUF024", "RUF026", "RUF027", "RUF029", "RUF030", + "SLOT", "SIM", "TID", "TC", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY", + "FLY", "PERF", "FURB", "RUF", "RUF027", "RUF029", "RUF034", "RUF036", ] preview = true explicit-preview-rules = true diff --git a/tests/func/test_import.py b/tests/func/test_import.py index 47fdd66cc..cd4189592 100644 --- a/tests/func/test_import.py +++ b/tests/func/test_import.py @@ -12,7 +12,7 @@ from dvc.scm import Git from dvc.stage.exceptions import StagePathNotFoundError from dvc.testing.tmp_dir import make_subrepo from dvc.utils.fs import remove -from dvc_data.hashfile import hash +from dvc_data.hashfile import hash as _hash from dvc_data.index.index import DataIndex, DataIndexDirError @@ -747,7 +747,7 @@ def test_import_no_hash( with erepo_dir.chdir(): erepo_dir.dvc_gen(files, commit="create foo") - file_md5_spy = mocker.spy(hash, "file_md5") + file_md5_spy = mocker.spy(_hash, "file_md5") index_info_spy = mocker.spy(DataIndex, "info") name = next(iter(files))