2525
2626from __future__ import annotations
2727
28- from typing import TYPE_CHECKING , Any , TypedDict
28+ from typing import TYPE_CHECKING , Any , Literal , TypedDict
2929
3030# Import from pygit2
3131from pygit2 import RemoteCallbacks
4646
4747# Need BaseRepository for type hints, but don't let it cause a circular dependency
4848if TYPE_CHECKING :
49+ from ._libgit2 .ffi import GitRemoteC
4950 from .repository import BaseRepository
5051
5152
@@ -92,34 +93,39 @@ def __init__(self, tp: Any) -> None:
9293
9394
9495class Remote :
95- def __init__ (self , repo : BaseRepository , ptr ) :
96+ def __init__ (self , repo : BaseRepository , ptr : 'GitRemoteC' ) -> None :
9697 """The constructor is for internal use only."""
9798 self ._repo = repo
9899 self ._remote = ptr
99100 self ._stored_exception = None
100101
101- def __del__ (self ):
102+ def __del__ (self ) -> None :
102103 C .git_remote_free (self ._remote )
103104
104105 @property
105- def name (self ):
106+ def name (self ) -> str | None :
106107 """Name of the remote"""
107108
108109 return maybe_string (C .git_remote_name (self ._remote ))
109110
110111 @property
111- def url (self ):
112+ def url (self ) -> str | None :
112113 """Url of the remote"""
113114
114115 return maybe_string (C .git_remote_url (self ._remote ))
115116
116117 @property
117- def push_url (self ):
118+ def push_url (self ) -> str | None :
118119 """Push url of the remote"""
119120
120121 return maybe_string (C .git_remote_pushurl (self ._remote ))
121122
122- def connect (self , callbacks = None , direction = C .GIT_DIRECTION_FETCH , proxy = None ):
123+ def connect (
124+ self ,
125+ callbacks : RemoteCallbacks | None = None ,
126+ direction : int = C .GIT_DIRECTION_FETCH ,
127+ proxy : None | bool | str = None ,
128+ ) -> None :
123129 """Connect to the remote.
124130
125131 Parameters:
@@ -144,13 +150,13 @@ def connect(self, callbacks=None, direction=C.GIT_DIRECTION_FETCH, proxy=None):
144150
145151 def fetch (
146152 self ,
147- refspecs = None ,
148- message = None ,
149- callbacks = None ,
153+ refspecs : list [ str ] | None = None ,
154+ message : str | None = None ,
155+ callbacks : RemoteCallbacks | None = None ,
150156 prune : FetchPrune = FetchPrune .UNSPECIFIED ,
151- proxy = None ,
152- depth = 0 ,
153- ):
157+ proxy : None | Literal [ True ] | str = None ,
158+ depth : int = 0 ,
159+ ) -> TransferProgress :
154160 """Perform a fetch against this remote. Returns a <TransferProgress>
155161 object.
156162
@@ -241,7 +247,7 @@ def prune(self, callbacks: RemoteCallbacks | None = None) -> None:
241247 payload .check_error (err )
242248
243249 @property
244- def refspec_count (self ):
250+ def refspec_count (self ) -> int :
245251 """Total number of refspecs in this remote"""
246252
247253 return C .git_remote_refspec_count (self ._remote )
@@ -252,7 +258,7 @@ def get_refspec(self, n: int) -> Refspec:
252258 return Refspec (self , spec )
253259
254260 @property
255- def fetch_refspecs (self ):
261+ def fetch_refspecs (self ) -> list [ str ] :
256262 """Refspecs that will be used for fetching"""
257263
258264 specs = ffi .new ('git_strarray *' )
@@ -261,7 +267,7 @@ def fetch_refspecs(self):
261267 return strarray_to_strings (specs )
262268
263269 @property
264- def push_refspecs (self ):
270+ def push_refspecs (self ) -> list [ str ] :
265271 """Refspecs that will be used for pushing"""
266272
267273 specs = ffi .new ('git_strarray *' )
0 commit comments