diff options
Diffstat (limited to 'git/objects')
-rw-r--r-- | git/objects/commit.py | 21 | ||||
-rw-r--r-- | git/objects/submodule/base.py | 14 | ||||
-rw-r--r-- | git/objects/submodule/util.py | 2 | ||||
-rw-r--r-- | git/objects/tree.py | 6 |
4 files changed, 23 insertions, 20 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 diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index d5ba118f..29212167 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -965,13 +965,12 @@ class Submodule(IndexObject, TraversableIterableObj): # now git config - need the config intact, otherwise we can't query # information anymore - writer: Union[GitConfigParser, SectionConstraint] - with self.repo.config_writer() as writer: - writer.remove_section(sm_section(self.name)) + with self.repo.config_writer() as gcp_writer: + gcp_writer.remove_section(sm_section(self.name)) - with self.config_writer() as writer: - writer.remove_section() + with self.config_writer() as sc_writer: + sc_writer.remove_section() # END delete configuration return self @@ -1024,7 +1023,8 @@ class Submodule(IndexObject, TraversableIterableObj): return self @unbare_repo - def config_writer(self, index: Union['IndexFile', None] = None, write: bool = True) -> SectionConstraint: + def config_writer(self, index: Union['IndexFile', None] = None, write: bool = True + ) -> SectionConstraint['SubmoduleConfigParser']: """:return: a config writer instance allowing you to read and write the data belonging to this submodule into the .gitmodules file. @@ -1201,7 +1201,7 @@ class Submodule(IndexObject, TraversableIterableObj): """ return self._name - def config_reader(self) -> SectionConstraint: + def config_reader(self) -> SectionConstraint[SubmoduleConfigParser]: """ :return: ConfigReader instance which allows you to qurey the configuration values of this submodule, as provided by the .gitmodules file diff --git a/git/objects/submodule/util.py b/git/objects/submodule/util.py index a776af88..cc1cd60a 100644 --- a/git/objects/submodule/util.py +++ b/git/objects/submodule/util.py @@ -100,7 +100,7 @@ class SubmoduleConfigParser(GitConfigParser): #} END interface #{ Overridden Methods - def write(self) -> None: + def write(self) -> None: # type: ignore[override] rval: None = super(SubmoduleConfigParser, self).write() self.flush_to_index() return rval diff --git a/git/objects/tree.py b/git/objects/tree.py index dd1fe783..70f36af5 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -24,7 +24,7 @@ from .fun import ( from typing import (Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type, Union, cast, TYPE_CHECKING) -from git.types import PathLike, TypeGuard, Literal +from git.types import PathLike, Literal if TYPE_CHECKING: from git.repo import Repo @@ -36,8 +36,8 @@ TraversedTreeTup = Union[Tuple[Union['Tree', None], IndexObjUnion, Tuple['Submodule', 'Submodule']]] -def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: - return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) +# def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: +# return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) #-------------------------------------------------------- |