25
25
26
26
from __future__ import annotations
27
27
28
- from typing import TYPE_CHECKING , Any , TypedDict
28
+ from typing import TYPE_CHECKING , Any , Literal , TypedDict
29
29
30
30
# Import from pygit2
31
31
from pygit2 import RemoteCallbacks
46
46
47
47
# Need BaseRepository for type hints, but don't let it cause a circular dependency
48
48
if TYPE_CHECKING :
49
+ from ._libgit2 .ffi import GitRemoteC
49
50
from .repository import BaseRepository
50
51
51
52
@@ -92,34 +93,39 @@ def __init__(self, tp: Any) -> None:
92
93
93
94
94
95
class Remote :
95
- def __init__ (self , repo : BaseRepository , ptr ) :
96
+ def __init__ (self , repo : BaseRepository , ptr : 'GitRemoteC' ) -> None :
96
97
"""The constructor is for internal use only."""
97
98
self ._repo = repo
98
99
self ._remote = ptr
99
100
self ._stored_exception = None
100
101
101
- def __del__ (self ):
102
+ def __del__ (self ) -> None :
102
103
C .git_remote_free (self ._remote )
103
104
104
105
@property
105
- def name (self ):
106
+ def name (self ) -> str | None :
106
107
"""Name of the remote"""
107
108
108
109
return maybe_string (C .git_remote_name (self ._remote ))
109
110
110
111
@property
111
- def url (self ):
112
+ def url (self ) -> str | None :
112
113
"""Url of the remote"""
113
114
114
115
return maybe_string (C .git_remote_url (self ._remote ))
115
116
116
117
@property
117
- def push_url (self ):
118
+ def push_url (self ) -> str | None :
118
119
"""Push url of the remote"""
119
120
120
121
return maybe_string (C .git_remote_pushurl (self ._remote ))
121
122
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 :
123
129
"""Connect to the remote.
124
130
125
131
Parameters:
@@ -144,13 +150,13 @@ def connect(self, callbacks=None, direction=C.GIT_DIRECTION_FETCH, proxy=None):
144
150
145
151
def fetch (
146
152
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 ,
150
156
prune : FetchPrune = FetchPrune .UNSPECIFIED ,
151
- proxy = None ,
152
- depth = 0 ,
153
- ):
157
+ proxy : None | Literal [ True ] | str = None ,
158
+ depth : int = 0 ,
159
+ ) -> TransferProgress :
154
160
"""Perform a fetch against this remote. Returns a <TransferProgress>
155
161
object.
156
162
@@ -241,7 +247,7 @@ def prune(self, callbacks: RemoteCallbacks | None = None) -> None:
241
247
payload .check_error (err )
242
248
243
249
@property
244
- def refspec_count (self ):
250
+ def refspec_count (self ) -> int :
245
251
"""Total number of refspecs in this remote"""
246
252
247
253
return C .git_remote_refspec_count (self ._remote )
@@ -252,7 +258,7 @@ def get_refspec(self, n: int) -> Refspec:
252
258
return Refspec (self , spec )
253
259
254
260
@property
255
- def fetch_refspecs (self ):
261
+ def fetch_refspecs (self ) -> list [ str ] :
256
262
"""Refspecs that will be used for fetching"""
257
263
258
264
specs = ffi .new ('git_strarray *' )
@@ -261,7 +267,7 @@ def fetch_refspecs(self):
261
267
return strarray_to_strings (specs )
262
268
263
269
@property
264
- def push_refspecs (self ):
270
+ def push_refspecs (self ) -> list [ str ] :
265
271
"""Refspecs that will be used for pushing"""
266
272
267
273
specs = ffi .new ('git_strarray *' )
0 commit comments