Skip to content

Commit 0d25525

Browse files
committed
ruff: Format with ruff v0.14.3
uv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; uv run ruff format . Fixed 72 errors: - scripts/generate_gitlab.py: 3 × G004 (logging-f-string) 1 × PLW1514 (unspecified-encoding) - src/vcspull/cli/_output.py: 3 × T201 (print) 1 × F401 (unused-import) 1 × COM812 (missing-trailing-comma) - src/vcspull/cli/add.py: 1 × RUF052 (used-dummy-variable) 1 × TC003 (typing-only-standard-library-import) - src/vcspull/cli/discover.py: 1 × RUF052 (used-dummy-variable) 1 × TC003 (typing-only-standard-library-import) - src/vcspull/cli/list.py: 2 × COM812 (missing-trailing-comma) 2 × TC003 (typing-only-standard-library-import) 1 × I001 (unsorted-imports) - src/vcspull/cli/status.py: 6 × COM812 (missing-trailing-comma) 1 × I001 (unsorted-imports) 1 × TC003 (typing-only-standard-library-import) - src/vcspull/cli/sync.py: 5 × COM812 (missing-trailing-comma) 1 × F811 (redefined-while-unused) 1 × T201 (print) 1 × G004 (logging-f-string) 1 × F841 (unused-variable) 1 × FURB177 (implicit-cwd) 1 × TC004 (runtime-import-in-type-checking-block) 1 × RET501 (unnecessary-return-none) 1 × F401 (unused-import) - src/vcspull/config.py: 2 × RUF027 (missing-f-string-syntax) 1 × COM812 (missing-trailing-comma) - tests/cli/test_add.py: 1 × I001 (unsorted-imports) 1 × TC003 (typing-only-standard-library-import) 1 × PLR5501 (collapsible-else-if) - tests/cli/test_discover.py: 1 × I001 (unsorted-imports) 1 × TC003 (typing-only-standard-library-import) - tests/cli/test_list.py: 1 × PLW1514 (unspecified-encoding) 1 × I001 (unsorted-imports) 1 × TC003 (typing-only-standard-library-import) - tests/cli/test_plan_output_helpers.py: 1 × COM812 (missing-trailing-comma) - tests/cli/test_status.py: 3 × TC006 (runtime-cast-value) 1 × TC003 (typing-only-standard-library-import) 1 × PLW1514 (unspecified-encoding) 1 × I001 (unsorted-imports) 1 × TC001 (typing-only-first-party-import) - tests/cli/test_sync_plan_helpers.py: 1 × TC003 (typing-only-standard-library-import) - tests/test_cli.py: 5 × COM812 (missing-trailing-comma) 2 × FLY002 (static-join-to-f-string) 1 × F811 (redefined-while-unused) 1 × TC004 (runtime-import-in-type-checking-block) - tests/test_config.py: 1 × I001 (unsorted-imports) 1 × TC003 (typing-only-standard-library-import) - tests/test_utils.py: 1 × F811 (redefined-while-unused) 1 × TC004 (runtime-import-in-type-checking-block) Found 1025 errors (72 fixed, 953 remaining). 6 files reformatted, 36 files left unchanged
1 parent 7e7dba1 commit 0d25525

17 files changed

+95
-80
lines changed

scripts/generate_gitlab.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161

6262
if result != "y":
6363
log.info(
64-
f"Aborting per user request as existing config file ({config_filename})"
65-
" should not be overwritten!",
64+
"Aborting per user request as existing config file (%s) should not be overwritten!",
65+
config_filename,
6666
)
6767
sys.exit(0)
6868

69-
config_file = config_filename.open(mode="w")
69+
config_file = config_filename.open(encoding="utf-8", mode="w")
7070
except OSError:
71-
log.info(f"File {config_filename} not accessible")
71+
log.info("File %s not accessible", config_filename)
7272
sys.exit(1)
7373

7474
response = requests.get(
@@ -78,7 +78,7 @@
7878
)
7979

8080
if response.status_code != 200:
81-
log.info(f"Error: {response}")
81+
log.info("Error: %s", response)
8282
sys.exit(1)
8383

8484
path_prefix = pathlib.Path().cwd()

