3636from git .remote import Remote
3737from git .repo .base import Repo
3838from git .config import GitConfigParser ,SectionConstraint
39- from git .objects .base import IndexObject
39+ # from git.objects.base import IndexObject
4040
4141
4242from .types import (Literal ,SupportsIndex ,# because behind py version guards
43- PathLike ,HSH_TD ,Total_TD ,Files_TD )# aliases
43+ PathLike ,HSH_TD ,Total_TD ,Files_TD ,# aliases
44+ Has_id_attribute )
4445
45- T_IterableObj = TypeVar ('T_IterableObj' ,bound = Union ['IterableObj' ,'IndexObject ' ],covariant = True )
46+ T_IterableObj = TypeVar ('T_IterableObj' ,bound = Union ['IterableObj' ,'Has_id_attribute ' ],covariant = True )
4647# So IterableList[Head] is subtype of IterableList[IterableObj]
4748
4849# ---------------------------------------------------------------------
8283HIDE_WINDOWS_KNOWN_ERRORS = is_win and os .environ .get ('HIDE_WINDOWS_KNOWN_ERRORS' ,True )
8384HIDE_WINDOWS_FREEZE_ERRORS = is_win and os .environ .get ('HIDE_WINDOWS_FREEZE_ERRORS' ,True )
8485
85- #{ Utility Methods
86+ # { Utility Methods
8687
8788T = TypeVar ('T' )
8889
@@ -247,7 +248,7 @@ def is_exec(fpath: str) -> bool:
247248
248249def _cygexpath (drive :Optional [str ],path :str )-> str :
249250if osp .isabs (path )and not drive :
250- ## Invoked from `cygpath()` directly with `D:Apps\123`?
251+ # Invoked from `cygpath()` directly with `D:Apps\123`?
251252# It's an error, leave it alone just slashes)
252253p = path # convert to str if AnyPath given
253254else :
@@ -265,8 +266,8 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
265266
266267
267268_cygpath_parsers = (
268- ## See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
269- ## and: https://www.cygwin.com/cygwin-ug-net/using.html#unc-paths
269+ # See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
270+ # and: https://www.cygwin.com/cygwin-ug-net/using.html#unc-paths
270271 (re .compile (r"\\\\\?\\UNC\\([^\\]+)\\([^\\]+)(?:\\(.*))?" ),
271272 (lambda server ,share ,rest_path :'//%s/%s/%s' % (server ,share ,rest_path .replace ('\\ ' ,'/' ))),
272273False
@@ -297,7 +298,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
297298def cygpath (path :str )-> str :
298299"""Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment."""
299300path = str (path )# ensure is str and not AnyPath.
300- #Fix to use Paths when 3.5 dropped. or to be just str if only for urls?
301+ # Fix to use Paths when 3.5 dropped. or to be just str if only for urls?
301302if not path .startswith (('/cygdrive' ,'//' )):
302303for regex ,parser ,recurse in _cygpath_parsers :
303304match = regex .match (path )
@@ -357,7 +358,7 @@ def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:
357358res = py_where (git_executable )
358359git_dir = osp .dirname (res [0 ])if res else ""
359360
360- ## Just a name given, not a real path.
361+ # Just a name given, not a real path.
361362uname_cmd = osp .join (git_dir ,'uname' )
362363process = subprocess .Popen ([uname_cmd ],stdout = subprocess .PIPE ,
363364universal_newlines = True )
@@ -378,7 +379,7 @@ def get_user_id() -> str:
378379
379380def finalize_process (proc :subprocess .Popen ,** kwargs :Any )-> None :
380381"""Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
381- ## TODO: No close proc-streams??
382+ # TODO: No close proc-streams??
382383proc .wait (** kwargs )
383384
384385
@@ -432,9 +433,9 @@ def remove_password_if_present(cmdline):
432433return new_cmdline
433434
434435
435- #} END utilities
436+ # } END utilities
436437
437- #{ Classes
438+ # { Classes
438439
439440
440441class RemoteProgress (object ):
@@ -984,15 +985,15 @@ def __contains__(self, attr: object) -> bool:
984985return False
985986# END handle membership
986987
987- def __getattr__ (self ,attr :str )-> Any :
988+ def __getattr__ (self ,attr :str )-> T_IterableObj :
988989attr = self ._prefix + attr
989990for item in self :
990991if getattr (item ,self ._id_attr )== attr :
991992return item
992993# END for each item
993994return list .__getattribute__ (self ,attr )
994995
995- def __getitem__ (self ,index :Union [SupportsIndex ,int ,slice ,str ])-> Any :
996+ def __getitem__ (self ,index :Union [SupportsIndex ,int ,slice ,str ])-> 'T_IterableObj' : # type: ignore
996997
997998assert isinstance (index , (int ,str ,slice )),"Index of IterableList should be an int or str"
998999
@@ -1007,7 +1008,7 @@ def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> Any:
10071008raise IndexError ("No item found with id %r" % (self ._prefix + index ))from e
10081009# END handle getattr
10091010
1010- def __delitem__ (self ,index :Union [SupportsIndex ,int ,slice ,str ])-> Any :
1011+ def __delitem__ (self ,index :Union [SupportsIndex ,int ,slice ,str ])-> None :
10111012
10121013assert isinstance (index , (int ,str )),"Index of IterableList should be an int or str"
10131014
@@ -1101,7 +1102,7 @@ def iter_items(cls, repo: 'Repo', *args: Any, **kwargs: Any
11011102 :return: iterator yielding Items"""
11021103raise NotImplementedError ("To be implemented by Subclass" )
11031104
1104- #} END classes
1105+ # } END classes
11051106
11061107
11071108class NullHandler (logging .Handler ):