mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
dvc: use consistent messages for InvalidArgumentError (#3506)
Per https://discordapp.com/channels/485586884165107732/563406153334128681/689896480898810034
This commit is contained in:
+2
-3
@@ -17,9 +17,8 @@ def _do_gc(typ, func, clist):
|
||||
def _raise_error_if_all_disabled(**kwargs):
|
||||
if not any(kwargs.values()):
|
||||
raise InvalidArgumentError(
|
||||
"Invalid Arguments. Either of ({}) needs to be enabled.".format(
|
||||
", ".join(kwargs.keys())
|
||||
)
|
||||
"Either of `-w|--workspace`, `-a|--all-branches`, `-T|--all-tags` "
|
||||
"or `--all-commits` needs to be set."
|
||||
)
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import colorama
|
||||
|
||||
from dvc import analytics
|
||||
from dvc.config import Config
|
||||
from dvc.exceptions import InitError
|
||||
from dvc.exceptions import InitError, InvalidArgumentError
|
||||
from dvc.repo import Repo
|
||||
from dvc.scm import SCM
|
||||
from dvc.scm.base import SCMError
|
||||
@@ -65,7 +65,7 @@ def init(root_dir=os.curdir, no_scm=False, force=False, subdir=False):
|
||||
"""
|
||||
|
||||
if no_scm and subdir:
|
||||
raise InitError(
|
||||
raise InvalidArgumentError(
|
||||
"Cannot initialize repo with `--no-scm` and `--subdir`"
|
||||
)
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ def reproduce(
|
||||
|
||||
if not target and not all_pipelines:
|
||||
raise InvalidArgumentError(
|
||||
"Neither target nor all_pipelines are specified."
|
||||
"Neither `target` nor `--all-pipelines` are specified."
|
||||
)
|
||||
|
||||
interactive = kwargs.get("interactive", False)
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ from itertools import compress
|
||||
|
||||
from funcy.py3 import cat
|
||||
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.exceptions import InvalidArgumentError
|
||||
from . import locked
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ def status(
|
||||
)
|
||||
)
|
||||
if ignored:
|
||||
msg = "the following options are meaningless for local status: {}"
|
||||
raise DvcException(msg.format(", ".join(ignored)))
|
||||
msg = "The following options are meaningless for local status: {}"
|
||||
raise InvalidArgumentError(msg.format(", ".join(ignored)))
|
||||
|
||||
return _local_status(self, targets, with_deps=with_deps)
|
||||
|
||||
@@ -265,14 +265,20 @@ def test_gc_without_workspace(tmp_dir, dvc, caplog):
|
||||
with caplog.at_level(logging.WARNING, logger="dvc"):
|
||||
assert main(["gc", "-vf"]) == 255
|
||||
|
||||
assert "Invalid Arguments" in caplog.text
|
||||
assert (
|
||||
"Either of `-w|--workspace`, `-a|--all-branches`, `-T|--all-tags` "
|
||||
"or `--all-commits` needs to be set."
|
||||
) in caplog.text
|
||||
|
||||
|
||||
def test_gc_cloud_without_any_specifier(tmp_dir, dvc, caplog):
|
||||
with caplog.at_level(logging.WARNING, logger="dvc"):
|
||||
assert main(["gc", "-cvf"]) == 255
|
||||
|
||||
assert "Invalid Arguments" in caplog.text
|
||||
assert (
|
||||
"Either of `-w|--workspace`, `-a|--all-branches`, `-T|--all-tags` "
|
||||
"or `--all-commits` needs to be set."
|
||||
) in caplog.text
|
||||
|
||||
|
||||
def test_gc_with_possible_args_positive(tmp_dir, dvc):
|
||||
|
||||
Reference in New Issue
Block a user