diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 40107f139..3983a7ef0 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -6,7 +6,7 @@ import shlex from collections import OrderedDict from contextlib import contextmanager from functools import partialmethod -from typing import Iterable, Optional +from typing import Iterable, List, Optional, Set from funcy import cached_property, first from pathspec.patterns import GitWildMatchPattern @@ -38,8 +38,8 @@ class Git(Base): def __init__( self, *args, backends: Optional[Iterable[str]] = None, **kwargs ): - self.ignored_paths = [] - self.files_to_track = set() + self.ignored_paths: List[str] = [] + self.files_to_track: Set[str] = set() selected = backends if backends else self.DEFAULT_BACKENDS.keys() self.backends = OrderedDict( @@ -248,7 +248,7 @@ class Git(Base): self.add(self.files_to_track) - def track_file(self, path): + def track_file(self, path: str): self.files_to_track.add(path) def belongs_to_scm(self, path): diff --git a/dvc/scm/git/backend/dulwich.py b/dvc/scm/git/backend/dulwich.py index 8a310aa4e..f3c4b0543 100644 --- a/dvc/scm/git/backend/dulwich.py +++ b/dvc/scm/git/backend/dulwich.py @@ -334,7 +334,7 @@ class DulwichBackend(BaseGitBackend): # pylint:disable=abstract-method raise SCMError("Git failed to push '{src}' to '{url}'") from exc def _push_dest_refs( - self, src: str, dest: str + self, src: Optional[str], dest: str ) -> Tuple[Iterable[bytes], Iterable[bytes]]: from dulwich.objects import ZERO_SHA diff --git a/dvc/scm/git/backend/gitpython.py b/dvc/scm/git/backend/gitpython.py index c2002905f..c5b711b2d 100644 --- a/dvc/scm/git/backend/gitpython.py +++ b/dvc/scm/git/backend/gitpython.py @@ -408,9 +408,7 @@ class GitPythonBackend(BaseGitBackend): # pylint:disable=abstract-method from git import Reference for ref in Reference.iter_items(self.repo, common_path=base): - if base and base.endswith("/"): - base = base[:-1] - yield "/".join([base, ref.name]) + yield ref.path def iter_remote_refs(self, url: str, base: Optional[str] = None): raise NotImplementedError