1
- from git .config import SectionConstraint
1
+ from git .config import GitConfigParser , SectionConstraint
2
2
from git .util import join_path
3
3
from git .exc import GitCommandError
4
4
@@ -142,7 +142,7 @@ def delete(cls, repo: 'Repo', *heads: 'Head', **kwargs: Any):
142
142
flag = "-D"
143
143
repo .git .branch (flag , * heads )
144
144
145
- def set_tracking_branch (self , remote_reference : 'RemoteReference' ) -> 'Head' :
145
+ def set_tracking_branch (self , remote_reference : Union [ 'RemoteReference' , None ] ) -> 'Head' :
146
146
"""
147
147
Configure this branch to track the given remote reference. This will alter
148
148
this branch's configuration accordingly.
@@ -203,7 +203,7 @@ def rename(self, new_path: PathLike, force: bool = False) -> 'Head':
203
203
self .path = "%s/%s" % (self ._common_path_default , new_path )
204
204
return self
205
205
206
- def checkout (self , force : bool = False , ** kwargs : Any ):
206
+ def checkout (self , force : bool = False , ** kwargs : Any ) -> Union [ 'HEAD' , 'Head' ] :
207
207
"""Checkout this head by setting the HEAD to this reference, by updating the index
208
208
to reflect the tree we point to and by updating the working tree to reflect
209
209
the latest index.
@@ -235,10 +235,11 @@ def checkout(self, force: bool = False, **kwargs: Any):
235
235
self .repo .git .checkout (self , ** kwargs )
236
236
if self .repo .head .is_detached :
237
237
return self .repo .head
238
- return self .repo .active_branch
238
+ else :
239
+ return self .repo .active_branch
239
240
240
241
#{ Configuration
241
- def _config_parser (self , read_only : bool ) -> SectionConstraint :
242
+ def _config_parser (self , read_only : bool ) -> SectionConstraint [ GitConfigParser ] :
242
243
if read_only :
243
244
parser = self .repo .config_reader ()
244
245
else :
@@ -247,13 +248,13 @@ def _config_parser(self, read_only: bool) -> SectionConstraint:
247
248
248
249
return SectionConstraint (parser , 'branch "%s"' % self .name )
249
250
250
- def config_reader (self ) -> SectionConstraint :
251
+ def config_reader (self ) -> SectionConstraint [ GitConfigParser ] :
251
252
"""
252
253
:return: A configuration parser instance constrained to only read
253
254
this instance's values"""
254
255
return self ._config_parser (read_only = True )
255
256
256
- def config_writer (self ) -> SectionConstraint :
257
+ def config_writer (self ) -> SectionConstraint [ GitConfigParser ] :
257
258
"""
258
259
:return: A configuration writer instance with read-and write access
259
260
to options of this head"""
0 commit comments