Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#9841)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.285](astral-sh/ruff-pre-commit@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 (सौगात) <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and skshetry authored Aug 22, 2023
1 parent 0342e4f commit 3783d65
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions dvc/commands/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')"
)


Expand Down
4 changes: 3 additions & 1 deletion dvc/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 5 additions & 9 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion dvc/pathspec_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)


Expand Down
2 changes: 1 addition & 1 deletion dvc/stage/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
)


Expand Down
4 changes: 2 additions & 2 deletions dvc/testing/tmp_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions tests/func/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
28 changes: 14 additions & 14 deletions tests/unit/command/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 3783d65

Please sign in to comment.