Skip to content

Commit

Permalink
ruff: enable a few more rules, and merge tests' config with the main …
Browse files Browse the repository at this point in the history
…config (#9739)
  • Loading branch information
skshetry authored Jul 15, 2023
1 parent eb06351 commit ea5f7d4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dvc/commands/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def run(self):
)

if not self.args.force and not ui.confirm(statement):
raise DvcException(
raise DvcException( # noqa: TRY301
"cannot destroy without a confirmation from the user."
" Use `-f` to force."
)
Expand Down
4 changes: 3 additions & 1 deletion dvc/repo/experiments/queue/tempdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def _reproduce_entry(
message=message,
)
if not exec_result.exp_hash:
raise DvcException(f"Failed to reproduce experiment '{rev[:7]}'")
raise DvcException( # noqa: TRY301
f"Failed to reproduce experiment '{rev[:7]}'"
)
if exec_result.ref_info:
results[rev].update(
self.collect_executor(self.repo.experiments, executor, exec_result)
Expand Down
4 changes: 3 additions & 1 deletion dvc/repo/experiments/queue/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def _reproduce_entry(
message=kwargs.get("message"),
)
if not exec_result.exp_hash:
raise DvcException(f"Failed to reproduce experiment '{rev[:7]}'")
raise DvcException( # noqa: TRY301
f"Failed to reproduce experiment '{rev[:7]}'"
)
if exec_result.ref_info:
results[rev].update(
self.collect_executor(self.repo.experiments, executor, exec_result)
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def collect(
if "workspace" in revs:
# reorder revs to match repo.brancher ordering
revs.remove("workspace")
revs = ["workspace"] + revs
revs = ["workspace", *revs]
for rev in revs:
with switch_repo(self.repo, rev) as (repo, _):
res: Dict = {}
Expand Down
2 changes: 1 addition & 1 deletion dvc/utils/threadpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def shutdown(self, wait=True, *, cancel_futures=False):
if sys.version_info > (3, 9): # pylint: disable=no-else-return
# pylint: disable=unexpected-keyword-arg
return super().shutdown(wait=wait, cancel_futures=cancel_futures)
else:
else: # noqa: RET505
with self._shutdown_lock:
self._shutdown = True
if cancel_futures:
Expand Down
15 changes: 12 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ lint = [
"pylint==2.17.4",
"types-colorama",
"types-psutil",
"types-pyinstaller",
"types-requests",
"types-tabulate",
"types-toml",
"types-tqdm",
"types-pyinstaller",
]
oss = ["dvc-oss==2.19"]
s3 = ["dvc-s3==2.23.0"]
Expand Down Expand Up @@ -268,8 +268,16 @@ ignored-argument-names = "_.*|args|kwargs"
[tool.ruff]
# external flake8 codes that should be preserved
external = ["B301", "C901", "E302", "W601"]
ignore = ["N818", "S101", "PT004", "PT007", "PT019", "SIM105", "SIM108", "SIM110", "SIM117", "TRY003", "TRY200", "TRY300", "TRY301", "PLR2004", "PLW2901", "RUF005", "RUF012"]
select = ["F", "E", "W", "C90", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10", "EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET501", "RET504", "SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY", "FLY", "RUF"]
ignore = [
"N818", "S101", "PT004", "PT007", "RET501", "RET502", "RET503", "SIM105", "SIM108",
"SIM117", "TRY003", "TRY200", "TRY300", "PLR2004", "PLW2901", "RUF012"
]
select = [
"F", "E", "W", "C90", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
"FLY", "PERF101", "RUF",
]
show-source = true

[tool.ruff.flake8-pytest-style]
Expand Down Expand Up @@ -298,6 +306,7 @@ ignore-names = ["M", "SCM"]
"dvc/commands/**" = ["N806"]
"dvc/testing/**" = ["ARG002"]
"dvc/testing/benchmarks/**" = ["ARG001"]
"tests/**" = ["S", "ARG001", "ARG002", "TRY002", "TRY301"]

[tool.ruff.pylint]
max-args = 10
Expand Down
3 changes: 0 additions & 3 deletions tests/ruff.toml

This file was deleted.

0 comments on commit ea5f7d4

Please sign in to comment.