Skip to content

Commit

Permalink
update ruff to 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Aug 15, 2024
1 parent fd3b43d commit e131122
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.5.7'
rev: 'v0.6.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _show_ascii(graph: "DiGraph"):

ret = []
for pipeline in pipelines:
ret.append(draw(pipeline.nodes, pipeline.edges))
ret.append(draw(pipeline.nodes, pipeline.edges)) # noqa: PERF401

return "\n".join(ret)

Expand Down
2 changes: 1 addition & 1 deletion dvc/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _get_supported_remotes():
if not fs_cls.get_missing_deps():
dependencies = []
for requirement in fs_cls.REQUIRES:
dependencies.append(
dependencies.append( # noqa: PERF401
f"{requirement} = {importlib_metadata.version(requirement)}"
)

Expand Down
2 changes: 1 addition & 1 deletion dvc/render/converter/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _lists(blob: Union[dict, list]) -> Iterable[list]:
if isinstance(blob, list):
yield blob
else:
for _, value in blob.items():
for value in blob.values():
if isinstance(value, dict):
yield from _lists(value)
elif isinstance(value, list):
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _reproduce_queue(
exec_results = queue.reproduce(copy_paths=copy_paths, message=message)

results: dict[str, str] = {}
for _, exp_result in exec_results.items():
for exp_result in exec_results.values():
results.update(exp_result)
return results

Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/executor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def save(
stages = []
if targets:
for target in targets:
stages.append(
stages.append( # noqa: PERF401
dvc.commit(
target, recursive=recursive, force=True, relink=False
)
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def pull( # noqa: C901
rev_dict = iter_revs(repo.scm, rev, num)
rev_set = set(rev_dict.keys())
ref_info_dict = exp_refs_by_baseline(repo.scm, rev_set, git_remote)
for _, ref_info_list in ref_info_dict.items():
for ref_info_list in ref_info_dict.values():
exp_ref_set.update(ref_info_list)

pull_result = _pull(repo, git_remote, exp_ref_set, force)
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def exp_refs_from_rev(scm: "Git", rev: list[str], num: int = 1) -> set["ExpRefIn
rev_dict = iter_revs(scm, rev, num)
rev_set = set(rev_dict.keys())
ref_info_dict = exp_refs_by_baseline(scm, rev_set)
for _, ref_info_list in ref_info_dict.items():
for ref_info_list in ref_info_dict.values():
exp_ref_set.update(ref_info_list)
return exp_ref_set

Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/queue/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def wait_for_start(self, entry: QueueEntry, sleep_interval: float = 0.001) -> No
def _get_running_task_ids(self) -> set[str]:
running_task_ids: set[str] = set()
active_workers = self.worker_status()
for _, tasks in active_workers.items():
for tasks in active_workers.values():
task = first(tasks)
if task:
running_task_ids.add(task["id"])
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/queue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_remote_executor_refs(scm: "Git", remote_url: str) -> list[str]:
refs = []
for ref in iter_remote_refs(scm, remote_url, base=EXPS_NAMESPACE):
if not ref.startswith(EXEC_NAMESPACE) and ref != EXPS_STASH:
refs.append(ref)
refs.append(ref) # noqa: PERF401
return refs


Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _resolve_exp_by_baseline(
rev_dict = iter_revs(repo.scm, rev, num)
rev_set = set(rev_dict.keys())
ref_info_dict = exp_refs_by_baseline(repo.scm, rev_set, git_remote)
for _, ref_info_list in ref_info_dict.items():
for ref_info_list in ref_info_dict.values():
for ref_info in ref_info_list:
commit_ref_dict[ref_info.name] = ref_info
return commit_ref_dict
Expand Down
4 changes: 2 additions & 2 deletions dvc/stage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ def _get_stage_files(stage: "Stage") -> list[str]:
and dep.is_in_repo
and not stage.repo.dvcfs.isdvc(stage.repo.dvcfs.from_os_path(str(dep)))
):
ret.append(relpath(dep.fs_path))
ret.append(relpath(dep.fs_path)) # noqa: PERF401

for out in stage.outs:
if not out.use_scm_ignore and out.is_in_repo:
ret.append(relpath(out.fs_path))
ret.append(relpath(out.fs_path)) # noqa: PERF401
return ret
2 changes: 1 addition & 1 deletion dvc/testing/path_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PathInfo(pathlib.PurePath, _BasePath):

def __new__(cls, *args):
if cls is PathInfo:
cls = WindowsPathInfo if os.name == "nt" else PosixPathInfo
cls = WindowsPathInfo if os.name == "nt" else PosixPathInfo # noqa: PLW0642

return cls._from_parts(args) # type: ignore[attr-defined]

Expand Down
2 changes: 1 addition & 1 deletion dvc/testing/tmp_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def config(self):

def __new__(cls, *args, **kwargs):
if cls is TmpDir:
cls = WindowsTmpDir if os.name == "nt" else PosixTmpDir
cls = WindowsTmpDir if os.name == "nt" else PosixTmpDir # noqa: PLW0642

# init parameter and `_init` method has been removed in Python 3.10.
kw = {"init": False} if sys.version_info < (3, 10) else {}
Expand Down
2 changes: 1 addition & 1 deletion dvc/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def env2bool(var, undefined=False):
var = os.getenv(var, None)
if var is None:
return undefined
return bool(re.search("1|y|yes|true", var, flags=re.I))
return bool(re.search("1|y|yes|true", var, flags=re.IGNORECASE))


def resolve_output(inp: str, out: Optional[str], force=False) -> str:
Expand Down
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,19 @@ show-fixes = true

[tool.ruff.lint]
ignore = [
"N818", "S101", "ISC001", "PT004", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117",
"TRY003", "TRY300", "PLR2004", "PLW2901", "LOG007",
"N818", "S101", "ISC001", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117",
"TRY003", "TRY300", "PERF203", "PLR2004", "PLW2901", "LOG007",
]
select = [
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "DTZ", "T10",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
"EXE", "ISC", "ICN", "LOG", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
"FLY", "PERF101", "LOG", "RUF", "RUF022", "RUF023", "RUF024", "RUF025", "RUF026", "RUF027"
"FLY", "PERF", "FURB", "RUF", "RUF022", "RUF023", "RUF024", "RUF026", "RUF027", "RUF029", "RUF030",
]
preview = true
explicit-preview-rules = true

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
parametrize-names-type = "csv"
raises-extend-require-match-for = ["dvc.exceptions.DvcException", "dvc.scm.SCMError", "scmrepo.exceptions.SCMError"]

Expand All @@ -305,4 +303,4 @@ max-args = 10
"dvc/commands/**" = ["N806"]
"dvc/testing/**" = ["ARG002"]
"dvc/testing/benchmarks/**" = ["ARG001"]
"tests/**" = ["S", "ARG001", "ARG002", "TRY002", "TRY301"]
"tests/**" = ["S", "ARG001", "ARG002", "TRY002", "TRY301","PERF"]
10 changes: 7 additions & 3 deletions tests/func/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ def test_analytics(tmp_path, server):
text=True,
)

match = re.search(r".*Saving analytics report to (.*)", output, flags=re.M)
match = re.search(r".*Saving analytics report to (.*)", output, flags=re.MULTILINE)
assert match, "no match for the report file"
report_file = match.group(1).strip()

match = re.search(r".*Spawned .*analytics.* with pid (.*)", output, flags=re.M)
match = re.search(
r".*Spawned .*analytics.* with pid (.*)", output, flags=re.MULTILINE
)
assert match, "no match for the pid"
pid = int(match.group(1).strip())

Expand Down Expand Up @@ -148,7 +150,9 @@ def test_updater(tmp_dir, dvc, server):
text=True,
)

match = re.search(r".*Spawned .*updater.* with pid (.*)", output, flags=re.M)
match = re.search(
r".*Spawned .*updater.* with pid (.*)", output, flags=re.MULTILINE
)
assert match, "no match for the pid"
pid = int(match.group(1).strip())

Expand Down

0 comments on commit e131122

Please sign in to comment.