mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
use ruff formatter (#10081)
Replaces black with ruff-formatter, and isort with ruff.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
[flake8]
|
||||
max_line_length = 88
|
||||
extend-ignore=
|
||||
E501
|
||||
# Whitespace before ':'
|
||||
E203
|
||||
# Line break occurred before a binary operator
|
||||
|
||||
+2
-11
@@ -17,25 +17,16 @@ repos:
|
||||
args: ['--assume-in-merge']
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
exclude: "dvc/_debug.py"
|
||||
- id: end-of-file-fixer
|
||||
- id: mixed-line-ending
|
||||
- id: sort-simple-yaml
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 23.9.1
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.0.291'
|
||||
rev: 'v0.1.5'
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.2.5
|
||||
hooks:
|
||||
|
||||
@@ -106,9 +106,7 @@ class CmdDataStatus(CmdBase):
|
||||
return 0
|
||||
|
||||
def run(self) -> int:
|
||||
with log_durations(
|
||||
logger.trace, "in data_status" # type: ignore[attr-defined]
|
||||
):
|
||||
with log_durations(logger.trace, "in data_status"): # type: ignore[attr-defined]
|
||||
status = self.repo.data_status(
|
||||
granular=self.args.granular,
|
||||
untracked_files=self.args.untracked_files,
|
||||
|
||||
@@ -36,9 +36,7 @@ def apply(repo: "Repo", rev: str, **kwargs): # noqa: C901
|
||||
(
|
||||
exp_ref_info,
|
||||
queue_entry,
|
||||
) = exps.celery_queue.get_ref_and_entry_by_names(
|
||||
rev
|
||||
)[rev]
|
||||
) = exps.celery_queue.get_ref_and_entry_by_names(rev)[rev]
|
||||
if exp_ref_info:
|
||||
exp_rev = repo.scm.get_ref(str(exp_ref_info))
|
||||
elif queue_entry:
|
||||
|
||||
@@ -148,7 +148,10 @@ class TempDirExecutor(BaseLocalExecutor):
|
||||
conf_obj.write(fobj)
|
||||
|
||||
def init_cache(
|
||||
self, repo: "Repo", rev: str, run_cache: bool = True # noqa: ARG002
|
||||
self,
|
||||
repo: "Repo",
|
||||
rev: str, # noqa: ARG002
|
||||
run_cache: bool = True, # noqa: ARG002
|
||||
):
|
||||
"""Initialize DVC cache."""
|
||||
self._update_config({"cache": {"dir": repo.cache.local_cache_dir}})
|
||||
|
||||
@@ -237,7 +237,9 @@ def docker_services(
|
||||
|
||||
try:
|
||||
subprocess.check_output( # nosec B607, B602,
|
||||
"docker ps", stderr=subprocess.STDOUT, shell=True # noqa: S602, S607
|
||||
"docker ps", # noqa: S607
|
||||
stderr=subprocess.STDOUT,
|
||||
shell=True, # noqa: S602
|
||||
)
|
||||
except subprocess.CalledProcessError as err:
|
||||
out = (err.output or b"").decode("utf-8")
|
||||
@@ -246,7 +248,9 @@ def docker_services(
|
||||
try:
|
||||
cmd = "docker-compose version"
|
||||
subprocess.check_output(
|
||||
cmd, stderr=subprocess.STDOUT, shell=True # nosec B602 # noqa: S602
|
||||
cmd,
|
||||
stderr=subprocess.STDOUT,
|
||||
shell=True, # nosec B602 # noqa: S602
|
||||
)
|
||||
except subprocess.CalledProcessError as err:
|
||||
out = (err.output or b"").decode("utf-8")
|
||||
|
||||
@@ -9,9 +9,7 @@ if os.path.isfile(sys.argv[1]):
|
||||
shutil.copyfile(sys.argv[1], sys.argv[2])
|
||||
else:
|
||||
shutil.copytree(sys.argv[1], sys.argv[2])
|
||||
""".replace(
|
||||
"\r\n", "\n"
|
||||
)
|
||||
""".replace("\r\n", "\n")
|
||||
|
||||
|
||||
def _add_script(tmp_dir, path, contents=""):
|
||||
|
||||
+1
-3
@@ -57,9 +57,7 @@ class Table(RichTable):
|
||||
If table is still too wide after collapsing, rich's automatic overflow
|
||||
handling will be used.
|
||||
"""
|
||||
collapsible = [
|
||||
column.collapse for column in self.columns # type: ignore[attr-defined]
|
||||
]
|
||||
collapsible = [column.collapse for column in self.columns] # type: ignore[attr-defined]
|
||||
total_width = sum(widths)
|
||||
excess_width = total_width - max_width
|
||||
if any(collapsible):
|
||||
|
||||
+2
-6
@@ -143,10 +143,6 @@ namespaces = false
|
||||
[tool.setuptools_scm]
|
||||
write_to = "dvc/_dvc_version.py"
|
||||
|
||||
[tool.isort]
|
||||
known_first_party = ["dvc", "dvc_data", "dvc_objects", "dvc_render", "dvc_task", "tests"]
|
||||
profile = "black"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-ra --cov-config pyproject.toml --dist worksteal"
|
||||
filterwarnings = [
|
||||
@@ -251,11 +247,11 @@ ignore-words-list = "ba,datas,fo,uptodate,cachable,falsy"
|
||||
# external flake8 codes that should be preserved
|
||||
external = ["B301", "C901", "E302", "W601"]
|
||||
ignore = [
|
||||
"N818", "S101", "PT004", "PT007", "RET501", "RET502", "RET503", "SIM105", "SIM108",
|
||||
"N818", "S101", "ISC001", "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",
|
||||
"F", "E", "W", "C90", "I", "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",
|
||||
|
||||
@@ -93,7 +93,8 @@ def test_subdir_init_no_option(tmp_dir, scm, monkeypatch, caplog):
|
||||
"{} is not tracked by any supported SCM tool (e.g. Git). "
|
||||
"Use `--no-scm` if you don't want to use any SCM or "
|
||||
"`--subdir` if initializing inside a subdirectory of a parent SCM "
|
||||
"repository.".format(os.fspath(tmp_dir / "subdir")) in caplog.text
|
||||
"repository.".format(os.fspath(tmp_dir / "subdir"))
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@ MAPPING_VALUES_NOT_ALLOWED_OUTPUT = """\
|
||||
'./dvc.yaml' is invalid.
|
||||
|
||||
Mapping values are not allowed {}, in line 3, column 8
|
||||
3 │ cmd: python script.py""".format(
|
||||
"in this context" if ruamel_clib else "here"
|
||||
)
|
||||
3 │ cmd: python script.py""".format("in this context" if ruamel_clib else "here")
|
||||
|
||||
|
||||
NO_HYPHEN_INDICATOR_IN_BLOCK = """\
|
||||
|
||||
+2
-6
@@ -14,9 +14,7 @@ from pathlib import Path
|
||||
|
||||
with Path(sys.argv[1]).open("a+", encoding="utf-8") as f:
|
||||
f.write("foo")
|
||||
""".replace(
|
||||
"\r\n", "\n"
|
||||
),
|
||||
""".replace("\r\n", "\n"),
|
||||
)
|
||||
|
||||
|
||||
@@ -34,7 +32,5 @@ import sys
|
||||
for file in sys.argv[1:]:
|
||||
with open(file) as f, open(file +"-1","w+") as w:
|
||||
w.write(f.readline())
|
||||
""".replace(
|
||||
"\r\n", "\n"
|
||||
),
|
||||
""".replace("\r\n", "\n"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user