src/vcspull/cli/_output.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import json
65
import sys
76
import typing as t
87
from dataclasses import dataclass, field
@@ -147,7 +146,7 @@ def to_json_object(self) -> dict[str, t.Any]:
147146
{
148147
"path": workspace_root,
149148
"operations": [entry.to_payload() for entry in entries],
150-
}
149+
},
151150
)
152151
return {
153152
"format_version": "1",
@@ -186,7 +185,6 @@ def emit(self, data: dict[str, t.Any] | PlanEntry | PlanSummary) -> None:
186185

187186
if self.mode == OutputMode.NDJSON:
188187
# Stream one JSON object per line immediately
189-
print(json.dumps(payload), file=sys.stdout)
190188
sys.stdout.flush()
191189
elif self.mode == OutputMode.JSON:
192190
# Buffer for later output as single array
@@ -202,12 +200,11 @@ def emit_text(self, text: str) -> None:
202200
Text to output
203201
"""
204202
if self.mode == OutputMode.HUMAN:
205-
print(text)
203+
pass
206204

207205
def finalize(self) -> None:
208206
"""Finalize output (flush JSON buffer if needed)."""
209207
if self.mode == OutputMode.JSON and self._json_buffer:
210-
print(json.dumps(self._json_buffer, indent=2), file=sys.stdout)
211208
self._json_buffer.clear()
212209

213210

src/vcspull/cli/add.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import argparse
65
import logging
76
import pathlib
87
import traceback
@@ -20,6 +19,9 @@
2019
workspace_root_label,
2120
)
2221

22+
if t.TYPE_CHECKING:
23+
import argparse
24+
2325
log = logging.getLogger(__name__)
2426

2527

@@ -180,8 +182,8 @@ def add_repo(
180182
cwd=cwd,
181183
home=home,
182184
)
183-
raw_config, workspace_map, merge_conflicts, _merge_changes = normalization_result
184-
config_was_normalized = _merge_changes > 0
185+
raw_config, workspace_map, merge_conflicts, merge_changes = normalization_result
186+
config_was_normalized = merge_changes > 0
185187

186188
for message in merge_conflicts:
187189
log.warning(message)

src/vcspull/cli/discover.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import argparse
65
import logging
76
import os
87
import pathlib
@@ -22,6 +21,9 @@
2221
workspace_root_label,
2322
)
2423

24+
if t.TYPE_CHECKING:
25+
import argparse
26+
2527
log = logging.getLogger(__name__)
2628

2729

@@ -222,7 +224,7 @@ def discover_repos(
222224
cwd=cwd,
223225
home=home,
224226
)
225-
raw_config, workspace_map, merge_conflicts, _merge_changes = normalization_result
227+
raw_config, workspace_map, merge_conflicts, merge_changes = normalization_result
226228

227229
for message in merge_conflicts:
228230
log.warning(message)
@@ -348,7 +350,7 @@ def discover_repos(
348350
Style.RESET_ALL,
349351
)
350352

351-
changes_made = _merge_changes > 0
353+
changes_made = merge_changes > 0
352354

353355
if not repos_to_add:
354356
if existing_repos:

src/vcspull/cli/list.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
from __future__ import annotations
44

5-
import argparse
65
import logging
7-
import pathlib
86
import typing as t
97

108
from vcspull.config import filter_repos, find_config_files, load_configs
@@ -15,6 +13,9 @@
1513
from ._workspaces import filter_by_workspace
1614

1715
if t.TYPE_CHECKING:
16+
import argparse
17+
import pathlib
18+
1819
from vcspull.types import ConfigDict
1920

2021
log = logging.getLogger(__name__)
@@ -168,7 +169,7 @@ def _output_flat(
168169
"url": str(repo_url),
169170
"path": contract_user_home(repo_path),
170171
"workspace_root": str(repo.get("workspace_root", "")),
171-
}
172+
},
172173
)
173174

174175
# Human output (contract home directory for privacy/brevity)
@@ -219,7 +220,7 @@ def _output_tree(
219220
"url": str(repo_url),
220221
"path": contract_user_home(repo_path),
221222
"workspace_root": workspace,
222-
}
223+
},
223224
)
224225

225226
# Human output: indented repo (contract home directory for privacy/brevity)

src/vcspull/cli/status.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import argparse
65
import asyncio
76
import logging
87
import os
@@ -22,6 +21,8 @@
2221
from ._workspaces import filter_by_workspace
2322

2423
if t.TYPE_CHECKING:
24+
import argparse
25+
2526
from vcspull.types import ConfigDict
2627

2728
log = logging.getLogger(__name__)
@@ -84,7 +85,7 @@ def update(self, processed: int, exists: int, missing: int) -> None:
8485
f"Progress: {processed}/{self.total}",
8586
self._colors.success(f"✓:{exists}"),
8687
self._colors.error(f"✗:{missing}"),
87-
)
88+
),
8889
)
8990
clean_len = _visible_length(line)
9091
padding = max(self._last_render_len - clean_len, 0)
@@ -204,7 +205,9 @@ async def _check_repos_status_async(
204205
async def check_with_limit(repo: ConfigDict) -> dict[str, t.Any]:
205206
async with semaphore:
206207
return await asyncio.to_thread(
207-
check_repo_status, repo, detailed=config.detailed
208+
check_repo_status,
209+
repo,
210+
detailed=config.detailed,
208211
)
209212

210213
tasks = [asyncio.create_task(check_with_limit(repo)) for repo in repos]
@@ -410,7 +413,9 @@ def status_repos(
410413

411414
progress_enabled = formatter.mode == OutputMode.HUMAN and sys.stdout.isatty()
412415
progress_printer = StatusProgressPrinter(
413-
len(found_repos), colors, progress_enabled
416+
len(found_repos),
417+
colors,
418+
progress_enabled,
414419
)
415420

416421
start_time = perf_counter()
@@ -419,7 +424,7 @@ def status_repos(
419424
found_repos,
420425
config=check_config,
421426
progress=progress_printer if progress_enabled else None,
422-
)
427+
),
423428
)
424429
duration_ms = int((perf_counter() - start_time) * 1000)
425430

@@ -453,7 +458,7 @@ def status_repos(
453458
{
454459
"reason": "status",
455460
**status,
456-
}
461+
},
457462
)
458463

459464
# Human output
@@ -541,7 +546,7 @@ def _format_status_line(
541546

542547
if detailed:
543548
formatter.emit_text(
544-
f" {colors.muted('Path:')} {contract_user_home(status['path'])}"
549+
f" {colors.muted('Path:')} {contract_user_home(status['path'])}",
545550
)
546551
branch = status.get("branch")
547552
if branch:

src/vcspull/cli/sync.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import asyncio
66
import contextlib
7-
import json
87
import logging
98
import os
109
import pathlib
@@ -42,7 +41,6 @@
4241

4342
if t.TYPE_CHECKING:
4443
import argparse
45-
import pathlib
4644

4745
from libvcs._internal.types import VCSLiteral
4846
from libvcs.sync.git import GitSync
@@ -114,7 +112,7 @@ def update(self, summary: PlanSummary, processed: int) -> None:
114112
self._colors.muted(f"✓:{summary.unchanged}"),
115113
self._colors.warning(f"⚠:{summary.blocked}"),
116114
self._colors.error(f"✗:{summary.errors}"),
117-
)
115+
),
118116
)
119117
clean_len = _visible_length(line)
120118
padding = max(self._last_render_len - clean_len, 0)
@@ -145,7 +143,7 @@ def _get_repo_path(repo: ConfigDict) -> pathlib.Path:
145143
"""Return the resolved filesystem path for a repository entry."""
146144
raw_path = repo.get("path")
147145
if raw_path is None:
148-
return pathlib.Path().resolve()
146+
return pathlib.Path.cwd()
149147
return pathlib.Path(str(raw_path)).expanduser()
150148

151149

@@ -459,7 +457,7 @@ def _render_plan(
459457
extra_lines.append(f"url: {entry.url}")
460458
if entry.ahead is not None or entry.behind is not None:
461459
extra_lines.append(
462-
f"ahead/behind: {entry.ahead or 0}/{entry.behind or 0}"
460+
f"ahead/behind: {entry.ahead or 0}/{entry.behind or 0}",
463461
)
464462
if entry.error:
465463
extra_lines.append(f"error: {entry.error}")
@@ -502,8 +500,7 @@ def _emit_plan_output(
502500
formatter.emit(plan.summary)
503501
return
504502

505-
structured = PlanResult(entries=display_entries, summary=plan.summary)
506-
print(json.dumps(structured.to_json_object(), indent=2))
503+
PlanResult(entries=display_entries, summary=plan.summary)
507504

508505

509506
def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
@@ -679,7 +676,7 @@ def sync(
679676
found_repos,
680677
config=plan_config,
681678
progress=progress_printer if progress_enabled else None,
682-
)
679+
),
683680
)
684681
plan_result.summary.duration_ms = int((perf_counter() - start_time) * 1000)
685682
if progress_enabled:
@@ -711,7 +708,7 @@ def sync(
711708

712709
def silent_progress(output: str, timestamp: datetime) -> None:
713710
"""Suppress progress for machine-readable output."""
714-
return None
711+
return
715712

716713
progress_callback = silent_progress
717714

@@ -755,7 +752,8 @@ def silent_progress(output: str, timestamp: datetime) -> None:
755752
formatter.emit(event)
756753
if is_human:
757754
log.info(
758-
f"Failed syncing {repo_name}",
755+
"Failed syncing %s",
756+
repo_name,
759757
)
760758
if log.isEnabledFor(logging.DEBUG):
761759
import traceback
@@ -770,7 +768,7 @@ def silent_progress(output: str, timestamp: datetime) -> None:
770768
{
771769
"reason": "summary",
772770
**summary,
773-
}
771+
},
774772
)
775773
formatter.finalize()
776774
if parser is not None:
@@ -790,7 +788,7 @@ def silent_progress(output: str, timestamp: datetime) -> None:
790788
{
791789
"reason": "summary",
792790
**summary,
793-
}
791+
},
794792
)
795793

796794
if formatter.mode == OutputMode.HUMAN:

src/vcspull/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,18 +525,18 @@ def normalize_workspace_roots(
525525
change_count += 1
526526
elif existing_value[repo_name] != repo_config:
527527
conflict_message = (
528-
"Workspace root '{label}' contains conflicting definitions "
528+
f"Workspace root '{label}' contains conflicting definitions "
529529
"for repository '{repo}'. Keeping the existing entry."
530530
)
531531
conflicts.append(
532532
conflict_message.format(
533533
label=normalized_label,
534534
repo=repo_name,
535-
)
535+
),
536536
)
537537
elif existing_value != value:
538538
conflict_message = (
539-
"Workspace root '{label}' contains conflicting non-dictionary "
539+
f"Workspace root '{label}' contains conflicting non-dictionary "
540540
"values. Keeping the existing entry."
541541
)
542542
conflicts.append(conflict_message.format(label=normalized_label))

0 commit comments

Comments
 (0)