diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-05 15:42:46 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-05 15:42:46 +0100 |
commit | 23b5d6b434551e1df1c954ab5d2c0166f080fba8 (patch) | |
tree | f7e003b12062568acb4946d3a3bbf6f640db06a1 /git/config.py | |
parent | 41e9781b640983cd3f38223e5b349eb299a0e4f6 (diff) | |
download | gitpython-23b5d6b434551e1df1c954ab5d2c0166f080fba8.tar.gz |
Add types to submodule.util.py
Diffstat (limited to 'git/config.py')
-rw-r--r-- | git/config.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/git/config.py b/git/config.py index 6931dd12..bfdfd916 100644 --- a/git/config.py +++ b/git/config.py @@ -38,6 +38,7 @@ from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, TBD, assert if TYPE_CHECKING: from git.repo.base import Repo + from io import BytesIO # ------------------------------------------------------------- @@ -274,7 +275,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje # list of RawConfigParser methods able to change the instance _mutating_methods_ = ("add_section", "remove_section", "remove_option", "set") - def __init__(self, file_or_files: Union[None, PathLike, IO, Sequence[Union[PathLike, IO]]] = None, + def __init__(self, file_or_files: Union[None, PathLike, BytesIO, Sequence[Union[PathLike, BytesIO]]] = None, read_only: bool = True, merge_includes: bool = True, config_level: Union[Lit_config_levels, None] = None, repo: Union['Repo', None] = None) -> None: @@ -303,7 +304,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje self._proxies = self._dict() if file_or_files is not None: - self._file_or_files: Union[PathLike, IO, Sequence[Union[PathLike, IO]]] = file_or_files + self._file_or_files: Union[PathLike, 'BytesIO', Sequence[Union[PathLike, 'BytesIO']]] = file_or_files else: if config_level is None: if read_only: @@ -650,7 +651,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje a file lock""" self._assure_writable("write") if not self._dirty: - return + return None if isinstance(self._file_or_files, (list, tuple)): raise AssertionError("Cannot write back if there is not exactly a single file to write to, have %i files" @@ -675,7 +676,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje with open(fp, "wb") as fp_open: self._write(fp_open) else: - fp = cast(IO, fp) + fp = cast(BytesIO, fp) fp.seek(0) # make sure we do not overwrite into an existing file if hasattr(fp, 'truncate'): |