From 39d37d550963a6a64e66ba3d6b9f4b077270a3ad Mon Sep 17 00:00:00 2001 From: Yobmod Date: Sat, 31 Jul 2021 22:26:20 +0100 Subject: replace some TBDs wiht runtime types --- git/cmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index f8212745..cbfde74c 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -68,7 +68,7 @@ __all__ = ('Git',) # Documentation ## @{ -def handle_process_output(process: subprocess.Popen, +def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'], stdout_handler: Union[None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None], @@ -77,7 +77,7 @@ def handle_process_output(process: subprocess.Popen, Callable[[AnyStr], None], Callable[[List[AnyStr]], None]], finalizer: Union[None, - Callable[[subprocess.Popen], None]] = None, + Callable[[Union[subprocess.Popen, 'Git.AutoInterrupt']], None]] = None, decode_streams: bool = True) -> None: """Registers for notifications to learn that process output is ready to read, and dispatches lines to the respective line handlers. -- cgit v1.2.1 From c878771e3a31c983a0c3468396ed33a532f87e98 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Sat, 31 Jul 2021 22:59:11 +0100 Subject: replace more TBDs wiht runtime types --- git/cmd.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index cbfde74c..85a5fbe9 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -421,15 +421,15 @@ class Git(LazyMixin): return getattr(self.proc, attr) # TODO: Bad choice to mimic `proc.wait()` but with different args. - def wait(self, stderr: Union[None, bytes] = b'') -> int: + def wait(self, stderr: Union[None, str, bytes] = b'') -> int: """Wait for the process and return its status code. :param stderr: Previously read value of stderr, in case stderr is already closed. :warn: may deadlock if output or error pipes are used and not handled separately. :raise GitCommandError: if the return status is not 0""" if stderr is None: - stderr = b'' - stderr = force_bytes(data=stderr, encoding='utf-8') + stderr_b = b'' + stderr_b = force_bytes(data=stderr, encoding='utf-8') if self.proc is not None: status = self.proc.wait() @@ -437,11 +437,11 @@ class Git(LazyMixin): def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> bytes: if stream: try: - return stderr + force_bytes(stream.read()) + return stderr_b + force_bytes(stream.read()) except ValueError: - return stderr or b'' + return stderr_b or b'' else: - return stderr or b'' + return stderr_b or b'' if status != 0: errstr = read_all_from_possibly_closed_stream(self.proc.stderr) -- cgit v1.2.1 From 2163322ef62fa97573ac94298261161fd9721993 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 2 Aug 2021 14:00:33 +0100 Subject: increase mypy strictness (warn unused ignored) --- git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 85a5fbe9..9d070367 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -164,7 +164,7 @@ CREATE_NO_WINDOW = 0x08000000 ## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards, # see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal -PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore[attr-defined] +PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP if is_win else 0) -- cgit v1.2.1 From 91fce331de16de6039c94cd4d7314184a5763e61 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 2 Aug 2021 14:56:03 +0100 Subject: increase mypy strictness (warn unused ignored and warn unreachable) --- git/cmd.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 9d070367..e690dc12 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -42,7 +42,7 @@ from .util import ( from typing import (Any, AnyStr, BinaryIO, Callable, Dict, IO, Iterator, List, Mapping, Sequence, TYPE_CHECKING, TextIO, Tuple, Union, cast, overload) -from git.types import PathLike, Literal +from git.types import PathLike, Literal, TBD if TYPE_CHECKING: from git.repo.base import Repo @@ -575,8 +575,8 @@ class Git(LazyMixin): self._environment: Dict[str, str] = {} # cached command slots - self.cat_file_header = None - self.cat_file_all = None + self.cat_file_header: Union[None, TBD] = None + self.cat_file_all: Union[None, TBD] = None def __getattr__(self, name: str) -> Any: """A convenience method as it allows to call the command as if it was @@ -1012,8 +1012,6 @@ class Git(LazyMixin): @classmethod def __unpack_args(cls, arg_list: Sequence[str]) -> List[str]: - if not isinstance(arg_list, (list, tuple)): - return [str(arg_list)] outlist = [] for arg in arg_list: -- cgit v1.2.1 From 15ace876d98d70c48a354ec8f526d6c8ad6b8d97 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 2 Aug 2021 15:30:15 +0100 Subject: rmv 3.6 from CI matrix --- git/cmd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index e690dc12..78fa3c9d 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -164,8 +164,7 @@ CREATE_NO_WINDOW = 0x08000000 ## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards, # see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal -PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP - if is_win else 0) +PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP if is_win else 0) class Git(LazyMixin): -- cgit v1.2.1 From bef218246c9935f0c31b23a17d1a02ac3810301d Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 2 Aug 2021 15:41:17 +0100 Subject: rmv 3.6 from setup.py --- git/cmd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 78fa3c9d..18a2bec1 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -164,7 +164,8 @@ CREATE_NO_WINDOW = 0x08000000 ## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards, # see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal -PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP if is_win else 0) +PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore[attr-defined] + if is_win else 0) # mypy error if not windows class Git(LazyMixin): -- cgit v1.2.1 From 270c3d7d4bbe4c606049bfd8af53da1bc3df4ad4 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 2 Aug 2021 15:48:17 +0100 Subject: rmv 3.6 README --- git/cmd.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 18a2bec1..b84c43df 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -1014,13 +1014,12 @@ class Git(LazyMixin): def __unpack_args(cls, arg_list: Sequence[str]) -> List[str]: outlist = [] - for arg in arg_list: - if isinstance(arg_list, (list, tuple)): + if isinstance(arg_list, (list, tuple)): + for arg in arg_list: outlist.extend(cls.__unpack_args(arg)) - # END recursion - else: - outlist.append(str(arg)) - # END for each arg + else: + outlist.append(str(arg_list)) + return outlist def __call__(self, **kwargs: Any) -> 'Git': -- cgit v1.2.1