[pre-commit.ci] pre-commit autoupdate (#8869)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.223 → v0.0.230](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.223...v0.0.230)

* Update .pre-commit-config.yaml

* fix lint issues

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: skshetry <[email protected]>
Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
This commit is contained in:
pre-commit-ci[bot]
2023-01-26 14:24:09 +05:45
committed by GitHub
co-authored by skshetry Saugat Pachhai
parent b2c1c4dccd
commit 5165fb67a1
22 changed files with 41 additions and 41 deletions
+1 -2
View File
@@ -43,10 +43,9 @@ repos:
hooks:
- id: isort
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.223'
rev: 'v0.0.235'
hooks:
- id: ruff
args: ["--force-exclude"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
+1 -1
View File
@@ -105,7 +105,7 @@ def daemon(args):
Args:
args (list): list of arguments to append to `dvc daemon` command.
"""
daemonize(["daemon", "-q"] + args)
daemonize(["daemon", "-q", *args])
def daemonize(cmd: List[str]):
+2 -2
View File
@@ -74,7 +74,7 @@ def _merge_params(s_list):
if not isinstance(key, dict):
msg = "Only list of str/dict is supported. Got: "
msg += f"'{type(key).__name__}'."
raise ValueError(msg)
raise ValueError(msg) # noqa: TRY004
for k, params in key.items():
if k in wholly_tracked:
@@ -83,7 +83,7 @@ def _merge_params(s_list):
if not isinstance(params, list):
msg = "Expected list of params for custom params file "
msg += f"'{k}', got '{type(params).__name__}'."
raise ValueError(msg)
raise ValueError(msg) # noqa: TRY004
d[k].extend(params)
return d
+4 -2
View File
@@ -150,11 +150,13 @@ def _merge_data(s_list):
d[key].update({})
continue
if not isinstance(key, dict):
raise ValueError(f"'{type(key).__name__}' not supported.")
raise ValueError( # noqa: TRY004
f"'{type(key).__name__}' not supported."
)
for k, flags in key.items():
if not isinstance(flags, dict):
raise ValueError(
raise ValueError( # noqa: TRY004
f"Expected dict for '{k}', got: '{type(flags).__name__}'"
)
d[k].update(flags)
+1 -1
View File
@@ -228,7 +228,7 @@ class Container(Node, ABC): # noqa: B024
rem = rems[0]
if not isinstance(d, Container):
raise ValueError(
raise ValueError( # noqa: TRY004
f"{index} is a primitive value, cannot get '{rem}'"
)
return d.select(rem)
+1 -1
View File
@@ -146,7 +146,7 @@ class LocalCeleryQueue(BaseStashQueue):
if os.name == "nt":
daemonize(cmd)
else:
ManagedProcess.spawn(["dvc"] + cmd, wdir=self.wdir, name=name)
ManagedProcess.spawn(["dvc", *cmd], wdir=self.wdir, name=name)
def start_workers(self, count: int) -> int:
"""start some workers to process the queued tasks.
+1 -1
View File
@@ -72,7 +72,7 @@ def gc(
for repo in all_repos:
stack.enter_context(repo.lock)
for repo in all_repos + [self]:
for repo in [*all_repos, self]:
for obj_ids in repo.used_objs(
all_branches=all_branches,
with_deps=with_deps,
+1 -1
View File
@@ -22,7 +22,7 @@ def _make_cmd(executable, cmd):
return cmd
opts = {"zsh": ["--no-rcs"], "bash": ["--noprofile", "--norc"]}
name = os.path.basename(executable).lower()
return [executable] + opts.get(name, []) + ["-c", cmd]
return [executable, *opts.get(name, []), "-c", cmd]
def warn_if_fish(executable):
+1 -1
View File
@@ -53,7 +53,7 @@ def apply_diff(src, dest): # noqa: C901
elif value != dest[i]:
dest[i] = value
else:
raise AssertionError(
raise AssertionError( # noqa: TRY004
"Can't apply diff from {} to {}".format(
src.__class__.__name__, dest.__class__.__name__
)
+1 -1
View File
@@ -93,7 +93,7 @@ class YAMLSyntaxError(PrettyDvcException, YAMLFileCorruptedError):
exc = self.exc.__cause__
if not isinstance(exc, MarkedYAMLError):
raise ValueError("nothing to pretty-print here. :)")
raise ValueError("nothing to pretty-print here.") # noqa: TRY004
source = self.yaml_text.splitlines()
+3 -3
View File
@@ -161,13 +161,13 @@ line_length = 79
line-length = 79
target-version = "py38"
show-source = true
ignore = ["S101", "SIM105", "SIM108", "SIM110", "SIM111", "SIM117", "A003", "ARG002", "PLR2004"]
select = ["F", "E", "W", "C90", "UP", "YTT", "S", "BLE", "B", "A", "C4", "T10", "ISC", "ICN", "T20", "PT003", "PT008", "PT009", "PT010", "PT015", "PT016", "PT017", "PT020", "PT021", "PT024", "PT025", "PT026", "Q", "RET501", "RET504", "SIM", "ARG", "TID", "PGH", "PLC", "PLE", "PLR", "PLW", "PIE", "RUF"]
ignore = ["S101", "SIM105", "SIM108", "SIM110", "SIM111", "SIM117", "A003", "ARG002", "PLR2004", "RUF005"]
select = ["F", "E", "W", "C90", "UP", "YTT", "S", "BLE", "B", "A", "C4", "T10", "ISC", "ICN", "T20", "PT003", "PT008", "PT009", "PT010", "PT015", "PT016", "PT017", "PT020", "PT021", "PT024", "PT025", "PT026", "Q", "RET501", "RET504", "SIM", "ARG", "TID", "PGH", "PLC", "PLE", "PLR", "PLW", "PIE", "INP", "TRY004", "TRY201", "RUF"]
# external flake8 codes that should be preserved
external = ["B301", "B024", "C901", "E302", "F401", "W601"]
[tool.ruff.per-file-ignores]
"scripts/**/*.py" = ["T201"]
"scripts/**/*.py" = ["T201", "INP001"]
[tool.ruff.flake8-pytest-style]
fixture-parentheses = false
View File
+1 -1
View File
@@ -65,7 +65,7 @@ def test_check_ignore_non_matching(tmp_dir, dvc, non_matching, caplog, capsys):
],
)
def test_check_ignore_error_args_cases(tmp_dir, dvc, args, caplog):
assert main(["check-ignore"] + args) == 255
assert main(["check-ignore", *args]) == 255
assert "Having any troubles?" not in caplog.text
+4 -4
View File
@@ -129,7 +129,7 @@ def test_config_get(tmp_dir, dvc, capsys, caplog, args, ret, msg):
)
)
assert main(["config"] + args) == ret
assert main(["config", *args]) == ret
text = caplog.text if ret else capsys.readouterr()[0]
assert msg in text
@@ -143,7 +143,7 @@ def test_config_get(tmp_dir, dvc, capsys, caplog, args, ret, msg):
],
)
def test_config_get_in_non_dvc_repo(tmp_dir, caplog, args, ret):
assert main(["config"] + args) == ret
assert main(["config", *args]) == ret
if ret != 0:
out = caplog.text
assert "Not inside a DVC repo" in out
@@ -199,7 +199,7 @@ def test_config_list(tmp_dir, dvc, capsys):
],
)
def test_config_list_in_non_dvc_repo(tmp_dir, caplog, args, ret):
assert main(["config"] + args) == ret
assert main(["config", *args]) == ret
if ret != 0:
out = caplog.text
assert "Not inside a DVC repo" in out
@@ -210,7 +210,7 @@ def test_config_list_in_non_dvc_repo(tmp_dir, caplog, args, ret):
)
def test_list_bad_args(tmp_dir, dvc, caplog, args):
caplog.clear()
assert main(["config", "--list"] + args) == 1
assert main(["config", "--list", *args]) == 1
assert (
"-l/--list can't be used together with any of these options: "
"-u/--unset, name, value"
+6 -6
View File
@@ -39,7 +39,7 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
# FIXME check status output
oids_exist = mocker.spy(LocalHashFileDB, "oids_exist")
assert main(["push"] + args) == 0
assert main(["push", *args]) == 0
assert os.path.exists(cache)
assert os.path.isfile(cache)
assert os.path.isfile(cache_dir)
@@ -52,7 +52,7 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
dvc.odb.local.clear()
oids_exist.reset_mock()
assert main(["fetch"] + args) == 0
assert main(["fetch", *args]) == 0
assert os.path.exists(cache)
assert os.path.isfile(cache)
assert os.path.isfile(cache_dir)
@@ -64,7 +64,7 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
oids_exist.reset_mock()
assert main(["pull"] + args) == 0
assert main(["pull", *args]) == 0
assert os.path.exists(cache)
assert os.path.isfile(cache)
assert os.path.isfile(cache_dir)
@@ -88,14 +88,14 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
_list_oids_traverse = mocker.spy(HashFileDB, "_list_oids_traverse")
# NOTE: check if remote gc works correctly on directories
assert main(["gc", "-cw", "-f"] + args) == 0
assert main(["gc", "-cw", "-f", *args]) == 0
assert _list_oids_traverse.called
assert all(
_kwargs["jobs"] == 2 for (_args, _kwargs) in oids_exist.call_args_list
)
shutil.move(dvc.odb.local.path, dvc.odb.local.path + ".back")
assert main(["fetch"] + args) == 0
assert main(["fetch", *args]) == 0
assert oids_exist.called
assert all(
@@ -104,7 +104,7 @@ def test_cloud_cli(tmp_dir, dvc, remote, mocker):
)
oids_exist.reset_mock()
assert main(["pull", "-f"] + args) == 0
assert main(["pull", "-f", *args]) == 0
assert os.path.exists(cache)
assert os.path.isfile(cache)
assert os.path.isfile(cache_dir)
+5 -7
View File
@@ -42,13 +42,11 @@ def create_dvc_pipeline(tmp_dir, dvc):
tmp_dir.scm_gen({"script.py": script}, commit="init")
tmp_dir.dvc_gen({"dep": "content"}, commit="init dvc")
dvc.run(
**{
"cmd": "python script.py {}".format(os.path.join("out", "file")),
"outs": [os.path.join("out", "file")],
"deps": ["dep"],
"fname": "out.dvc",
"single_stage": True,
}
cmd="python script.py {}".format(os.path.join("out", "file")),
outs=[os.path.join("out", "file")],
deps=["dep"],
fname="out.dvc",
single_stage=True,
)
tmp_dir.scm_add(["out.dvc"], commit="run")
shutil.rmtree("out")
+1
View File
@@ -1,2 +1,3 @@
extend = "../pyproject.toml"
extend-select = ["RUF005"]
extend-ignore = ["S", "RUF001", "ARG001", "ARG002"]
+1 -1
View File
@@ -118,7 +118,7 @@ def test_list(tmp_dir, mocker, show_origin):
from dvc.ui import ui
tmp_dir.gen(DATA)
cli_args = parse_args(["machine", "list"] + show_origin + ["foo"])
cli_args = parse_args(["machine", "list", *show_origin, "foo"])
assert cli_args.func == CmdMachineList
cmd = cli_args.func(cli_args)
if show_origin:
+1 -1
View File
@@ -629,7 +629,7 @@ def test_walk_nested_subrepos(tmp_dir, dvc, scm, traverse_subrepos):
extras = {".gitignore"} # these files are always there
expected = {}
for repo_dir in subrepos + [tmp_dir]:
for repo_dir in [*subrepos, tmp_dir]:
base = os.path.basename(repo_dir)
scm_files = fs_structure(base)
dvc_files = dvc_structure(base)
View File
@@ -209,7 +209,7 @@ def test_order_deps_outs(dvc, typ):
stage = create_stage(PipelineStage, dvc, **kwargs, **extra)
assert typ not in to_pipeline_file(stage)["something"]
assert (
list(to_pipeline_file(stage)["something"].keys())
== ["cmd"] + all_types
)
assert list(to_pipeline_file(stage)["something"].keys()) == [
"cmd",
*all_types,
]
+1 -1
View File
@@ -20,7 +20,7 @@ def test_hook_is_called(tmp_dir, erepo_dir, mocker):
for repo in subrepos:
make_subrepo(repo, erepo_dir.scm)
for repo in subrepos + [erepo_dir]:
for repo in [*subrepos, erepo_dir]:
with repo.chdir():
repo.scm_gen("foo", "foo", commit=f"git add {repo}/foo")
repo.dvc_gen("bar", "bar", commit=f"dvc add {repo}/bar")