Skip to content

Commit cf67fab

Browse files
committed
improve types according to test/test_remote_prune.py
1 parent fb0bfd7 commit cf67fab

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pygit2/remotes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def ls_remotes(
234234

235235
return results
236236

237-
def prune(self, callbacks=None):
237+
def prune(self, callbacks: RemoteCallbacks | None = None) -> None:
238238
"""Perform a prune against this remote."""
239239
with git_remote_callbacks(callbacks) as payload:
240240
err = C.git_remote_prune(self._remote, payload.remote_callbacks)

test/test_remote_prune.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@
2323
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
2424
# Boston, MA 02110-1301, USA.
2525

26+
from pathlib import Path
27+
from typing import Generator
28+
2629
import pytest
2730

2831
import pygit2
32+
from pygit2 import Oid, Repository
2933
from pygit2.enums import FetchPrune
3034

3135

3236
@pytest.fixture
33-
def clonerepo(testrepo, tmp_path):
37+
def clonerepo(
38+
testrepo: Repository, tmp_path: Path
39+
) -> Generator[Repository, None, None]:
3440
cloned_repo_path = tmp_path / 'test_remote_prune'
3541

3642
pygit2.clone_repository(testrepo.workdir, cloned_repo_path)
@@ -39,26 +45,26 @@ def clonerepo(testrepo, tmp_path):
3945
yield clonerepo
4046

4147

42-
def test_fetch_remote_default(clonerepo):
48+
def test_fetch_remote_default(clonerepo: Repository) -> None:
4349
clonerepo.remotes[0].fetch()
4450
assert 'origin/i18n' in clonerepo.branches
4551

4652

47-
def test_fetch_remote_prune(clonerepo):
53+
def test_fetch_remote_prune(clonerepo: Repository) -> None:
4854
clonerepo.remotes[0].fetch(prune=FetchPrune.PRUNE)
4955
assert 'origin/i18n' not in clonerepo.branches
5056

5157

52-
def test_fetch_no_prune(clonerepo):
58+
def test_fetch_no_prune(clonerepo: Repository) -> None:
5359
clonerepo.remotes[0].fetch(prune=FetchPrune.NO_PRUNE)
5460
assert 'origin/i18n' in clonerepo.branches
5561

5662

57-
def test_remote_prune(clonerepo):
63+
def test_remote_prune(clonerepo: Repository) -> None:
5864
pruned = []
5965

6066
class MyCallbacks(pygit2.RemoteCallbacks):
61-
def update_tips(self, name, old, new):
67+
def update_tips(self, name: str, old: Oid, new: Oid) -> None:
6268
pruned.append(name)
6369

6470
callbacks = MyCallbacks()

0 commit comments

Comments
 (0)