3636
3737# typing-------------------------------------------------------
3838
39- from typing import Any , Callable , Dict , Iterator , List , Optional , Sequence , TYPE_CHECKING , Union , overload
39+ from typing import (Any , Callable , Dict , Iterator , List , NoReturn , Optional , Sequence , # NOQA[TC002]
40+ TYPE_CHECKING , Type , Union , overload )
4041
41- from git .types import PathLike , Literal , TBD , TypeGuard , Commit_ish
42+ from git .types import PathLike , Literal , TBD , TypeGuard , Commit_ish # NOQA[TC002]
4243
4344if TYPE_CHECKING :
4445 from git .repo .base import Repo
@@ -83,17 +84,17 @@ def add_progress(kwargs: Any, git: Git,
8384#} END utilities
8485
8586
86- @overload
87+ @ overload
8788def to_progress_instance (progress : None ) -> RemoteProgress :
8889 ...
8990
9091
91- @overload
92+ @ overload
9293def to_progress_instance (progress : Callable [..., Any ]) -> CallableRemoteProgress :
9394 ...
9495
9596
96- @overload
97+ @ overload
9798def to_progress_instance (progress : RemoteProgress ) -> RemoteProgress :
9899 ...
99100
@@ -155,11 +156,11 @@ def __init__(self, flags: int, local_ref: Union[SymbolicReference, None], remote
155156 self ._old_commit_sha = old_commit
156157 self .summary = summary
157158
158- @property
159- def old_commit (self ) -> Union [str , SymbolicReference , ' Commit_ish' , None ]:
159+ @ property
160+ def old_commit (self ) -> Union [str , SymbolicReference , Commit_ish , None ]:
160161 return self ._old_commit_sha and self ._remote .repo .commit (self ._old_commit_sha ) or None
161162
162- @property
163+ @ property
163164 def remote_ref (self ) -> Union [RemoteReference , TagReference ]:
164165 """
165166 :return:
@@ -175,7 +176,7 @@ def remote_ref(self) -> Union[RemoteReference, TagReference]:
175176 raise ValueError ("Could not handle remote ref: %r" % self .remote_ref_string )
176177 # END
177178
178- @classmethod
179+ @ classmethod
179180 def _from_line (cls , remote : 'Remote' , line : str ) -> 'PushInfo' :
180181 """Create a new PushInfo instance as parsed from line which is expected to be like
181182 refs/heads/master:refs/heads/master 05d2687..1d0568e as bytes"""
@@ -228,6 +229,11 @@ def _from_line(cls, remote: 'Remote', line: str) -> 'PushInfo':
228229
229230 return PushInfo (flags , from_ref , to_ref_string , remote , old_commit , summary )
230231
232+ @ classmethod
233+ def iter_items (cls , repo : 'Repo' , * args : Any , ** kwargs : Any
234+ ) -> NoReturn : # -> Iterator['PushInfo']:
235+ raise NotImplementedError
236+
231237
232238class FetchInfo (IterableObj , object ):
233239
@@ -262,7 +268,7 @@ class FetchInfo(IterableObj, object):
262268 '-' : TAG_UPDATE ,
263269 } # type: Dict[flagKeyLiteral, int]
264270
265- @classmethod
271+ @ classmethod
266272 def refresh (cls ) -> Literal [True ]:
267273 """This gets called by the refresh function (see the top level
268274 __init__).
@@ -301,25 +307,25 @@ def __init__(self, ref: SymbolicReference, flags: int, note: str = '',
301307 def __str__ (self ) -> str :
302308 return self .name
303309
304- @property
310+ @ property
305311 def name (self ) -> str :
306312 """:return: Name of our remote ref"""
307313 return self .ref .name
308314
309- @property
315+ @ property
310316 def commit (self ) -> Commit_ish :
311317 """:return: Commit of our remote ref"""
312318 return self .ref .commit
313319
314- @classmethod
320+ @ classmethod
315321 def _from_line (cls , repo : 'Repo' , line : str , fetch_line : str ) -> 'FetchInfo' :
316322 """Parse information from the given line as returned by git-fetch -v
317323 and return a new FetchInfo object representing this information.
318324
319- We can handle a line as follows
320- "%c %-*s %-*s -> %s%s"
325+ We can handle a line as follows:
326+ "%c %-\\ *s %-\\ *s -> %s%s"
321327
322- Where c is either ' ', !, +, -, *, or =
328+ Where c is either ' ', !, +, -, \\ *, or =
323329 ! means error
324330 + means success forcing update
325331 - means a tag was updated
@@ -334,6 +340,7 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo':
334340 raise ValueError ("Failed to parse line: %r" % line )
335341
336342 # parse lines
343+ remote_local_ref_str : str
337344 control_character , operation , local_remote_ref , remote_local_ref_str , note = match .groups ()
338345 assert is_flagKeyLiteral (control_character ), f"{ control_character } "
339346
@@ -375,7 +382,7 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo':
375382 # If we do not specify a target branch like master:refs/remotes/origin/master,
376383 # the fetch result is stored in FETCH_HEAD which destroys the rule we usually
377384 # have. In that case we use a symbolic reference which is detached
378- ref_type = None
385+ ref_type : Optional [ Type [ SymbolicReference ]] = None
379386 if remote_local_ref_str == "FETCH_HEAD" :
380387 ref_type = SymbolicReference
381388 elif ref_type_name == "tag" or is_tag_operation :
@@ -404,14 +411,15 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo':
404411 # by the 'ref/' prefix. Otherwise even a tag could be in refs/remotes, which is when it will have the
405412 # 'tags/' subdirectory in its path.
406413 # We don't want to test for actual existence, but try to figure everything out analytically.
407- ref_path = None # type : Optional[PathLike]
414+ ref_path : Optional [PathLike ] = None
408415 remote_local_ref_str = remote_local_ref_str .strip ()
416+
409417 if remote_local_ref_str .startswith (Reference ._common_path_default + "/" ):
410418 # always use actual type if we get absolute paths
411419 # Will always be the case if something is fetched outside of refs/remotes (if its not a tag)
412420 ref_path = remote_local_ref_str
413421 if ref_type is not TagReference and not \
414- remote_local_ref_str .startswith (RemoteReference ._common_path_default + "/" ):
422+ remote_local_ref_str .startswith (RemoteReference ._common_path_default + "/" ):
415423 ref_type = Reference
416424 # END downgrade remote reference
417425 elif ref_type is TagReference and 'tags/' in remote_local_ref_str :
@@ -430,6 +438,11 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo':
430438
431439 return cls (remote_local_ref , flags , note , old_commit , local_remote_ref )
432440
441+ @ classmethod
442+ def iter_items (cls , repo : 'Repo' , * args : Any , ** kwargs : Any
443+ ) -> NoReturn : # -> Iterator['FetchInfo']:
444+ raise NotImplementedError
445+
433446
434447class Remote (LazyMixin , IterableObj ):
435448
@@ -507,7 +520,7 @@ def exists(self) -> bool:
507520 return False
508521 # end
509522
510- @classmethod
523+ @ classmethod
511524 def iter_items (cls , repo : 'Repo' , * args : Any , ** kwargs : Any ) -> Iterator ['Remote' ]:
512525 """:return: Iterator yielding Remote objects of the given repository"""
513526 for section in repo .config_reader ("repository" ).sections ():
@@ -897,7 +910,7 @@ def push(self, refspec: Union[str, List[str], None] = None,
897910 universal_newlines = True , ** kwargs )
898911 return self ._get_push_info (proc , progress )
899912
900- @property
913+ @ property
901914 def config_reader (self ) -> SectionConstraint :
902915 """
903916 :return:
@@ -912,7 +925,7 @@ def _clear_cache(self) -> None:
912925 pass
913926 # END handle exception
914927
915- @property
928+ @ property
916929 def config_writer (self ) -> SectionConstraint :
917930 """
918931 :return: GitConfigParser compatible object able to write options for this remote.
0 commit comments