mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
dvc: modify flake8 configuration
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
+2
-3
@@ -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)
|
||||
)
|
||||
|
||||
|
||||
|
||||
+2
-6
@@ -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):
|
||||
|
||||
@@ -4,7 +4,6 @@ import os
|
||||
|
||||
try:
|
||||
from google.cloud import storage
|
||||
from google.auth.credentials import Credentials
|
||||
except ImportError:
|
||||
storage = None
|
||||
|
||||
|
||||
+2
-3
@@ -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/"):
|
||||
|
||||
+10
-8
@@ -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
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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))
|
||||
)
|
||||
|
||||
+1
-1
@@ -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):
|
||||
|
||||
+6
-6
@@ -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):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
from dvc.utils.compat import str
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
+5
-2
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import yaml
|
||||
import shutil
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from dvc.stage import StageCommitError
|
||||
|
||||
@@ -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(),
|
||||
)
|
||||
|
||||
|
||||
+14
-11
@@ -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):
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user