diff --git a/.flake8 b/.flake8 index 50b8fe537..5cf97db62 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,7 @@ [flake8] -ignore = E203, E266, E501, W503, F403, F401 +ignore = + E203, # Whitespace before ':' + E266, # Too many leading '#' for block comment + W503, # Line break occurred before a binary operator max-line-length = 79 select = B,C,E,F,W,T4,B9 diff --git a/dvc/command/metrics.py b/dvc/command/metrics.py index bc7f6f5e7..535fa3a6d 100644 --- a/dvc/command/metrics.py +++ b/dvc/command/metrics.py @@ -75,7 +75,10 @@ class CmdMetricsRemove(CmdBase): def add_parser(subparsers, parent_parser): - METRICS_HELP = "A set of commands to add, manage, collect and display project metrics." + METRICS_HELP = ( + "A set of commands to add, manage, collect and display project " + "metrics." + ) metrics_parser = subparsers.add_parser( "metrics", parents=[parent_parser], @@ -125,7 +128,10 @@ def add_parser(subparsers, parent_parser): "--recursive", action="store_true", default=False, - help="If path is a directory, recursively search and process metric files in path.", + help=( + "If path is a directory, recursively search and process metric " + "files in path." + ), ) metrics_show_parser.set_defaults(func=CmdMetricsShow) diff --git a/dvc/prompt.py b/dvc/prompt.py index 898eb921b..4546f37d4 100644 --- a/dvc/prompt.py +++ b/dvc/prompt.py @@ -26,9 +26,8 @@ def _ask(prompt, limited_to=None): return answer print( - "Your response must be one of: {options}. Please try again.".format( - options=limited_to - ) + "Your response must be one of: {options}. " + "Please try again.".format(options=limited_to) ) diff --git a/dvc/remote/base.py b/dvc/remote/base.py index 9952ce824..ada5db980 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -2,9 +2,7 @@ from __future__ import unicode_literals from dvc.utils.compat import str -import os import re -import errno import posixpath from multiprocessing import cpu_count @@ -83,10 +81,8 @@ class RemoteBase(object): "\n" "If you have installed dvc from a binary package and you " "are still seeing this message, please report it to us " - "using https://github.com/iterative/dvc/issues. Thank you!".format( - url, missing, " ".join(missing), self.scheme - ) - ) + "using https://github.com/iterative/dvc/issues. Thank you!" + ).format(url, missing, " ".join(missing), self.scheme) raise RemoteMissingDepsError(msg) def __repr__(self): diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py index aa7d8ffd6..bcde483e6 100644 --- a/dvc/remote/gs.py +++ b/dvc/remote/gs.py @@ -4,7 +4,6 @@ import os try: from google.cloud import storage - from google.auth.credentials import Credentials except ImportError: storage = None diff --git a/dvc/remote/http.py b/dvc/remote/http.py index c6232e29e..35fd8b10e 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -121,9 +121,8 @@ class RemoteHTTP(RemoteBase): if not etag: raise DvcException( - "could not find an ETag or Content-MD5 header for '{url}'".format( - url=url - ) + "could not find an ETag or " + "Content-MD5 header for '{url}'".format(url=url) ) if etag.startswith("W/"): diff --git a/dvc/repo/init.py b/dvc/repo/init.py index d0bc62cea..7311f20d3 100644 --- a/dvc/repo/init.py +++ b/dvc/repo/init.py @@ -19,18 +19,20 @@ def _welcome_message(): border_color="red", ) - logger.info( + msg = ( "{yellow}What's next?{nc}\n" "{yellow}------------{nc}\n" "- Check out the documentation: {blue}https://dvc.org/doc{nc}\n" "- Get help and share ideas: {blue}https://dvc.org/chat{nc}\n" - "- Star us on GitHub: {blue}https://github.com/iterative/dvc{nc}".format( - yellow=colorama.Fore.YELLOW, - blue=colorama.Fore.BLUE, - nc=colorama.Fore.RESET, - ) + "- Star us on GitHub: {blue}https://github.com/iterative/dvc{nc}" + ).format( + yellow=colorama.Fore.YELLOW, + blue=colorama.Fore.BLUE, + nc=colorama.Fore.RESET, ) + logger.info(msg) + def init(root_dir=os.curdir, no_scm=False, force=False): """ @@ -56,8 +58,8 @@ def init(root_dir=os.curdir, no_scm=False, force=False): scm = SCM(root_dir) if type(scm) == Base 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( + "{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( repo=root_dir ) ) diff --git a/dvc/repo/metrics/modify.py b/dvc/repo/metrics/modify.py index 541446b6a..2ce5fbe79 100644 --- a/dvc/repo/metrics/modify.py +++ b/dvc/repo/metrics/modify.py @@ -16,7 +16,10 @@ def modify(repo, path, typ=None, xpath=None, delete=False): if typ is not None: typ = typ.lower().strip() if typ not in ["raw", "json", "csv", "tsv", "hcsv", "htsv"]: - msg = "metric type '{typ}' is not supported, must be one of [{types}]" + msg = ( + "metric type '{typ}' is not supported, " + "must be one of [{types}]" + ) raise DvcException( msg.format(typ=typ, types=", ".join(supported_types)) ) diff --git a/dvc/repo/move.py b/dvc/repo/move.py index 46b4fc98b..39a4ad9c9 100644 --- a/dvc/repo/move.py +++ b/dvc/repo/move.py @@ -1,6 +1,6 @@ import os -from dvc.exceptions import MoveNotDataSourceError, DvcException +from dvc.exceptions import MoveNotDataSourceError def _expand_target_path(from_path, to_path): diff --git a/dvc/stage.py b/dvc/stage.py index 011d244a5..feac49ffe 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -186,10 +186,9 @@ class Stage(object): if self.is_callback: logger.warning( - "Dvc file '{fname}' is a 'callback' stage (has a command and" - " no dependencies) and thus always considered as changed.".format( - fname=self.relpath - ) + "Dvc file '{fname}' is a 'callback' stage " + "(has a command and no dependencies) and thus always " + "considered as changed.".format(fname=self.relpath) ) return True @@ -265,8 +264,9 @@ class Stage(object): # Removing outputs only if we actually have command to reproduce self.remove_outs(ignore_remove=False) - msg = "Going to reproduce '{stage}'. Are you sure you want to continue?".format( - stage=self.relpath + msg = ( + "Going to reproduce '{stage}'. " + "Are you sure you want to continue?".format(stage=self.relpath) ) if interactive and not prompt.confirm(msg): diff --git a/dvc/updater.py b/dvc/updater.py index ca839eb99..09b2032bf 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -from dvc.utils.compat import str import sys import os diff --git a/dvc/utils/compat.py b/dvc/utils/compat.py index d9f1c045f..15d5699c4 100644 --- a/dvc/utils/compat.py +++ b/dvc/utils/compat.py @@ -27,14 +27,17 @@ def encode(u, encoding=None): return u.encode(encoding, "replace") -# NOTE: cast_bytes_py2 is taken from https://github.com/ipython/ipython_genutils +# NOTE: cast_bytes_py2 is taken from +# https://github.com/ipython/ipython_genutils def cast_bytes(s, encoding=None): if not isinstance(s, bytes): return encode(s, encoding) return s -# NOTE _makedirs is taken from https://github.com/python/cpython/blob/3ce3dea60646d8a5a1c952469a2eb65f937875b3/Lib/os.py#L196-L226 +# NOTE _makedirs is taken from +# https://github.com/python/cpython/blob/ +# 3ce3dea60646d8a5a1c952469a2eb65f937875b3/Lib/os.py#L196-L226 def _makedirs(name, mode=0o777, exist_ok=False): head, tail = os.path.split(name) if not tail: diff --git a/tests/test_add.py b/tests/test_add.py index a835fce03..f2ad4b150 100644 --- a/tests/test_add.py +++ b/tests/test_add.py @@ -11,7 +11,6 @@ import filecmp from mock import patch from dvc.main import main -from dvc.state import State from dvc.utils import file_md5 from dvc.stage import Stage from dvc.exceptions import DvcException diff --git a/tests/test_checkout.py b/tests/test_checkout.py index 37effe9a9..eb1d46602 100644 --- a/tests/test_checkout.py +++ b/tests/test_checkout.py @@ -381,7 +381,10 @@ class TestCheckoutSuggestGit(TestRepro): msg = str(exc) self.assertEqual( msg, - "'gitbranch' does not exist. Did you mean 'git checkout gitbranch'?", + ( + "'gitbranch' does not exist. " + "Did you mean 'git checkout gitbranch'?" + ), ) try: diff --git a/tests/test_commit.py b/tests/test_commit.py index 68581225a..c71dfd025 100644 --- a/tests/test_commit.py +++ b/tests/test_commit.py @@ -1,5 +1,4 @@ import yaml -import shutil from tests.basic_env import TestDvc from dvc.stage import StageCommitError diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 0bc20bc3a..b17dfece8 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -363,8 +363,9 @@ class TestMetricsCLI(TestMetrics): ret = main(["metrics", "add", "metric.unknown", "-t", "unknown"]) self.assertEqual(ret, 1) self.assertIn( - "failed to add metric file 'metric.unknown' - metric type 'unknown'" - " is not supported, must be one of [raw, json, csv, tsv, hcsv, htsv]", + "failed to add metric file 'metric.unknown' - metric type " + "'unknown' is not supported, must be one of " + "[raw, json, csv, tsv, hcsv, htsv]", logger.logger.handlers[1].stream.getvalue(), ) @@ -394,8 +395,9 @@ class TestMetricsCLI(TestMetrics): ) self.assertEqual(ret, 1) self.assertIn( - "failed to modify metric file settings - metric type 'unknown'" - " is not supported, must be one of [raw, json, csv, tsv, hcsv, htsv]", + "failed to modify metric file settings - metric type " + "'unknown' is not supported, must be one of " + "[raw, json, csv, tsv, hcsv, htsv]", logger.logger.handlers[1].stream.getvalue(), ) diff --git a/tests/test_repro.py b/tests/test_repro.py index 873e5165c..421fe13fe 100644 --- a/tests/test_repro.py +++ b/tests/test_repro.py @@ -803,13 +803,15 @@ class TestReproExternalBase(TestDvc): patch_run = patch.object(stage, "_run", wraps=stage._run) - with self.dvc.state, patch_download as mock_download, patch_checkout as mock_checkout, patch_run as mock_run: + with self.dvc.state: + with patch_download as mock_download: + with patch_checkout as mock_checkout: + with patch_run as mock_run: + stage.run() - stage.run() - - mock_run.assert_not_called() - mock_download.assert_not_called() - mock_checkout.assert_called_once() + mock_run.assert_not_called() + mock_download.assert_not_called() + mock_checkout.assert_called_once() def corrupted_cache(self): os.unlink("bar.dvc") @@ -827,12 +829,13 @@ class TestReproExternalBase(TestDvc): patch_run = patch.object(stage, "_run", wraps=stage._run) - with self.dvc.state, patch_checkout as mock_checkout, patch_run as mock_run: + with self.dvc.state: + with patch_checkout as mock_checkout: + with patch_run as mock_run: + stage.run() - stage.run() - - mock_run.assert_called_once() - mock_checkout.assert_not_called() + mock_run.assert_called_once() + mock_checkout.assert_not_called() @patch("dvc.prompt.confirm", return_value=True) def test(self, mock_prompt): diff --git a/tests/unit/remote/azure.py b/tests/unit/remote/azure.py index 79a6d48a0..676651f61 100644 --- a/tests/unit/remote/azure.py +++ b/tests/unit/remote/azure.py @@ -13,7 +13,9 @@ class TestRemoteAzure(TestCase): ) def test_init_compat(self): - url = "azure://ContainerName={container_name};{connection_string}".format( + url = ( + "azure://ContainerName={container_name};{connection_string}" + ).format( container_name=self.container_name, connection_string=self.connection_string, )