diff --git a/dvc/config.py b/dvc/config.py index c6323c2b7..c5d1fcdf2 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -99,6 +99,7 @@ class Config(dict): ): # 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 diff --git a/dvc/fs/dvc.py b/dvc/fs/dvc.py index bdddc0693..2685dd438 100644 --- a/dvc/fs/dvc.py +++ b/dvc/fs/dvc.py @@ -139,7 +139,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method 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) @@ -163,6 +163,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method 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 () diff --git a/dvc/repo/brancher.py b/dvc/repo/brancher.py index 75a8283fa..509ec0390 100644 --- a/dvc/repo/brancher.py +++ b/dvc/repo/brancher.py @@ -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) @@ -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) diff --git a/dvc/repo/checkout.py b/dvc/repo/checkout.py index a722afd29..ef0988636 100644 --- a/dvc/repo/checkout.py +++ b/dvc/repo/checkout.py @@ -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 diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index f37dec1cc..7fd0a47f7 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -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():