Skip to content

Commit

Permalink
fix type hints (#9863)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Aug 22, 2023
1 parent fc9af7a commit 0342e4f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def __init__(
): # pylint: disable=super-init-not-called
from dvc.fs import LocalFileSystem

dvc_dir = os.fspath(dvc_dir) if dvc_dir else None
self.dvc_dir = dvc_dir
self.wfs = LocalFileSystem()
self.fs = fs or self.wfs
Expand Down
3 changes: 2 additions & 1 deletion dvc/fs/dvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(
self.repo_factory = repo_factory

def _getcwd():
relparts = ()
relparts: Tuple[str, ...] = ()
assert repo is not None
if repo.fs.path.isin(repo.fs.path.getcwd(), repo.root_dir):
relparts = repo.fs.path.relparts(repo.fs.path.getcwd(), repo.root_dir)
Expand All @@ -163,6 +163,7 @@ def _getcwd():
self._datafss[key] = DataFileSystem(index=repo.index.data["repo"])

def _get_key(self, path: "StrPath") -> Key:
path = os.fspath(path)
parts = self.repo.fs.path.relparts(path, self.repo.root_dir)
if parts == (os.curdir,):
return ()
Expand Down
8 changes: 4 additions & 4 deletions dvc/repo/brancher.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def brancher( # noqa: E302

from dvc.fs import LocalFileSystem

repo_root_parts = ()
repo_root_parts: Tuple[str, ...] = ()
if self.fs.path.isin(self.root_dir, self.scm.root_dir):
repo_root_parts = self.fs.path.relparts(self.root_dir, self.scm.root_dir)

cwd_parts = ()
cwd_parts: Tuple[str, ...] = ()
if self.fs.path.isin(self.fs.path.getcwd(), self.scm.root_dir):
cwd_parts = self.fs.path.relparts(self.fs.path.getcwd(), self.scm.root_dir)

Expand Down Expand Up @@ -144,11 +144,11 @@ def switch(repo: "Repo", rev: str) -> Iterator[str]:
if rev != "workspace":
rev = resolve_rev(repo.scm, rev)

repo_root_parts = ()
repo_root_parts: Tuple[str, ...] = ()
if repo.fs.path.isin(repo.root_dir, repo.scm.root_dir):
repo_root_parts = repo.fs.path.relparts(repo.root_dir, repo.scm.root_dir)

cwd_parts = ()
cwd_parts: Tuple[str, ...] = ()
if repo.fs.path.isin(repo.fs.path.getcwd(), repo.scm.root_dir):
cwd_parts = repo.fs.path.relparts(repo.fs.path.getcwd(), repo.scm.root_dir)

Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _check_can_delete(
if cache_fs.exists(cache_path):
continue

entry_paths.append(fs.path.join(path, *entry.key))
entry_paths.append(fs.path.join(path, *(entry.key or ())))

if not entry_paths:
return
Expand Down
1 change: 1 addition & 0 deletions dvc/repo/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ def _resolve_definitions(
definitions: "DictStrAny",
onerror: Optional[Callable[[Any], Any]] = None,
):
config_path = os.fspath(config_path)
config_dir = fs.path.dirname(config_path)
result: Dict[str, Dict] = {}
for plot_id, plot_props in definitions.items():
Expand Down

0 comments on commit 0342e4f

Please sign in to comment.