From 3783d65ddeafe57716d4c5a18ac8f20f333de530 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 15:22:57 +0545 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#9841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.285](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.282...v0.0.285) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix ruff issues --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Saugat Pachhai (सौगात) --- .pre-commit-config.yaml | 2 +- dvc/commands/remote.py | 4 ++-- dvc/exceptions.py | 2 +- dvc/ignore.py | 4 +++- dvc/output.py | 14 +++++--------- dvc/pathspec_math.py | 2 +- dvc/repo/plots/__init__.py | 4 ++-- dvc/stage/exceptions.py | 2 +- dvc/testing/tmp_dir.py | 4 ++-- tests/func/test_init.py | 7 ++----- tests/unit/command/test_diff.py | 28 ++++++++++++++-------------- tests/unit/utils/test_utils.py | 2 -- 12 files changed, 34 insertions(+), 41 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 305837a4c7..4b39bef26a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.0.282' + rev: 'v0.0.285' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/dvc/commands/remote.py b/dvc/commands/remote.py index 03dc430f27..1e3c4e5da5 100644 --- a/dvc/commands/remote.py +++ b/dvc/commands/remote.py @@ -30,8 +30,8 @@ def run(self): with self.config.edit(self.args.level) as conf: if self.args.name in conf["remote"] and not self.args.force: raise ConfigError( - "remote '{}' already exists. Use `-f|--force` to " - "overwrite it.".format(self.args.name) + f"remote '{self.args.name}' already exists. Use `-f|--force` to " + "overwrite it." ) conf["remote"][self.args.name] = {"url": self.args.url} diff --git a/dvc/exceptions.py b/dvc/exceptions.py index fd0a0b26e1..7623c31a44 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -196,7 +196,7 @@ class ETagMismatchError(DvcException): def __init__(self, etag, cached_etag): super().__init__( "ETag mismatch detected when copying file to cache! " - "(expected: '{}', actual: '{}')".format(etag, cached_etag) + f"(expected: '{etag}', actual: '{cached_etag}')" ) diff --git a/dvc/ignore.py b/dvc/ignore.py index 08b08d4184..852230339b 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -148,7 +148,9 @@ def __bool__(self): return bool(self.pattern_list) -CheckIgnoreResult = namedtuple("CheckIgnoreResult", ["file", "match", "patterns"]) +CheckIgnoreResult = namedtuple( # noqa: PYI024 + "CheckIgnoreResult", ["file", "match", "patterns"] +) def _no_match(path): diff --git a/dvc/output.py b/dvc/output.py index fa73c4ba09..ae8b303fb2 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -1142,7 +1142,7 @@ def _collect_used_dir_cache( if not force and not prompt.confirm(msg.format(self.fs_path)): raise CollectCacheError( # noqa: B904 "unable to fully collect used cache" - " without cache for directory '{}'".format(self) + f" without cache for directory '{self}'" ) return None @@ -1171,19 +1171,15 @@ def get_used_objs( # noqa: C901 if not self.hash_info: msg = ( - "Output '{}'({}) is missing version info. " + f"Output '{self}'({self.stage}) is missing version info. " "Cache for it will not be collected. " - "Use `dvc repro` to get your pipeline up to date.".format( - self, self.stage - ) + "Use `dvc repro` to get your pipeline up to date." ) if self.exists: msg += ( "\n" - "You can also use `dvc commit {stage.addressing}` " - "to associate existing '{out}' with {stage}.".format( - out=self, stage=self.stage - ) + f"You can also use `dvc commit {self.stage.addressing}` " + f"to associate existing '{self}' with {self.stage}." ) logger.warning(msg) return {} diff --git a/dvc/pathspec_math.py b/dvc/pathspec_math.py index 276f9ac299..8f252ac586 100644 --- a/dvc/pathspec_math.py +++ b/dvc/pathspec_math.py @@ -8,7 +8,7 @@ from dvc.utils import relpath -PatternInfo = namedtuple("PatternInfo", ["patterns", "file_info"]) +PatternInfo = namedtuple("PatternInfo", ["patterns", "file_info"]) # noqa: PYI024 def _not_ignore(rule): diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index 7fd0a47f70..4225e3a507 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -46,8 +46,8 @@ class PlotMetricTypeError(DvcException): def __init__(self, file): super().__init__( - "'{}' - file type error\n" - "Only JSON, YAML, CSV and TSV formats are supported.".format(file) + f"'{file}' - file type error\n" + "Only JSON, YAML, CSV and TSV formats are supported." ) diff --git a/dvc/stage/exceptions.py b/dvc/stage/exceptions.py index d1c867c318..1921440c1a 100644 --- a/dvc/stage/exceptions.py +++ b/dvc/stage/exceptions.py @@ -98,7 +98,7 @@ class StageNameUnspecified(DvcException): def __init__(self, file): super().__init__( "Stage name not provided." - "Please specify the name as: `{}:stage_name`".format(file.relpath) + f"Please specify the name as: `{file.relpath}:stage_name`" ) diff --git a/dvc/testing/tmp_dir.py b/dvc/testing/tmp_dir.py index 126145d0da..d0b00f0788 100644 --- a/dvc/testing/tmp_dir.py +++ b/dvc/testing/tmp_dir.py @@ -115,8 +115,8 @@ def close(self): def _require(self, name): if not hasattr(self, name): raise TypeError( - "Can't use {name} for this temporary dir. " - 'Did you forget to use "{name}" fixture?'.format(name=name) + f"Can't use {name} for this temporary dir. " + f'Did you forget to use "{name}" fixture?' ) # Bootstrapping methods diff --git a/tests/func/test_init.py b/tests/func/test_init.py index 7944d5b1a6..5e79a9a47d 100644 --- a/tests/func/test_init.py +++ b/tests/func/test_init.py @@ -113,10 +113,7 @@ def test_init_when_ignored_by_git(tmp_dir, scm, caplog): with caplog.at_level(logging.ERROR, logger="dvc"): assert main(["init"]) == 1 assert ( - "{dvc_dir} is ignored by your SCM tool. \n" + f"{tmp_dir / DvcRepo.DVC_DIR} is ignored by your SCM tool. \n" "Make sure that it's tracked, " - "for example, by adding '!.dvc' to .gitignore.".format( - dvc_dir=tmp_dir / DvcRepo.DVC_DIR - ) - in caplog.text + "for example, by adding '!.dvc' to .gitignore." in caplog.text ) diff --git a/tests/unit/command/test_diff.py b/tests/unit/command/test_diff.py index 25bbe7743b..a18b414c51 100644 --- a/tests/unit/command/test_diff.py +++ b/tests/unit/command/test_diff.py @@ -45,10 +45,10 @@ def test_default(mocker, capsys, dvc): " file\n" "\n" "Renamed:\n" - " data{sep}file_old -> data{sep}file_new\n" + f" data{os.path.sep}file_old -> data{os.path.sep}file_new\n" "\n" "files summary: 1 added, 1 renamed" - ).format(sep=os.path.sep) in capsys.readouterr()[0] + ) in capsys.readouterr()[0] def test_show_hash(mocker, capsys, dvc): @@ -252,14 +252,14 @@ def test_show_markdown(capsys): "|--------------|----------------------|\n" "| added | file |\n" "| deleted | zoo |\n" - "| deleted | data{sep} |\n" - "| deleted | data{sep}foo |\n" - "| deleted | data{sep}bar |\n" + f"| deleted | data{os.path.sep} |\n" + f"| deleted | data{os.path.sep}foo |\n" + f"| deleted | data{os.path.sep}bar |\n" "| renamed | file_old -> file_new |\n" "| modified | file |\n" "| not in cache | file2 |\n" "\n" - ).format(sep=os.path.sep) + ) def test_show_markdown_with_hash(capsys): @@ -289,14 +289,14 @@ def test_show_markdown_with_hash(capsys): "|--------------|--------------------|----------------------|\n" "| added | 00000000 | file |\n" "| deleted | 22222 | zoo |\n" - "| deleted | XXXXXXXX | data{sep} |\n" - "| deleted | 11111111 | data{sep}foo |\n" - "| deleted | 00000000 | data{sep}bar |\n" + f"| deleted | XXXXXXXX | data{os.path.sep} |\n" + f"| deleted | 11111111 | data{os.path.sep}foo |\n" + f"| deleted | 00000000 | data{os.path.sep}bar |\n" "| renamed | 11111111 | file_old -> file_new |\n" "| modified | AAAAAAAA..BBBBBBBB | file |\n" "| not in cache | 12345678 | file2 |\n" "\n" - ).format(sep=os.path.sep) + ) def test_show_markdown_hide_missing(capsys): @@ -321,13 +321,13 @@ def test_show_markdown_hide_missing(capsys): "|----------|----------------------|\n" "| added | file |\n" "| deleted | zoo |\n" - "| deleted | data{sep} |\n" - "| deleted | data{sep}foo |\n" - "| deleted | data{sep}bar |\n" + f"| deleted | data{os.path.sep} |\n" + f"| deleted | data{os.path.sep}foo |\n" + f"| deleted | data{os.path.sep}bar |\n" "| renamed | file_old -> file_new |\n" "| modified | file |\n" "\n" - ).format(sep=os.path.sep) + ) def test_hide_missing(mocker, capsys, dvc): diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 3db70ff0ac..a29e49a2d0 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -80,10 +80,8 @@ def test_resolve_output(inp, out, is_dir, expected, mocker): ["dvc.yaml:name", ("dvc.yaml", "name"), None], [":name", ("dvc.yaml", "name"), None], ["stage.dvc", ("stage.dvc", None), None], - ["dvc.yaml:name", ("dvc.yaml", "name"), None], ["../models/stage.dvc", ("../models/stage.dvc", None), "def"], [":name", ("default", "name"), "default"], - [":name", ("default", "name"), "default"], ["something.dvc:name", ("something.dvc", "name"), None], ["../something.dvc:name", ("../something.dvc", "name"), None], ["file", (None, "file"), None],