1515 PIPE
1616)
1717import subprocess
18- import sys
1918import threading
2019from textwrap import dedent
2120
@@ -539,7 +538,7 @@ def __iter__(self) -> 'Git.CatFileContentStream':
539538 return self
540539
541540 def __next__ (self ) -> bytes :
542- return self . next ()
541+ return next (self )
543542
544543 def next (self ) -> bytes :
545544 line = self .readline ()
@@ -566,11 +565,11 @@ def __init__(self, working_dir: Union[None, PathLike] = None):
566565 .git directory in case of bare repositories."""
567566 super (Git , self ).__init__ ()
568567 self ._working_dir = expand_path (working_dir )
569- self ._git_options = () # type : Union[List[str], Tuple[str, ...]]
570- self ._persistent_git_options = [] # type: List[str ]
568+ self ._git_options : Union [List [str ], Tuple [str , ...]] = ()
569+ self ._persistent_git_options : List [ str ] = [ ]
571570
572571 # Extra environment variables to pass to git commands
573- self ._environment = {} # type : Dict[str, str]
572+ self ._environment : Dict [str , str ] = {}
574573
575574 # cached command slots
576575 self .cat_file_header = None
@@ -604,35 +603,35 @@ def _set_cache_(self, attr: str) -> None:
604603 process_version = self ._call_process ('version' ) # should be as default *args and **kwargs used
605604 version_numbers = process_version .split (' ' )[2 ]
606605
607- self ._version_info = tuple (
608- int (n ) for n in version_numbers .split ('.' )[:4 ] if n .isdigit ()
609- ) # type: Tuple[int, int, int, int] # type: ignore
606+ self ._version_info = cast ( Tuple [ int , int , int , int ],
607+ tuple ( int (n ) for n in version_numbers .split ('.' )[:4 ] if n .isdigit () )
608+ )
610609 else :
611610 super (Git , self )._set_cache_ (attr )
612611 # END handle version info
613612
614- @property
613+ @ property
615614 def working_dir (self ) -> Union [None , PathLike ]:
616615 """:return: Git directory we are working on"""
617616 return self ._working_dir
618617
619- @property
618+ @ property
620619 def version_info (self ) -> Tuple [int , int , int , int ]:
621620 """
622621 :return: tuple(int, int, int, int) tuple with integers representing the major, minor
623622 and additional version numbers as parsed from git version.
624623 This value is generated on demand and is cached"""
625624 return self ._version_info
626625
627- @overload
626+ @ overload
628627 def execute (self ,
629628 command : Union [str , Sequence [Any ]],
630629 * ,
631630 as_process : Literal [True ]
632631 ) -> 'AutoInterrupt' :
633632 ...
634633
635- @overload
634+ @ overload
636635 def execute (self ,
637636 command : Union [str , Sequence [Any ]],
638637 * ,
@@ -641,7 +640,7 @@ def execute(self,
641640 ) -> Union [str , Tuple [int , str , str ]]:
642641 ...
643642
644- @overload
643+ @ overload
645644 def execute (self ,
646645 command : Union [str , Sequence [Any ]],
647646 * ,
@@ -650,7 +649,7 @@ def execute(self,
650649 ) -> Union [bytes , Tuple [int , bytes , str ]]:
651650 ...
652651
653- @overload
652+ @ overload
654653 def execute (self ,
655654 command : Union [str , Sequence [Any ]],
656655 * ,
@@ -660,7 +659,7 @@ def execute(self,
660659 ) -> str :
661660 ...
662661
663- @overload
662+ @ overload
664663 def execute (self ,
665664 command : Union [str , Sequence [Any ]],
666665 * ,
@@ -799,10 +798,7 @@ def execute(self,
799798 if kill_after_timeout :
800799 raise GitCommandError (redacted_command , '"kill_after_timeout" feature is not supported on Windows.' )
801800 else :
802- if sys .version_info [0 ] > 2 :
803- cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
804- else :
805- cmd_not_found_exception = OSError
801+ cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
806802 # end handle
807803
808804 stdout_sink = (PIPE
@@ -872,8 +868,8 @@ def _kill_process(pid: int) -> None:
872868
873869 # Wait for the process to return
874870 status = 0
875- stdout_value = b'' # type : Union[str, bytes]
876- stderr_value = b'' # type : Union[str, bytes]
871+ stdout_value : Union [str , bytes ] = b''
872+ stderr_value : Union [str , bytes ] = b''
877873 newline = "\n " if universal_newlines else b"\n "
878874 try :
879875 if output_stream is None :
@@ -1070,8 +1066,8 @@ def _call_process(self, method: str, *args: Any, **kwargs: Any
10701066 It contains key-values for the following:
10711067 - the :meth:`execute()` kwds, as listed in :var:`execute_kwargs`;
10721068 - "command options" to be converted by :meth:`transform_kwargs()`;
1073- - the `'insert_kwargs_after'` key which its value must match one of ``*args``,
1074- and any cmd-options will be appended after the matched arg.
1069+ - the `'insert_kwargs_after'` key which its value must match one of ``*args``
1070+ and any cmd-options will be appended after the matched arg.
10751071
10761072 Examples::
10771073
@@ -1149,7 +1145,7 @@ def _prepare_ref(self, ref: AnyStr) -> bytes:
11491145 # required for command to separate refs on stdin, as bytes
11501146 if isinstance (ref , bytes ):
11511147 # Assume 40 bytes hexsha - bin-to-ascii for some reason returns bytes, not text
1152- refstr = ref .decode ('ascii' ) # type: str
1148+ refstr : str = ref .decode ('ascii' )
11531149 elif not isinstance (ref , str ):
11541150 refstr = str (ref ) # could be ref-object
11551151 else :
0 commit comments