summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/config.py6
-rw-r--r--git/objects/submodule/base.py2
-rw-r--r--git/objects/submodule/root.py15
-rw-r--r--git/refs/head.py11
4 files changed, 24 insertions, 10 deletions
diff --git a/git/config.py b/git/config.py
index bfdfd916..0ce3e831 100644
--- a/git/config.py
+++ b/git/config.py
@@ -275,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, BytesIO, Sequence[Union[PathLike, BytesIO]]] = 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:
@@ -667,7 +667,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje
fp = self._file_or_files
# we have a physical file on disk, so get a lock
- is_file_lock = isinstance(fp, (str, IOBase)) # can't use Pathlike until 3.5 dropped
+ is_file_lock = isinstance(fp, (str, os.PathLike, IOBase)) # can't use Pathlike until 3.5 dropped
if is_file_lock and self._lock is not None: # else raise Error?
self._lock._obtain_lock()
@@ -676,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(BytesIO, fp)
+ fp = cast('BytesIO', fp)
fp.seek(0)
# make sure we do not overwrite into an existing file
if hasattr(fp, 'truncate'):
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index 25f88b37..7cd4356e 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -392,7 +392,7 @@ class Submodule(IndexObject, TraversableIterableObj):
if sm.exists():
# reretrieve submodule from tree
try:
- sm = repo.head.commit.tree[path]
+ sm = repo.head.commit.tree[str(path)]
sm._name = name
return sm
except KeyError:
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index 0af48710..c6746ad8 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -10,6 +10,15 @@ import git
import logging
+# typing -------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from git.repo import Repo
+
+# ----------------------------------------------------------------------------
+
__all__ = ["RootModule", "RootUpdateProgress"]
log = logging.getLogger('git.objects.submodule.root')
@@ -42,7 +51,7 @@ class RootModule(Submodule):
k_root_name = '__ROOT__'
- def __init__(self, repo):
+ def __init__(self, repo: 'Repo'):
# repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
super(RootModule, self).__init__(
repo,
@@ -55,7 +64,7 @@ class RootModule(Submodule):
branch_path=git.Head.to_full_path(self.k_head_default)
)
- def _clear_cache(self):
+ def _clear_cache(self) -> None:
"""May not do anything"""
pass
@@ -343,7 +352,7 @@ class RootModule(Submodule):
return self
- def module(self):
+ def module(self) -> 'Repo':
""":return: the actual repository containing the submodules"""
return self.repo
#} END interface
diff --git a/git/refs/head.py b/git/refs/head.py
index c698004d..97c8e6a1 100644
--- a/git/refs/head.py
+++ b/git/refs/head.py
@@ -5,9 +5,13 @@ from git.exc import GitCommandError
from .symbolic import SymbolicReference
from .reference import Reference
-from typing import Union
+from typing import Union, TYPE_CHECKING
+
from git.types import Commit_ish
+if TYPE_CHECKING:
+ from git.repo import Repo
+
__all__ = ["HEAD", "Head"]
@@ -25,12 +29,13 @@ class HEAD(SymbolicReference):
_ORIG_HEAD_NAME = 'ORIG_HEAD'
__slots__ = ()
- def __init__(self, repo, path=_HEAD_NAME):
+ def __init__(self, repo: 'Repo', path=_HEAD_NAME):
if path != self._HEAD_NAME:
raise ValueError("HEAD instance must point to %r, got %r" % (self._HEAD_NAME, path))
super(HEAD, self).__init__(repo, path)
+ self.commit: 'Commit_ish'
- def orig_head(self):
+ def orig_head(self) -> 'SymbolicReference':
"""
:return: SymbolicReference pointing at the ORIG_HEAD, which is maintained
to contain the previous value of HEAD"""