From 5b0028e1e75e1ee0eea63ba78cb3160d49c1f3a3 Mon Sep 17 00:00:00 2001 From: yobmod Date: Sun, 28 Feb 2021 21:16:14 +0000 Subject: start add types to util.py --- git/cmd.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 050efaed..bac16217 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -19,6 +19,7 @@ import sys import threading from collections import OrderedDict from textwrap import dedent +from typing import Any, Dict, List, Optional from git.compat import ( defenc, @@ -39,6 +40,8 @@ from .util import ( stream_copy, ) +from .types import PathLike + execute_kwargs = {'istream', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', 'output_stream', 'with_stdout', 'kill_after_timeout', @@ -516,7 +519,7 @@ class Git(LazyMixin): self._stream.read(bytes_left + 1) # END handle incomplete read - def __init__(self, working_dir=None): + def __init__(self, working_dir: Optional[PathLike]=None) -> None: """Initialize this instance with: :param working_dir: @@ -525,12 +528,12 @@ class Git(LazyMixin): It is meant to be the working tree directory if available, or the .git directory in case of bare repositories.""" super(Git, self).__init__() - self._working_dir = expand_path(working_dir) + self._working_dir = expand_path(working_dir) if working_dir is not None else None self._git_options = () - self._persistent_git_options = [] + self._persistent_git_options = [] # type: List[str] # Extra environment variables to pass to git commands - self._environment = {} + self._environment = {} # type: Dict[str, Any] # cached command slots self.cat_file_header = None @@ -544,7 +547,7 @@ class Git(LazyMixin): return LazyMixin.__getattr__(self, name) return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) - def set_persistent_git_options(self, **kwargs): + def set_persistent_git_options(self, **kwargs) -> None: """Specify command line options to the git executable for subsequent subcommand calls -- cgit v1.2.1