19
19
import threading
20
20
from collections import OrderedDict
21
21
from textwrap import dedent
22
+ from typing import Any , Dict , List , Optional
22
23
23
24
from git .compat import (
24
25
defenc ,
39
40
stream_copy ,
40
41
)
41
42
43
+ from .types import PathLike
44
+
42
45
execute_kwargs = {'istream' , 'with_extended_output' ,
43
46
'with_exceptions' , 'as_process' , 'stdout_as_string' ,
44
47
'output_stream' , 'with_stdout' , 'kill_after_timeout' ,
@@ -516,7 +519,7 @@ def __del__(self):
516
519
self ._stream .read (bytes_left + 1 )
517
520
# END handle incomplete read
518
521
519
- def __init__ (self , working_dir = None ):
522
+ def __init__ (self , working_dir : Optional [ PathLike ] = None ) -> None :
520
523
"""Initialize this instance with:
521
524
522
525
:param working_dir:
@@ -525,12 +528,12 @@ def __init__(self, working_dir=None):
525
528
It is meant to be the working tree directory if available, or the
526
529
.git directory in case of bare repositories."""
527
530
super (Git , self ).__init__ ()
528
- self ._working_dir = expand_path (working_dir )
531
+ self ._working_dir = expand_path (working_dir ) if working_dir is not None else None
529
532
self ._git_options = ()
530
- self ._persistent_git_options = []
533
+ self ._persistent_git_options = [] # type: List[str]
531
534
532
535
# Extra environment variables to pass to git commands
533
- self ._environment = {}
536
+ self ._environment = {} # type: Dict[str, Any]
534
537
535
538
# cached command slots
536
539
self .cat_file_header = None
@@ -544,7 +547,7 @@ def __getattr__(self, name):
544
547
return LazyMixin .__getattr__ (self , name )
545
548
return lambda * args , ** kwargs : self ._call_process (name , * args , ** kwargs )
546
549
547
- def set_persistent_git_options (self , ** kwargs ):
550
+ def set_persistent_git_options (self , ** kwargs ) -> None :
548
551
"""Specify command line options to the git executable
549
552
for subsequent subcommand calls
550
553
0 commit comments