summaryrefslogtreecommitdiff
path: root/git/repo/fun.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/repo/fun.py')
-rw-r--r--git/repo/fun.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/git/repo/fun.py b/git/repo/fun.py
index e96b62e0..7d5c7823 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -1,5 +1,4 @@
"""Package with general repository related functions"""
-from git.refs.tag import Tag
import os
import stat
from string import digits
@@ -19,11 +18,14 @@ from git.cmd import Git
# Typing ----------------------------------------------------------------------
from typing import Union, Optional, cast, TYPE_CHECKING
-from git.types import PathLike
+
+
if TYPE_CHECKING:
+ from git.types import PathLike
from .base import Repo
from git.db import GitCmdObjectDB
from git.objects import Commit, TagObject, Blob, Tree
+ from git.refs.tag import Tag
# ----------------------------------------------------------------------------
@@ -37,7 +39,7 @@ def touch(filename: str) -> str:
return filename
-def is_git_dir(d: PathLike) -> bool:
+def is_git_dir(d: 'PathLike') -> bool:
""" This is taken from the git setup.c:is_git_directory
function.
@@ -59,7 +61,7 @@ def is_git_dir(d: PathLike) -> bool:
return False
-def find_worktree_git_dir(dotgit: PathLike) -> Optional[str]:
+def find_worktree_git_dir(dotgit: 'PathLike') -> Optional[str]:
"""Search for a gitdir for this worktree."""
try:
statbuf = os.stat(dotgit)
@@ -78,7 +80,7 @@ def find_worktree_git_dir(dotgit: PathLike) -> Optional[str]:
return None
-def find_submodule_git_dir(d: PathLike) -> Optional[PathLike]:
+def find_submodule_git_dir(d: 'PathLike') -> Optional['PathLike']:
"""Search for a submodule repo."""
if is_git_dir(d):
return d
@@ -122,7 +124,7 @@ def name_to_object(repo: 'Repo', name: str, return_ref: bool = False
:param return_ref: if name specifies a reference, we will return the reference
instead of the object. Otherwise it will raise BadObject or BadName
"""
- hexsha = None # type: Union[None, str, bytes]
+ hexsha: Union[None, str, bytes] = None
# is it a hexsha ? Try the most common ones, which is 7 to 40
if repo.re_hexsha_shortened.match(name):
@@ -162,7 +164,7 @@ def name_to_object(repo: 'Repo', name: str, return_ref: bool = False
return Object.new_from_sha(repo, hex_to_bin(hexsha))
-def deref_tag(tag: Tag) -> 'TagObject':
+def deref_tag(tag: 'Tag') -> 'TagObject':
"""Recursively dereference a tag and return the resulting object"""
while True:
try: