20
20
import logging
21
21
import os
22
22
import re
23
- from typing import NamedTuple , Optional
23
+ from typing import Dict , NamedTuple , Optional
24
24
from urllib import parse as urlparse
25
25
26
26
from . import exc
@@ -334,7 +334,7 @@ def update_repo(self):
334
334
cmd = ['submodule' , 'update' , '--recursive' , '--init' ]
335
335
self .run (cmd , log_in_real_time = True )
336
336
337
- def remotes (self , flat = False ):
337
+ def remotes (self , flat = False ) -> Dict :
338
338
"""Return remotes like git remote -v.
339
339
340
340
Parameters
@@ -344,8 +344,7 @@ def remotes(self, flat=False):
344
344
345
345
Returns
346
346
-------
347
- dict
348
- dict of git upstream / remote URLs
347
+ dict of git upstream / remote URLs
349
348
"""
350
349
remotes = {}
351
350
@@ -358,7 +357,7 @@ def remotes(self, flat=False):
358
357
)
359
358
return remotes
360
359
361
- def remote (self , name , ** kwargs ):
360
+ def remote (self , name , ** kwargs ) -> GitRemote :
362
361
"""Get the fetch and push URL for a specified remote name.
363
362
364
363
Parameters
@@ -368,8 +367,7 @@ def remote(self, name, **kwargs):
368
367
369
368
Returns
370
369
-------
371
- libvcs.git.GitRemote
372
- Remote name and url in tuple form
370
+ Remote name and url in tuple form
373
371
"""
374
372
375
373
try :
@@ -407,7 +405,7 @@ def set_remote(self, name, url, overwrite=False):
407
405
return self .remote (name = name )
408
406
409
407
@staticmethod
410
- def chomp_protocol (url ):
408
+ def chomp_protocol (url ) -> str :
411
409
"""Return clean VCS url from RFC-style url
412
410
413
411
Parameters
@@ -417,8 +415,7 @@ def chomp_protocol(url):
417
415
418
416
Returns
419
417
-------
420
- str
421
- URL as VCS software would accept it
418
+ URL as VCS software would accept it
422
419
"""
423
420
if '+' in url :
424
421
url = url .split ('+' , 1 )[1 ]
@@ -435,13 +432,12 @@ def chomp_protocol(url):
435
432
url = url .replace ('ssh://' , '' )
436
433
return url
437
434
438
- def get_git_version (self ):
435
+ def get_git_version (self ) -> str :
439
436
"""Return current version of git binary
440
437
441
438
Returns
442
439
-------
443
- str
444
- git version
440
+ git version
445
441
"""
446
442
VERSION_PFX = 'git version '
447
443
version = self .run (['version' ])
@@ -451,15 +447,14 @@ def get_git_version(self):
451
447
version = ''
452
448
return '.' .join (version .split ('.' )[:3 ])
453
449
454
- def status (self ):
450
+ def status (self ) -> dict :
455
451
"""Retrieve status of project in dict format.
456
452
457
453
Wraps ``git status --sb --porcelain=2``. Does not include changed files, yet.
458
454
459
455
Returns
460
456
-------
461
- dict
462
- Status of current checked out repository
457
+ Status of current checked out repository
463
458
464
459
Examples
465
460
--------
@@ -476,14 +471,13 @@ def status(self):
476
471
"""
477
472
return extract_status (self .run (['status' , '-sb' , '--porcelain=2' ]))
478
473
479
- def get_current_remote_name (self ):
474
+ def get_current_remote_name (self ) -> str :
480
475
"""Retrieve name of the remote / upstream of currently checked out branch.
481
476
482
477
Returns
483
478
-------
484
- str
485
- If upstream the same, returns ``branch_name``.
486
- If upstream mismatches, returns ``remote_name/branch_name``.
479
+ If upstream the same, returns ``branch_name``.
480
+ If upstream mismatches, returns ``remote_name/branch_name``.
487
481
"""
488
482
match = self .status ()
489
483
0 commit comments