diff --git a/dvc/command/plots.py b/dvc/command/plots.py index 169d4f24b..8625b64fa 100644 --- a/dvc/command/plots.py +++ b/dvc/command/plots.py @@ -5,7 +5,6 @@ import os from dvc.command import completion from dvc.command.base import CmdBase, append_doc_link, fix_subparsers from dvc.exceptions import DvcException -from dvc.schema import PLOT_PROPS from dvc.utils import format_link from dvc.utils.html import write @@ -17,6 +16,8 @@ class CmdPlots(CmdBase): raise NotImplementedError def _props(self): + from dvc.schema import PLOT_PROPS + # Pass only props specified by user, to not shadow ones from plot def props = {p: getattr(self.args, p) for p in PLOT_PROPS} return {k: v for k, v in props.items() if v is not None} diff --git a/dvc/command/remote.py b/dvc/command/remote.py index 79a46958a..06ca0200d 100644 --- a/dvc/command/remote.py +++ b/dvc/command/remote.py @@ -3,7 +3,6 @@ import logging from dvc.command.base import append_doc_link, fix_subparsers from dvc.command.config import CmdConfig -from dvc.config import ConfigError, merge from dvc.utils import format_link logger = logging.getLogger(__name__) @@ -17,12 +16,16 @@ class CmdRemote(CmdConfig): self.args.name = self.args.name.lower() def _check_exists(self, conf): + from dvc.config import ConfigError + if self.args.name not in conf["remote"]: raise ConfigError(f"remote '{self.args.name}' doesn't exist.") class CmdRemoteAdd(CmdRemote): def run(self): + from dvc.config import ConfigError + if self.args.default: logger.info(f"Setting '{self.args.name}' as a default remote.") @@ -61,6 +64,8 @@ class CmdRemoteRemove(CmdRemote): class CmdRemoteModify(CmdRemote): def run(self): + from dvc.config import merge + with self.config.edit(self.args.level) as conf: merged = self.config.load_config_to_level(self.args.level) merge(merged, conf) @@ -78,6 +83,7 @@ class CmdRemoteModify(CmdRemote): class CmdRemoteDefault(CmdRemote): def run(self): + from dvc.config import ConfigError if self.args.name is None and not self.args.unset: conf = self.config.read(self.args.level) @@ -120,6 +126,8 @@ class CmdRemoteRename(CmdRemote): conf["core"]["remote"] = self.args.new def run(self): + from dvc.config import ConfigError + all_config = self.config.load_config_to_level(None) if self.args.new in all_config.get("remote", {}): raise ConfigError( diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 71aae71e3..7ee9fc60c 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -5,7 +5,6 @@ from functools import wraps from typing import TYPE_CHECKING from funcy import cached_property, cat -from git import InvalidGitRepositoryError from dvc.config import Config from dvc.exceptions import FileMissingError @@ -113,7 +112,7 @@ class Repo: try: scm = SCM(root_dir or os.curdir) - except (SCMError, InvalidGitRepositoryError): + except SCMError: scm = SCM(os.curdir, no_scm=True) assert isinstance(scm, Base)