From 6b18ac649d360cbf3740b522c899697f15af8485 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Tue, 22 Oct 2019 16:11:40 -0500 Subject: [PATCH 1/2] dvc: change ` for ' in dinamic parts of DVC outputs per https://github.com/iterative/dvc/pull/2644#issuecomment-545151398 --- dvc/command/get_url.py | 2 +- dvc/command/imp_url.py | 4 ++-- dvc/command/version.py | 2 +- dvc/config.py | 2 +- dvc/remote/http.py | 2 +- dvc/scm/git/__init__.py | 8 ++++---- dvc/stage.py | 4 ++-- dvc/utils/__init__.py | 2 +- tests/unit/command/test_imp_url.py | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dvc/command/get_url.py b/dvc/command/get_url.py index 579193d9a9..8cfc4ef76c 100644 --- a/dvc/command/get_url.py +++ b/dvc/command/get_url.py @@ -32,7 +32,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) get_parser.add_argument( - "url", help="See `dvc import-url -h` for full list of supported URLs." + "url", help="See 'dvc import-url -h' for full list of supported URLs." ) get_parser.add_argument( "out", nargs="?", help="Destination path to put data to." diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py index 012ea80c0e..bb2488fdbe 100644 --- a/dvc/command/imp_url.py +++ b/dvc/command/imp_url.py @@ -19,7 +19,7 @@ def run(self): except DvcException: logger.exception( "failed to import {}. You could also try downloading " - "it manually and adding it with `dvc add` command.".format( + "it manually, and adding it with 'dvc add'.".format( self.args.url ) ) @@ -49,7 +49,7 @@ def add_parser(subparsers, parent_parser): "gs://bucket/path/to/file\n" "hdfs://example.com/path/to/file\n" "ssh://example.com:/path/to/file\n" - "remote://myremote/path/to/file (see `dvc remote`)", + "remote://myremote/path/to/file (see 'dvc remote')", ) import_parser.add_argument( "out", nargs="?", help="Destination path to put files to." diff --git a/dvc/command/version.py b/dvc/command/version.py index 078f1fdec1..e3d4e07db2 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -60,7 +60,7 @@ def run(self): logger.warning( "Unable to detect supported link types, as cache " "directory '{}' doesn't exist. It is usually auto-created " - "by commands such as `dvc add/fetch/pull/run/import`, " + "by commands such as 'dvc add/fetch/pull/run/import', " "but you could create it manually to enable this " "check.".format(relpath(repo.cache.local.cache_dir)) ) diff --git a/dvc/config.py b/dvc/config.py index d89b2fc6f0..6ed330cc1c 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -550,7 +550,7 @@ def set(self, section, opt, value, level=None, force=True): config[section] = {} elif not force: raise ConfigError( - "Section '{}' already exists. Use `-f|--force` to overwrite " + "Section '{}' already exists. Use '-f|--force' to overwrite " "section with new value.".format(section) ) diff --git a/dvc/remote/http.py b/dvc/remote/http.py index aef214c081..9cb61781a1 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -31,7 +31,7 @@ def __init__(self, repo, config): if not self.no_traverse: raise ConfigError( "HTTP doesn't support traversing the remote to list existing " - "files. Use: `dvc remote modify no_traverse true`" + "files. Use: 'dvc remote modify no_traverse true'" ) def _download(self, from_info, to_file, name=None, no_progress_bar=False): diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 980835e6c1..a324a484bd 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -200,10 +200,10 @@ def add(self, paths): self.repo.index.add(paths) except AssertionError: msg = ( - "failed to add '{}' to git. You can add those files" - " manually using 'git add'." - " See 'https://github.com/iterative/dvc/issues/610'" - " for more details.".format(str(paths)) + "failed to add '{}' to git. You can add those files " + "manually using 'git add'. See " + "https://github.com/iterative/dvc/issues/610 for more " + "details.".format(str(paths)) ) logger.exception(msg) diff --git a/dvc/stage.py b/dvc/stage.py index a368788486..8103f737fa 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -735,8 +735,8 @@ def check_can_commit(self, force): msg += "Are you sure you want to commit it?" if not force and not prompt.confirm(msg): raise StageCommitError( - "unable to commit changed '{}'. Use `-f|--force` to " - "force.`".format(self.relpath) + "unable to commit changed '{}'. Use '-f|--force' to " + "force.".format(self.relpath) ) self.save() diff --git a/dvc/utils/__init__.py b/dvc/utils/__init__.py index 538b7a97e1..b0cb6b3fff 100644 --- a/dvc/utils/__init__.py +++ b/dvc/utils/__init__.py @@ -232,7 +232,7 @@ def _to_chunks_by_chunks_number(list_to_split, num_chunks): def to_chunks(list_to_split, num_chunks=None, chunk_size=None): if (num_chunks and chunk_size) or (not num_chunks and not chunk_size): raise ValueError( - "One and only one of 'num_chunks', 'chunk_size' must be defined" + "Only one among `num_chunks` or `chunk_size` must be defined." ) if chunk_size: return _split(list_to_split, chunk_size) diff --git a/tests/unit/command/test_imp_url.py b/tests/unit/command/test_imp_url.py index 3ec0efbaac..e1049bca56 100644 --- a/tests/unit/command/test_imp_url.py +++ b/tests/unit/command/test_imp_url.py @@ -29,7 +29,7 @@ def test_failed_import_url(mocker, caplog, dvc_repo): assert cmd.run() == 1 expected_error = ( "failed to import http://somesite.com/file_name. " - "You could also try downloading it manually and " - "adding it with `dvc add` command." + "You could also try downloading it manually, and " + "adding it with 'dvc add'." ) assert expected_error in caplog.text From 9637bf3e76b2df36d4752f76ad3e53a74a39db18 Mon Sep 17 00:00:00 2001 From: Jorge Orpinel Date: Sun, 27 Oct 2019 20:04:06 -0600 Subject: [PATCH 2/2] dvc: use ' for dynamic output and ` for DVC names per https://github.com/iterative/dvc/pull/2644#discussion_r338417698 --- dvc/command/destroy.py | 2 +- dvc/command/get_url.py | 2 +- dvc/command/imp_url.py | 4 ++-- dvc/command/init.py | 2 +- dvc/command/remove.py | 2 +- dvc/command/run.py | 6 +++--- dvc/command/version.py | 2 +- dvc/config.py | 2 +- dvc/exceptions.py | 6 +++--- dvc/remote/http.py | 2 +- dvc/remote/slow_link_detection.py | 2 +- dvc/repo/init.py | 4 ++-- dvc/scm/git/__init__.py | 2 +- dvc/stage.py | 12 ++++++------ tests/unit/command/test_imp_url.py | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/dvc/command/destroy.py b/dvc/command/destroy.py index ca739de4ae..3dc2513875 100644 --- a/dvc/command/destroy.py +++ b/dvc/command/destroy.py @@ -24,7 +24,7 @@ def run(self): if not self.args.force and not prompt.confirm(statement): raise DvcException( "cannot destroy without a confirmation from the user." - " Use '-f' to force." + " Use `-f` to force." ) self.repo.destroy() diff --git a/dvc/command/get_url.py b/dvc/command/get_url.py index 8cfc4ef76c..579193d9a9 100644 --- a/dvc/command/get_url.py +++ b/dvc/command/get_url.py @@ -32,7 +32,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) get_parser.add_argument( - "url", help="See 'dvc import-url -h' for full list of supported URLs." + "url", help="See `dvc import-url -h` for full list of supported URLs." ) get_parser.add_argument( "out", nargs="?", help="Destination path to put data to." diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py index bb2488fdbe..1b0b1cf87c 100644 --- a/dvc/command/imp_url.py +++ b/dvc/command/imp_url.py @@ -19,7 +19,7 @@ def run(self): except DvcException: logger.exception( "failed to import {}. You could also try downloading " - "it manually, and adding it with 'dvc add'.".format( + "it manually, and adding it with `dvc add`.".format( self.args.url ) ) @@ -49,7 +49,7 @@ def add_parser(subparsers, parent_parser): "gs://bucket/path/to/file\n" "hdfs://example.com/path/to/file\n" "ssh://example.com:/path/to/file\n" - "remote://myremote/path/to/file (see 'dvc remote')", + "remote://myremote/path/to/file (see `dvc remote`)", ) import_parser.add_argument( "out", nargs="?", help="Destination path to put files to." diff --git a/dvc/command/init.py b/dvc/command/init.py index 0e9bdf83f8..075e3be4c0 100644 --- a/dvc/command/init.py +++ b/dvc/command/init.py @@ -53,7 +53,7 @@ def add_parser(subparsers, parent_parser): action="store_true", default=False, help=( - "Overwrite existing '.dvc' directory. " + "Overwrite existing '.dvc/' directory. " "This operation removes local cache." ), ) diff --git a/dvc/command/remove.py b/dvc/command/remove.py index 814adcfae3..a004480290 100644 --- a/dvc/command/remove.py +++ b/dvc/command/remove.py @@ -28,7 +28,7 @@ def _is_outs_only(self, target): raise DvcException( "Cannot purge without a confirmation from the user." - " Use '-f' to force." + " Use `-f` to force." ) def run(self): diff --git a/dvc/command/run.py b/dvc/command/run.py index b0761435f3..c51f10baba 100644 --- a/dvc/command/run.py +++ b/dvc/command/run.py @@ -27,9 +27,9 @@ def run(self): ] ): # pragma: no cover logger.error( - "too few arguments. Specify at least one: '-d', '-o', '-O'," - " '-m', '-M', '--outs-persist', '--outs-persist-no-cache'," - " 'command'." + "too few arguments. Specify at least one: `-d`, `-o`, `-O`, " + "`-m`, `-M`, `--outs-persist`, `--outs-persist-no-cache`, " + "`command`." ) return 1 diff --git a/dvc/command/version.py b/dvc/command/version.py index e3d4e07db2..078f1fdec1 100644 --- a/dvc/command/version.py +++ b/dvc/command/version.py @@ -60,7 +60,7 @@ def run(self): logger.warning( "Unable to detect supported link types, as cache " "directory '{}' doesn't exist. It is usually auto-created " - "by commands such as 'dvc add/fetch/pull/run/import', " + "by commands such as `dvc add/fetch/pull/run/import`, " "but you could create it manually to enable this " "check.".format(relpath(repo.cache.local.cache_dir)) ) diff --git a/dvc/config.py b/dvc/config.py index 6ed330cc1c..d89b2fc6f0 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -550,7 +550,7 @@ def set(self, section, opt, value, level=None, force=True): config[section] = {} elif not force: raise ConfigError( - "Section '{}' already exists. Use '-f|--force' to overwrite " + "Section '{}' already exists. Use `-f|--force` to overwrite " "section with new value.".format(section) ) diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 2309bcdbf8..16b8b837b3 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -179,7 +179,7 @@ class ConfirmRemoveError(DvcException): def __init__(self, path): super(ConfirmRemoveError, self).__init__( "unable to remove '{}' without a confirmation from the user. Use " - "'-f' to force.".format(path) + "`-f` to force.".format(path) ) @@ -209,7 +209,7 @@ class NoMetricsError(DvcException): def __init__(self): super(NoMetricsError, self).__init__( "no metric files in this repository. " - "Use 'dvc metrics add' to add a metric file to track." + "Use `dvc metrics add` to add a metric file to track." ) @@ -247,7 +247,7 @@ def __init__(self, out_1, out_2): class CheckoutErrorSuggestGit(DvcException): def __init__(self, target, cause): super(CheckoutErrorSuggestGit, self).__init__( - "Did you mean 'git checkout {}'?".format(target), cause=cause + "Did you mean `git checkout {}`?".format(target), cause=cause ) diff --git a/dvc/remote/http.py b/dvc/remote/http.py index 9cb61781a1..aef214c081 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -31,7 +31,7 @@ def __init__(self, repo, config): if not self.no_traverse: raise ConfigError( "HTTP doesn't support traversing the remote to list existing " - "files. Use: 'dvc remote modify no_traverse true'" + "files. Use: `dvc remote modify no_traverse true`" ) def _download(self, from_info, to_file, name=None, no_progress_bar=False): diff --git a/dvc/remote/slow_link_detection.py b/dvc/remote/slow_link_detection.py index 0dd2285d60..bffa6e9e8a 100644 --- a/dvc/remote/slow_link_detection.py +++ b/dvc/remote/slow_link_detection.py @@ -18,7 +18,7 @@ "See {blue}https://dvc.org/doc/commands-reference/config#cache{reset} " "for more information.\n" "To disable this message, run:\n" - "'dvc config cache.slow_link_warning false'".format( + "`dvc config cache.slow_link_warning false`".format( blue=colorama.Fore.BLUE, reset=colorama.Fore.RESET ) ) diff --git a/dvc/repo/init.py b/dvc/repo/init.py index 19dc20d1bf..e2f6b4702a 100644 --- a/dvc/repo/init.py +++ b/dvc/repo/init.py @@ -65,7 +65,7 @@ def init(root_dir=os.curdir, no_scm=False, force=False): if isinstance(scm, NoSCM) and not no_scm: raise InitError( "{repo} is not tracked by any supported scm tool (e.g. git). " - "Use '--no-scm' if you don't want to use any scm.".format( + "Use `--no-scm` if you don't want to use any scm.".format( repo=root_dir ) ) @@ -73,7 +73,7 @@ def init(root_dir=os.curdir, no_scm=False, force=False): if os.path.isdir(dvc_dir): if not force: raise InitError( - "'{repo}' exists. Use '-f' to force.".format( + "'{repo}' exists. Use `-f` to force.".format( repo=relpath(dvc_dir) ) ) diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 2f0730ef5b..fd4e7ad10f 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -201,7 +201,7 @@ def add(self, paths): except AssertionError: msg = ( "failed to add '{}' to git. You can add those files " - "manually using 'git add'. See " + "manually using `git add`. See " "https://github.com/iterative/dvc/issues/610 for more " "details.".format(str(paths)) ) diff --git a/dvc/stage.py b/dvc/stage.py index e6b4385540..94ec95c210 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -242,7 +242,7 @@ def _changed_deps(self): if self.is_callback: logger.warning( - "DVC-file '{fname}' is a 'callback' stage " + "DVC-file '{fname}' is a \"callback\" stage " "(has a command and no dependencies) and thus always " "considered as changed.".format(fname=self.relpath) ) @@ -451,8 +451,8 @@ def create(repo, **kwargs): if fname is not None and os.path.basename(fname) != fname: raise StageFileBadNameError( "DVC-file name '{fname}' may not contain subdirectories" - " if '-c|--cwd' (deprecated) is specified. Use '-w|--wdir'" - " along with '-f' to specify DVC-file path with working" + " if `-c|--cwd` (deprecated) is specified. Use `-w|--wdir`" + " along with `-f` to specify DVC-file path with working" " directory.".format(fname=fname) ) wdir = cwd @@ -571,8 +571,8 @@ def _fill_stage_outputs(stage, **kwargs): def _check_dvc_filename(fname): if not Stage.is_valid_filename(fname): raise StageFileBadNameError( - "bad DVC-file name '{}'. DVC-files should be named" - " 'Dvcfile' or have a '.dvc' suffix (e.g. '{}.dvc').".format( + "bad DVC-file name '{}'. DVC-files should be named " + "'Dvcfile' or have a '.dvc' suffix (e.g. '{}.dvc').".format( relpath(fname), os.path.basename(fname) ) ) @@ -735,7 +735,7 @@ def check_can_commit(self, force): msg += "Are you sure you want to commit it?" if not force and not prompt.confirm(msg): raise StageCommitError( - "unable to commit changed '{}'. Use '-f|--force' to " + "unable to commit changed '{}'. Use `-f|--force` to " "force.".format(self.relpath) ) self.save() diff --git a/tests/unit/command/test_imp_url.py b/tests/unit/command/test_imp_url.py index e1049bca56..50cb6e5bd5 100644 --- a/tests/unit/command/test_imp_url.py +++ b/tests/unit/command/test_imp_url.py @@ -30,6 +30,6 @@ def test_failed_import_url(mocker, caplog, dvc_repo): expected_error = ( "failed to import http://somesite.com/file_name. " "You could also try downloading it manually, and " - "adding it with 'dvc add'." + "adding it with `dvc add`." ) assert expected_error in caplog.text