Skip to content

Commit 3578355

Browse files
committed
Add cast(Repo, mrepo) in try block
1 parent 2a6a2e2 commit 3578355

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

git/objects/submodule/base.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
find_first_remote_branch
4848
)
4949

50-
from git.repo import Repo
5150

5251
# typing ----------------------------------------------------------------------
53-
from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING
52+
from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast
5453
from typing import Any, Iterator, Union
5554

5655
from git.types import Commit_ish, PathLike, TBD
5756

5857
if TYPE_CHECKING:
58+
from git.repo import Repo
5959
from git.index import IndexFile
6060

6161

@@ -589,7 +589,8 @@ def update(self, recursive: bool = False, init: bool = True, to_latest_revision:
589589
if not dry_run:
590590
# see whether we have a valid branch to checkout
591591
try:
592-
assert isinstance(mrepo, Repo)
592+
# assert isinstance(mrepo, Repo) # cant do this cos of circular import
593+
mrepo = cast('Repo', mrepo) # Try TypeGuard wirh hasattr?
593594
# find a remote which has our branch - we try to be flexible
594595
remote_branch = find_first_remote_branch(mrepo.remotes, self.branch_name)
595596
local_branch = mkhead(mrepo, self.branch_path)

0 commit comments

Comments
 (0)