3030if TYPE_CHECKING :
3131 from git .remote import Remote
3232 from git .repo .base import Repo
33+ from git .config import GitConfigParser , SectionConstraint
34+
3335from .types import PathLike , TBD , Literal , SupportsIndex
3436
3537# ---------------------------------------------------------------------
@@ -82,7 +84,7 @@ def unbare_repo(func: Callable) -> Callable:
8284 encounter a bare repository"""
8385
8486 @wraps (func )
85- def wrapper (self : 'Remote' , * args : Any , ** kwargs : Any ) -> TBD :
87+ def wrapper (self : 'Remote' , * args : Any , ** kwargs : Any ) -> Callable :
8688 if self .repo .bare :
8789 raise InvalidGitRepositoryError ("Method '%s' cannot operate on bare repositories" % func .__name__ )
8890 # END bare method
@@ -108,7 +110,7 @@ def rmtree(path: PathLike) -> None:
108110 :note: we use shutil rmtree but adjust its behaviour to see whether files that
109111 couldn't be deleted are read-only. Windows will not remove them in that case"""
110112
111- def onerror (func : Callable , path : PathLike , exc_info : TBD ) -> None :
113+ def onerror (func : Callable , path : PathLike , exc_info : str ) -> None :
112114 # Is the error an access error ?
113115 os .chmod (path , stat .S_IWUSR )
114116
@@ -448,7 +450,7 @@ class RemoteProgress(object):
448450 re_op_relative = re .compile (r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)" )
449451
450452 def __init__ (self ) -> None :
451- self ._seen_ops = [] # type: List[TBD ]
453+ self ._seen_ops = [] # type: List[int ]
452454 self ._cur_line = None # type: Optional[str]
453455 self .error_lines = [] # type: List[str]
454456 self .other_lines = [] # type: List[str]
@@ -669,7 +671,8 @@ def _from_string(cls, string: str) -> 'Actor':
669671 # END handle name/email matching
670672
671673 @classmethod
672- def _main_actor (cls , env_name : str , env_email : str , config_reader : Optional [TBD ] = None ) -> 'Actor' :
674+ def _main_actor (cls , env_name : str , env_email : str ,
675+ config_reader : Union [None , GitConfigParser , SectionConstraint ] = None ) -> 'Actor' :
673676 actor = Actor ('' , '' )
674677 user_id = None # We use this to avoid multiple calls to getpass.getuser()
675678
@@ -698,7 +701,7 @@ def default_name() -> str:
698701 return actor
699702
700703 @classmethod
701- def committer (cls , config_reader : Optional [ TBD ] = None ) -> 'Actor' :
704+ def committer (cls , config_reader : Union [ None , GitConfigParser , SectionConstraint ] = None ) -> 'Actor' :
702705 """
703706 :return: Actor instance corresponding to the configured committer. It behaves
704707 similar to the git implementation, such that the environment will override
@@ -709,7 +712,7 @@ def committer(cls, config_reader: Optional[TBD] = None) -> 'Actor':
709712 return cls ._main_actor (cls .env_committer_name , cls .env_committer_email , config_reader )
710713
711714 @classmethod
712- def author (cls , config_reader : Optional [ TBD ] = None ) -> 'Actor' :
715+ def author (cls , config_reader : Union [ None , GitConfigParser , SectionConstraint ] = None ) -> 'Actor' :
713716 """Same as committer(), but defines the main author. It may be specified in the environment,
714717 but defaults to the committer"""
715718 return cls ._main_actor (cls .env_author_name , cls .env_author_email , config_reader )
@@ -752,9 +755,14 @@ def _list_from_string(cls, repo: 'Repo', text: str) -> 'Stats':
752755 """Create a Stat object from output retrieved by git-diff.
753756
754757 :return: git.Stat"""
755- hsh = {'total' : {'insertions' : 0 , 'deletions' : 0 , 'lines' : 0 , 'files' : 0 },
756- 'files' : {}
757- } # type: Dict[str, Dict[str, TBD]] ## need typeddict or refactor for mypy
758+
759+ # hsh: Dict[str, Dict[str, Union[int, Dict[str, int]]]]
760+ hsh : Dict [str , Dict [str , TBD ]] = {'total' : {'insertions' : 0 ,
761+ 'deletions' : 0 ,
762+ 'lines' : 0 ,
763+ 'files' : 0 },
764+ 'files' : {}
765+ } # need typeddict?
758766 for line in text .splitlines ():
759767 (raw_insertions , raw_deletions , filename ) = line .split ("\t " )
760768 insertions = raw_insertions != '-' and int (raw_insertions ) or 0
@@ -763,9 +771,10 @@ def _list_from_string(cls, repo: 'Repo', text: str) -> 'Stats':
763771 hsh ['total' ]['deletions' ] += deletions
764772 hsh ['total' ]['lines' ] += insertions + deletions
765773 hsh ['total' ]['files' ] += 1
766- hsh ['files' ][filename .strip ()] = {'insertions' : insertions ,
767- 'deletions' : deletions ,
768- 'lines' : insertions + deletions }
774+ files_dict = {'insertions' : insertions ,
775+ 'deletions' : deletions ,
776+ 'lines' : insertions + deletions }
777+ hsh ['files' ][filename .strip ()] = files_dict
769778 return Stats (hsh ['total' ], hsh ['files' ])
770779
771780
@@ -1077,7 +1086,7 @@ def list_items(cls, repo: 'Repo', *args: Any, **kwargs: Any) -> IterableList[T]:
10771086 return out_list
10781087
10791088 @classmethod
1080- def iter_items (cls , repo : 'Repo' , * args : Any , ** kwargs : Any ) -> Iterator :
1089+ def iter_items (cls , repo : 'Repo' , * args : Any , ** kwargs : Any ) -> Iterator [ T ] :
10811090 # return typed to be compatible with subtypes e.g. Remote
10821091 """For more information about the arguments, see list_items
10831092 :return: iterator yielding Items"""
0 commit comments