diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-07-25 10:22:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 10:22:22 +0800 |
commit | c5e6ae25b9169e5ef070d791fb9d620e2357e24e (patch) | |
tree | 680964b9eb8cc102cd1e79f8aeadde6620fc0eb6 /git/objects/commit.py | |
parent | 0c1446da2d1ce0382cbc65d7a2aad4483783ae74 (diff) | |
parent | be7bb868279f61d55594059690904baabe30503c (diff) | |
download | gitpython-c5e6ae25b9169e5ef070d791fb9d620e2357e24e.tar.gz |
Merge pull request #1298 from Yobmod/main
Revert use of Typeguard and therefore typing-extensions==3.10.0.0
Diffstat (limited to 'git/objects/commit.py')
-rw-r--r-- | git/objects/commit.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py index 11cf52a5..884f6522 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -39,9 +39,9 @@ import logging # typing ------------------------------------------------------------------ -from typing import Any, IO, Iterator, List, Sequence, Tuple, Union, TYPE_CHECKING +from typing import Any, IO, Iterator, List, Sequence, Tuple, Union, TYPE_CHECKING, cast -from git.types import PathLike, TypeGuard, Literal +from git.types import PathLike, Literal if TYPE_CHECKING: from git.repo import Repo @@ -323,16 +323,18 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable): :param proc: git-rev-list process instance - one sha per line :return: iterator returning Commit objects""" - def is_proc(inp) -> TypeGuard[Popen]: - return hasattr(proc_or_stream, 'wait') and not hasattr(proc_or_stream, 'readline') + # def is_proc(inp) -> TypeGuard[Popen]: + # return hasattr(proc_or_stream, 'wait') and not hasattr(proc_or_stream, 'readline') - def is_stream(inp) -> TypeGuard[IO]: - return hasattr(proc_or_stream, 'readline') + # def is_stream(inp) -> TypeGuard[IO]: + # return hasattr(proc_or_stream, 'readline') - if is_proc(proc_or_stream): + if hasattr(proc_or_stream, 'wait'): + proc_or_stream = cast(Popen, proc_or_stream) if proc_or_stream.stdout is not None: stream = proc_or_stream.stdout - elif is_stream(proc_or_stream): + elif hasattr(proc_or_stream, 'readline'): + proc_or_stream = cast(IO, proc_or_stream) stream = proc_or_stream readline = stream.readline @@ -351,7 +353,8 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable): # END for each line in stream # TODO: Review this - it seems process handling got a bit out of control # due to many developers trying to fix the open file handles issue - if is_proc(proc_or_stream): + if hasattr(proc_or_stream, 'wait'): + proc_or_stream = cast(Popen, proc_or_stream) finalize_process(proc_or_stream) @ classmethod |