2020import logging
2121import os
2222import re
23- from typing import NamedTuple , Optional
23+ from typing import Dict , NamedTuple , Optional
2424from urllib import parse as urlparse
2525
2626from . import exc
@@ -334,7 +334,7 @@ def update_repo(self):
334334 cmd = ['submodule' , 'update' , '--recursive' , '--init' ]
335335 self .run (cmd , log_in_real_time = True )
336336
337- def remotes (self , flat = False ):
337+ def remotes (self , flat = False ) -> Dict :
338338 """Return remotes like git remote -v.
339339
340340 Parameters
@@ -344,8 +344,7 @@ def remotes(self, flat=False):
344344
345345 Returns
346346 -------
347- dict
348- dict of git upstream / remote URLs
347+ dict of git upstream / remote URLs
349348 """
350349 remotes = {}
351350
@@ -358,7 +357,7 @@ def remotes(self, flat=False):
358357 )
359358 return remotes
360359
361- def remote (self , name , ** kwargs ):
360+ def remote (self , name , ** kwargs ) -> GitRemote :
362361 """Get the fetch and push URL for a specified remote name.
363362
364363 Parameters
@@ -368,8 +367,7 @@ def remote(self, name, **kwargs):
368367
369368 Returns
370369 -------
371- libvcs.git.GitRemote
372- Remote name and url in tuple form
370+ Remote name and url in tuple form
373371 """
374372
375373 try :
@@ -407,7 +405,7 @@ def set_remote(self, name, url, overwrite=False):
407405 return self .remote (name = name )
408406
409407 @staticmethod
410- def chomp_protocol (url ):
408+ def chomp_protocol (url ) -> str :
411409 """Return clean VCS url from RFC-style url
412410
413411 Parameters
@@ -417,8 +415,7 @@ def chomp_protocol(url):
417415
418416 Returns
419417 -------
420- str
421- URL as VCS software would accept it
418+ URL as VCS software would accept it
422419 """
423420 if '+' in url :
424421 url = url .split ('+' , 1 )[1 ]
@@ -435,13 +432,12 @@ def chomp_protocol(url):
435432 url = url .replace ('ssh://' , '' )
436433 return url
437434
438- def get_git_version (self ):
435+ def get_git_version (self ) -> str :
439436 """Return current version of git binary
440437
441438 Returns
442439 -------
443- str
444- git version
440+ git version
445441 """
446442 VERSION_PFX = 'git version '
447443 version = self .run (['version' ])
@@ -451,15 +447,14 @@ def get_git_version(self):
451447 version = ''
452448 return '.' .join (version .split ('.' )[:3 ])
453449
454- def status (self ):
450+ def status (self ) -> dict :
455451 """Retrieve status of project in dict format.
456452
457453 Wraps ``git status --sb --porcelain=2``. Does not include changed files, yet.
458454
459455 Returns
460456 -------
461- dict
462- Status of current checked out repository
457+ Status of current checked out repository
463458
464459 Examples
465460 --------
@@ -476,14 +471,13 @@ def status(self):
476471 """
477472 return extract_status (self .run (['status' , '-sb' , '--porcelain=2' ]))
478473
479- def get_current_remote_name (self ):
474+ def get_current_remote_name (self ) -> str :
480475 """Retrieve name of the remote / upstream of currently checked out branch.
481476
482477 Returns
483478 -------
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``.
487481 """
488482 match = self .status ()
489483
0 commit comments