dvc: use consistent messages for InvalidArgumentError (#3506)

Per https://discordapp.com/channels/485586884165107732/563406153334128681/689896480898810034
This commit is contained in:
Ruslan Kuprieiev
2020-03-18 21:34:46 +02:00
committed by GitHub
parent 55f86df5b1
commit 498ee509da
5 changed files with 16 additions and 11 deletions
+2 -3
View File
@@ -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
View File
@@ -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`"
)
+1 -1
View File
@@ -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
View File
@@ -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)
+8 -2
View File
@@ -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):