Skip to content

Commit 7c0831f

Browse files
committed
add types for _ffi_names in RemoteCollection
1 parent 46c8425 commit 7c0831f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pygit2/remotes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# Need BaseRepository for type hints, but don't let it cause a circular dependency
4848
if TYPE_CHECKING:
49-
from ._libgit2.ffi import GitRemoteC
49+
from ._libgit2.ffi import GitRemoteC, char_pointer
5050
from .repository import BaseRepository
5151

5252

@@ -367,12 +367,12 @@ def __getitem__(self, name: str | int) -> Remote:
367367

368368
return Remote(self._repo, cremote[0])
369369

370-
def _ffi_names(self):
370+
def _ffi_names(self) -> Generator['char_pointer', None, None]:
371371
with utils.new_git_strarray() as names:
372372
err = C.git_remote_list(names, self._repo._repo)
373373
check_error(err)
374374
for i in range(names.count):
375-
yield names.strings[i]
375+
yield names.strings[i] # type: ignore[index]
376376

377377
def names(self) -> Generator[str | None, None, None]:
378378
"""An iterator over the names of the available remotes."""

pygit2/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from typing import (
3030
TYPE_CHECKING,
3131
Generic,
32+
Generator,
3233
Iterator,
3334
Optional,
3435
Protocol,
@@ -45,7 +46,7 @@
4546
from ._libgit2.ffi import ArrayC, GitStrrayC, char, char_pointer
4647

4748

48-
def maybe_string(ptr: 'char_pointer') -> str | None:
49+
def maybe_string(ptr: 'char_pointer' | None) -> str | None:
4950
if not ptr:
5051
return None
5152

@@ -105,7 +106,7 @@ def ptr_to_bytes(ptr_cdata):
105106

106107

107108
@contextlib.contextmanager
108-
def new_git_strarray():
109+
def new_git_strarray() -> Generator[GitStrrayC, None, None]:
109110
strarray = ffi.new('git_strarray *')
110111
yield strarray
111112
C.git_strarray_dispose(strarray)

0 commit comments

Comments
 (0)