Skip to content

Commit afa0154

Browse files
committed
docs(sync[update_repo]): Document SyncResult return type in README and base class
why: README showed a bare update_repo() call that ignored errors, and BaseSync.update_repo() docstring lacked a Returns section for autodoc. what: - Update README sync example to capture SyncResult and check .ok/.errors - Add NumPy-style Returns section to BaseSync.update_repo() docstring
1 parent 6c7a660 commit afa0154

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ repo = GitSync(
7070
)
7171

7272
# Clone (if not exists) or fetch & update (if exists)
73-
repo.update_repo()
73+
result = repo.update_repo()
7474

75-
print(f"Current revision: {repo.get_revision()}")
75+
if result.ok:
76+
print(f"Current revision: {repo.get_revision()}")
77+
else:
78+
for error in result.errors:
79+
print(f"Sync failed at {error.step}: {error.message}")
7680
```
7781

7882
### 2. Command Abstraction

src/libvcs/sync/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,13 @@ def ensure_dir(self, *args: t.Any, **kwargs: t.Any) -> bool:
278278
return True
279279

280280
def update_repo(self, *args: t.Any, **kwargs: t.Any) -> SyncResult:
281-
"""Pull latest changes to here from remote repository."""
281+
"""Pull latest changes to here from remote repository.
282+
283+
Returns
284+
-------
285+
SyncResult
286+
Result of the sync operation, with any errors recorded.
287+
"""
282288
raise NotImplementedError
283289

284290
def obtain(self, *args: t.Any, **kwargs: t.Any) -> None:

0 commit comments

Comments
 (0)