mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
Merge pull request #3039 from mroutis/refactor-super
py3: use new magic from PEP 3135
This commit is contained in:
@@ -8,7 +8,7 @@ from dvc.command.config import CmdConfig
|
||||
|
||||
class CmdCacheDir(CmdConfig):
|
||||
def __init__(self, args):
|
||||
super(CmdCacheDir, self).__init__(args)
|
||||
super().__init__(args)
|
||||
self.cache_config = CacheConfig(self.config)
|
||||
|
||||
def run(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class CmdConfig(CmdBaseNoRepo):
|
||||
def __init__(self, args):
|
||||
super(CmdConfig, self).__init__(args)
|
||||
super().__init__(args)
|
||||
|
||||
self.config = Config(validate=False)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class CmdRemoteConfig(CmdConfig):
|
||||
def __init__(self, args):
|
||||
super(CmdRemoteConfig, self).__init__(args)
|
||||
super().__init__(args)
|
||||
self.remote_config = RemoteConfig(self.config)
|
||||
|
||||
|
||||
|
||||
+2
-4
@@ -25,9 +25,7 @@ class ConfigError(DvcException):
|
||||
"""
|
||||
|
||||
def __init__(self, msg, cause=None):
|
||||
super(ConfigError, self).__init__(
|
||||
"config file error: {}".format(msg), cause=cause
|
||||
)
|
||||
super().__init__("config file error: {}".format(msg), cause=cause)
|
||||
|
||||
|
||||
class NoRemoteError(ConfigError):
|
||||
@@ -39,7 +37,7 @@ class NoRemoteError(ConfigError):
|
||||
" dvc {} -r <name>\n".format(command)
|
||||
)
|
||||
|
||||
super(NoRemoteError, self).__init__(msg, cause=cause)
|
||||
super().__init__(msg, cause=cause)
|
||||
|
||||
|
||||
def supported_cache_type(types):
|
||||
|
||||
@@ -4,18 +4,18 @@ from dvc.exceptions import DvcException
|
||||
class DependencyDoesNotExistError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "dependency '{}' does not exist".format(path)
|
||||
super(DependencyDoesNotExistError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class DependencyIsNotFileOrDirError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "dependency '{}' is not a file or directory".format(path)
|
||||
super(DependencyIsNotFileOrDirError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class DependencyIsStageFileError(DvcException):
|
||||
def __init__(self, path):
|
||||
super(DependencyIsStageFileError, self).__init__(
|
||||
super().__init__(
|
||||
"Stage file '{}' cannot be a dependency.".format(path)
|
||||
)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class DependencyREPO(DependencyLOCAL):
|
||||
|
||||
def __init__(self, def_repo, stage, *args, **kwargs):
|
||||
self.def_repo = def_repo
|
||||
super(DependencyREPO, self).__init__(stage, *args, **kwargs)
|
||||
super().__init__(stage, *args, **kwargs)
|
||||
|
||||
def _parse_path(self, remote, path):
|
||||
return None
|
||||
|
||||
+31
-33
@@ -23,7 +23,7 @@ class DvcException(Exception):
|
||||
self.cause_tb = traceback.format_exc()
|
||||
except AttributeError: # pragma: no cover
|
||||
pass
|
||||
super(DvcException, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class OutputDuplicationError(DvcException):
|
||||
@@ -43,7 +43,7 @@ class OutputDuplicationError(DvcException):
|
||||
"stage: {}\n"
|
||||
"This is not allowed. Consider using a different output name."
|
||||
).format(output, "\n ".join(s.relpath for s in stages))
|
||||
super(OutputDuplicationError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class OutputNotFoundError(DvcException):
|
||||
@@ -56,7 +56,7 @@ class OutputNotFoundError(DvcException):
|
||||
def __init__(self, output, repo=None):
|
||||
self.output = output
|
||||
self.repo = repo
|
||||
super(OutputNotFoundError, self).__init__(
|
||||
super().__init__(
|
||||
"unable to find DVC-file with output '{path}'".format(
|
||||
path=relpath(self.output)
|
||||
)
|
||||
@@ -74,7 +74,7 @@ class StagePathAsOutputError(DvcException):
|
||||
|
||||
def __init__(self, stage, output):
|
||||
assert isinstance(output, str)
|
||||
super(StagePathAsOutputError, self).__init__(
|
||||
super().__init__(
|
||||
"'{stage}' is within an output '{output}' of another stage".format(
|
||||
stage=stage.relpath, output=output
|
||||
)
|
||||
@@ -96,7 +96,7 @@ class CircularDependencyError(DvcException):
|
||||
"file/directory '{}' is specified as an output and as a "
|
||||
"dependency."
|
||||
)
|
||||
super(CircularDependencyError, self).__init__(msg.format(dependency))
|
||||
super().__init__(msg.format(dependency))
|
||||
|
||||
|
||||
class ArgumentDuplicationError(DvcException):
|
||||
@@ -110,7 +110,7 @@ class ArgumentDuplicationError(DvcException):
|
||||
def __init__(self, path):
|
||||
assert isinstance(path, str)
|
||||
msg = "file '{}' is specified more than once."
|
||||
super(ArgumentDuplicationError, self).__init__(msg.format(path))
|
||||
super().__init__(msg.format(path))
|
||||
|
||||
|
||||
class MoveNotDataSourceError(DvcException):
|
||||
@@ -128,7 +128,7 @@ class MoveNotDataSourceError(DvcException):
|
||||
"it by hand, or remove '{path}' and create a new one at the "
|
||||
"desired location."
|
||||
)
|
||||
super(MoveNotDataSourceError, self).__init__(msg.format(path=path))
|
||||
super().__init__(msg.format(path=path))
|
||||
|
||||
|
||||
class NotDvcRepoError(DvcException):
|
||||
@@ -143,14 +143,14 @@ class NotDvcRepoError(DvcException):
|
||||
"you are not inside of a dvc repository "
|
||||
"(checked up to mount point '{}')"
|
||||
)
|
||||
super(NotDvcRepoError, self).__init__(msg.format(root))
|
||||
super().__init__(msg.format(root))
|
||||
|
||||
|
||||
class DvcParserError(DvcException):
|
||||
"""Base class for CLI parser errors."""
|
||||
|
||||
def __init__(self):
|
||||
super(DvcParserError, self).__init__("parser error")
|
||||
super().__init__("parser error")
|
||||
|
||||
|
||||
class CyclicGraphError(DvcException):
|
||||
@@ -163,12 +163,12 @@ class CyclicGraphError(DvcException):
|
||||
"\n"
|
||||
"{stages}".format(stages=stages)
|
||||
)
|
||||
super(CyclicGraphError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class ConfirmRemoveError(DvcException):
|
||||
def __init__(self, path):
|
||||
super(ConfirmRemoveError, self).__init__(
|
||||
super().__init__(
|
||||
"unable to remove '{}' without a confirmation from the user. Use "
|
||||
"`-f` to force.".format(path)
|
||||
)
|
||||
@@ -176,19 +176,19 @@ class ConfirmRemoveError(DvcException):
|
||||
|
||||
class InitError(DvcException):
|
||||
def __init__(self, msg):
|
||||
super(InitError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class ReproductionError(DvcException):
|
||||
def __init__(self, dvc_file_name, ex):
|
||||
self.path = dvc_file_name
|
||||
msg = "failed to reproduce '{}'".format(dvc_file_name)
|
||||
super(ReproductionError, self).__init__(msg, cause=ex)
|
||||
super().__init__(msg, cause=ex)
|
||||
|
||||
|
||||
class BadMetricError(DvcException):
|
||||
def __init__(self, paths):
|
||||
super(BadMetricError, self).__init__(
|
||||
super().__init__(
|
||||
"the following metrics do not exists, "
|
||||
"are not metric files or are malformed: {paths}".format(
|
||||
paths=", ".join("'{}'".format(path) for path in paths)
|
||||
@@ -198,7 +198,7 @@ class BadMetricError(DvcException):
|
||||
|
||||
class NoMetricsError(DvcException):
|
||||
def __init__(self):
|
||||
super(NoMetricsError, self).__init__(
|
||||
super().__init__(
|
||||
"no metric files in this repository. "
|
||||
"Use `dvc metrics add` to add a metric file to track."
|
||||
)
|
||||
@@ -207,7 +207,7 @@ class NoMetricsError(DvcException):
|
||||
class StageFileCorruptedError(DvcException):
|
||||
def __init__(self, path, cause=None):
|
||||
path = relpath(path)
|
||||
super(StageFileCorruptedError, self).__init__(
|
||||
super().__init__(
|
||||
"unable to read DVC-file: {} "
|
||||
"YAML file structure is corrupted".format(path),
|
||||
cause=cause,
|
||||
@@ -216,14 +216,14 @@ class StageFileCorruptedError(DvcException):
|
||||
|
||||
class RecursiveAddingWhileUsingFilename(DvcException):
|
||||
def __init__(self):
|
||||
super(RecursiveAddingWhileUsingFilename, self).__init__(
|
||||
super().__init__(
|
||||
"cannot use `fname` with multiple targets or `-R|--recursive`"
|
||||
)
|
||||
|
||||
|
||||
class OverlappingOutputPathsError(DvcException):
|
||||
def __init__(self, out_1, out_2):
|
||||
super(OverlappingOutputPathsError, self).__init__(
|
||||
super().__init__(
|
||||
"Paths for outs:\n'{}'('{}')\n'{}'('{}')\noverlap. To avoid "
|
||||
"unpredictable behaviour, rerun command with non overlapping outs "
|
||||
"paths.".format(
|
||||
@@ -237,14 +237,14 @@ class OverlappingOutputPathsError(DvcException):
|
||||
|
||||
class CheckoutErrorSuggestGit(DvcException):
|
||||
def __init__(self, target, cause):
|
||||
super(CheckoutErrorSuggestGit, self).__init__(
|
||||
super().__init__(
|
||||
"Did you mean `git checkout {}`?".format(target), cause=cause
|
||||
)
|
||||
|
||||
|
||||
class ETagMismatchError(DvcException):
|
||||
def __init__(self, etag, cached_etag):
|
||||
super(ETagMismatchError, self).__init__(
|
||||
super().__init__(
|
||||
"ETag mismatch detected when copying file to cache! "
|
||||
"(expected: '{}', actual: '{}')".format(etag, cached_etag)
|
||||
)
|
||||
@@ -252,7 +252,7 @@ class ETagMismatchError(DvcException):
|
||||
|
||||
class FileMissingError(DvcException):
|
||||
def __init__(self, path, cause=None):
|
||||
super(FileMissingError, self).__init__(
|
||||
super().__init__(
|
||||
"Can't find '{}' neither locally nor on remote".format(path),
|
||||
cause=cause,
|
||||
)
|
||||
@@ -260,7 +260,7 @@ class FileMissingError(DvcException):
|
||||
|
||||
class DvcIgnoreInCollectedDirError(DvcException):
|
||||
def __init__(self, ignore_dirname):
|
||||
super(DvcIgnoreInCollectedDirError, self).__init__(
|
||||
super().__init__(
|
||||
".dvcignore file should not be in collected dir path: "
|
||||
"'{}'".format(ignore_dirname)
|
||||
)
|
||||
@@ -268,14 +268,12 @@ class DvcIgnoreInCollectedDirError(DvcException):
|
||||
|
||||
class UrlNotDvcRepoError(DvcException):
|
||||
def __init__(self, url):
|
||||
super(UrlNotDvcRepoError, self).__init__(
|
||||
"URL '{}' is not a dvc repository.".format(url)
|
||||
)
|
||||
super().__init__("URL '{}' is not a dvc repository.".format(url))
|
||||
|
||||
|
||||
class GitHookAlreadyExistsError(DvcException):
|
||||
def __init__(self, hook_name):
|
||||
super(GitHookAlreadyExistsError, self).__init__(
|
||||
super().__init__(
|
||||
"Hook '{}' already exists. Please refer to "
|
||||
"https://man.dvc.org/install "
|
||||
"for more info.".format(hook_name)
|
||||
@@ -286,7 +284,7 @@ class DownloadError(DvcException):
|
||||
def __init__(self, amount):
|
||||
self.amount = amount
|
||||
|
||||
super(DownloadError, self).__init__(
|
||||
super().__init__(
|
||||
"{amount} files failed to download".format(amount=amount)
|
||||
)
|
||||
|
||||
@@ -295,7 +293,7 @@ class UploadError(DvcException):
|
||||
def __init__(self, amount):
|
||||
self.amount = amount
|
||||
|
||||
super(UploadError, self).__init__(
|
||||
super().__init__(
|
||||
"{amount} files failed to upload".format(amount=amount)
|
||||
)
|
||||
|
||||
@@ -307,7 +305,7 @@ class CheckoutError(DvcException):
|
||||
"Checkout failed for following targets:\n {}\nDid you "
|
||||
"forget to fetch?".format("\n".join(targets))
|
||||
)
|
||||
super(CheckoutError, self).__init__(m)
|
||||
super().__init__(m)
|
||||
|
||||
|
||||
class CollectCacheError(DvcException):
|
||||
@@ -316,14 +314,14 @@ class CollectCacheError(DvcException):
|
||||
|
||||
class NoRemoteInExternalRepoError(DvcException):
|
||||
def __init__(self, url):
|
||||
super(NoRemoteInExternalRepoError, self).__init__(
|
||||
super().__init__(
|
||||
"No DVC remote is specified in target repository '{}'.".format(url)
|
||||
)
|
||||
|
||||
|
||||
class NoOutputInExternalRepoError(DvcException):
|
||||
def __init__(self, path, external_repo_path, external_repo_url):
|
||||
super(NoOutputInExternalRepoError, self).__init__(
|
||||
super().__init__(
|
||||
"Output '{}' not found in target repository '{}'".format(
|
||||
relpath(path, external_repo_path), external_repo_url
|
||||
)
|
||||
@@ -332,7 +330,7 @@ class NoOutputInExternalRepoError(DvcException):
|
||||
|
||||
class HTTPError(DvcException):
|
||||
def __init__(self, code, reason):
|
||||
super(HTTPError, self).__init__("'{} {}'".format(code, reason))
|
||||
super().__init__("'{} {}'".format(code, reason))
|
||||
|
||||
|
||||
class PathMissingError(DvcException):
|
||||
@@ -341,4 +339,4 @@ class PathMissingError(DvcException):
|
||||
"The path '{}' does not exist in the target repository '{}'"
|
||||
" neighther as an output nor a git-handled file."
|
||||
)
|
||||
super(PathMissingError, self).__init__(msg.format(path, repo))
|
||||
super().__init__(msg.format(path, repo))
|
||||
|
||||
+2
-2
@@ -115,12 +115,12 @@ class HardlinkLock(flufl.lock.Lock):
|
||||
|
||||
def lock(self):
|
||||
try:
|
||||
super(Lock, self).lock(timedelta(seconds=DEFAULT_TIMEOUT))
|
||||
super().lock(timedelta(seconds=DEFAULT_TIMEOUT))
|
||||
except flufl.lock.TimeOutError:
|
||||
raise LockError(FAILED_TO_LOCK_MESSAGE)
|
||||
|
||||
def _set_claimfile(self, pid=None):
|
||||
super(Lock, self)._set_claimfile(pid)
|
||||
super()._set_claimfile(pid)
|
||||
|
||||
if self._tmp_dir is not None:
|
||||
# Under Windows file path length is limited so we hash it
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ FOOTER = (
|
||||
class LoggingException(Exception):
|
||||
def __init__(self, record):
|
||||
msg = "failed to log {}".format(str(record))
|
||||
super(LoggingException, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class ExcludeErrorsFilter(logging.Filter):
|
||||
@@ -147,7 +147,7 @@ class ColorFormatter(logging.Formatter):
|
||||
|
||||
class LoggerHandler(logging.StreamHandler):
|
||||
def handleError(self, record):
|
||||
super(LoggerHandler, self).handleError(record)
|
||||
super().handleError(record)
|
||||
raise LoggingException(record)
|
||||
|
||||
def emit(self, record):
|
||||
|
||||
+4
-6
@@ -17,26 +17,24 @@ logger = logging.getLogger(__name__)
|
||||
class OutputDoesNotExistError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "output '{}' does not exist".format(path)
|
||||
super(OutputDoesNotExistError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class OutputIsNotFileOrDirError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "output '{}' is not a file or directory".format(path)
|
||||
super(OutputIsNotFileOrDirError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class OutputAlreadyTrackedError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "output '{}' is already tracked by scm (e.g. git)".format(path)
|
||||
super(OutputAlreadyTrackedError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class OutputIsStageFileError(DvcException):
|
||||
def __init__(self, path):
|
||||
super(OutputIsStageFileError, self).__init__(
|
||||
"Stage file '{}' cannot be an output.".format(path)
|
||||
)
|
||||
super().__init__("Stage file '{}' cannot be an output.".format(path))
|
||||
|
||||
|
||||
class OutputBase(object):
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class OutputLOCAL(OutputBase):
|
||||
return def_scheme != "remote" and not os.path.isabs(self.def_path)
|
||||
|
||||
def dumpd(self):
|
||||
ret = super(OutputLOCAL, self).dumpd()
|
||||
ret = super().dumpd()
|
||||
if self.is_in_repo:
|
||||
path = self.path_info.relpath(self.stage.wdir).as_posix()
|
||||
else:
|
||||
|
||||
+3
-3
@@ -77,7 +77,7 @@ class Tqdm(tqdm):
|
||||
and hasattr(file, "isatty")
|
||||
):
|
||||
disable = not file.isatty()
|
||||
super(Tqdm, self).__init__(
|
||||
super().__init__(
|
||||
iterable=iterable,
|
||||
disable=disable,
|
||||
leave=leave,
|
||||
@@ -114,12 +114,12 @@ class Tqdm(tqdm):
|
||||
def close(self):
|
||||
if self.desc_persist is not None:
|
||||
self.set_description_str(self.desc_persist, refresh=False)
|
||||
super(Tqdm, self).close()
|
||||
super().close()
|
||||
|
||||
@property
|
||||
def format_dict(self):
|
||||
"""inject `ncols_desc` to fill the display width (`ncols`)"""
|
||||
d = super(Tqdm, self).format_dict
|
||||
d = super().format_dict
|
||||
ncols = d["ncols"] or 80
|
||||
ncols_desc = ncols - len(self.format_meter(ncols_desc=1, **d)) + 1
|
||||
ncols_desc = max(ncols_desc, 0)
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class RemoteAZURE(RemoteBASE):
|
||||
COPY_POLL_SECONDS = 5
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteAZURE, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
|
||||
url = config.get(Config.SECTION_REMOTE_URL, "azure://")
|
||||
|
||||
|
||||
+3
-3
@@ -46,7 +46,7 @@ STATUS_MAP = {
|
||||
|
||||
class RemoteCmdError(DvcException):
|
||||
def __init__(self, remote, cmd, ret, err):
|
||||
super(RemoteCmdError, self).__init__(
|
||||
super().__init__(
|
||||
"{remote} command '{cmd}' finished with non-zero return code"
|
||||
" {ret}': {err}".format(remote=remote, cmd=cmd, ret=ret, err=err)
|
||||
)
|
||||
@@ -55,7 +55,7 @@ class RemoteCmdError(DvcException):
|
||||
class RemoteActionNotImplemented(DvcException):
|
||||
def __init__(self, action, scheme):
|
||||
m = "{} is not supported for {} remotes".format(action, scheme)
|
||||
super(RemoteActionNotImplemented, self).__init__(m)
|
||||
super().__init__(m)
|
||||
|
||||
|
||||
class RemoteMissingDepsError(DvcException):
|
||||
@@ -64,7 +64,7 @@ class RemoteMissingDepsError(DvcException):
|
||||
|
||||
class DirCacheError(DvcException):
|
||||
def __init__(self, checksum, cause=None):
|
||||
super(DirCacheError, self).__init__(
|
||||
super().__init__(
|
||||
"Failed to load dir cache for checksum: '{}'.".format(checksum),
|
||||
cause=cause,
|
||||
)
|
||||
|
||||
@@ -20,17 +20,17 @@ FOLDER_MIME_TYPE = "application/vnd.google-apps.folder"
|
||||
|
||||
class GDriveRetriableError(DvcException):
|
||||
def __init__(self, msg, cause=None):
|
||||
super(GDriveRetriableError, self).__init__(msg, cause=cause)
|
||||
super().__init__(msg, cause=cause)
|
||||
|
||||
|
||||
class GDriveAccessTokenRefreshError(DvcException):
|
||||
def __init__(self, msg, cause=None):
|
||||
super(GDriveAccessTokenRefreshError, self).__init__(msg, cause=cause)
|
||||
super().__init__(msg, cause=cause)
|
||||
|
||||
|
||||
class GDriveMissedCredentialKeyError(DvcException):
|
||||
def __init__(self, msg, cause=None):
|
||||
super(GDriveMissedCredentialKeyError, self).__init__(msg, cause=cause)
|
||||
super().__init__(msg, cause=cause)
|
||||
|
||||
|
||||
@decorator
|
||||
@@ -68,7 +68,7 @@ class RemoteGDrive(RemoteBASE):
|
||||
DEFAULT_USER_CREDENTIALS_FILE = "gdrive-user-credentials.json"
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteGDrive, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
self.no_traverse = False
|
||||
self.path_info = self.path_cls(config[Config.SECTION_REMOTE_URL])
|
||||
self.config = config
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class RemoteGS(RemoteBASE):
|
||||
PARAM_CHECKSUM = "md5"
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteGS, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
|
||||
url = config.get(Config.SECTION_REMOTE_URL, "gs:///")
|
||||
self.path_info = self.path_cls(url)
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class RemoteHDFS(RemoteBASE):
|
||||
REQUIRES = {"pyarrow": "pyarrow"}
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteHDFS, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
self.path_info = None
|
||||
url = config.get(Config.SECTION_REMOTE_URL)
|
||||
if not url:
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class RemoteHTTP(RemoteBASE):
|
||||
PARAM_CHECKSUM = "etag"
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteHTTP, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
|
||||
url = config.get(Config.SECTION_REMOTE_URL)
|
||||
self.path_info = self.path_cls(url) if url else None
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class RemoteLOCAL(RemoteBASE):
|
||||
SHARED_MODE_MAP = {None: (0o644, 0o755), "group": (0o664, 0o775)}
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteLOCAL, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
self.protected = config.get(Config.SECTION_CACHE_PROTECTED, False)
|
||||
|
||||
shared = config.get(Config.SECTION_CACHE_SHARED)
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ class RemoteOSS(RemoteBASE):
|
||||
COPY_POLL_SECONDS = 5
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteOSS, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
|
||||
url = config.get(Config.SECTION_REMOTE_URL)
|
||||
self.path_info = self.path_cls(url) if url else None
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class RemoteS3(RemoteBASE):
|
||||
PARAM_CHECKSUM = "etag"
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteS3, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
|
||||
url = config.get(Config.SECTION_REMOTE_URL, "s3://")
|
||||
self.path_info = self.path_cls(url)
|
||||
|
||||
@@ -49,7 +49,7 @@ class RemoteSSH(RemoteBASE):
|
||||
DEFAULT_CACHE_TYPES = ["copy"]
|
||||
|
||||
def __init__(self, repo, config):
|
||||
super(RemoteSSH, self).__init__(repo, config)
|
||||
super().__init__(repo, config)
|
||||
url = config.get(Config.SECTION_REMOTE_URL)
|
||||
if url:
|
||||
parsed = urlparse(url)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class GetDVCFileError(DvcException):
|
||||
def __init__(self):
|
||||
super(GetDVCFileError, self).__init__(
|
||||
super().__init__(
|
||||
"the given path is a DVC-file, you must specify a data file "
|
||||
"or a directory"
|
||||
)
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ SCHEMA = Schema({"write": {str: INFO_SCHEMA}, "read": {str: [INFO_SCHEMA]}})
|
||||
|
||||
class RWLockFileCorruptedError(DvcException):
|
||||
def __init__(self, path, cause):
|
||||
super(RWLockFileCorruptedError, self).__init__(
|
||||
super().__init__(
|
||||
"Unable to read RWLock-file '{}'. JSON structure is "
|
||||
"corrupted".format(relpath(path)),
|
||||
cause=cause,
|
||||
@@ -27,7 +27,7 @@ class RWLockFileCorruptedError(DvcException):
|
||||
|
||||
class RWLockFileFormatError(DvcException):
|
||||
def __init__(self, path, cause):
|
||||
super(RWLockFileFormatError, self).__init__(
|
||||
super().__init__(
|
||||
"RWLock-file '{}' format error.".format(relpath(path)), cause=cause
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -23,14 +23,14 @@ class FileNotInCommitError(SCMError):
|
||||
|
||||
class CloneError(SCMError):
|
||||
def __init__(self, url, path, cause):
|
||||
super(CloneError, self).__init__(
|
||||
super().__init__(
|
||||
"Failed to clone repo '{}' to '{}'".format(url, path), cause=cause
|
||||
)
|
||||
|
||||
|
||||
class RevError(SCMError):
|
||||
def __init__(self, url, rev, cause):
|
||||
super(RevError, self).__init__(
|
||||
super().__init__(
|
||||
"Failed to access revision '{}' for repo '{}'".format(rev, url),
|
||||
cause=cause,
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ class Git(Base):
|
||||
"""Git class constructor.
|
||||
Requires `Repo` class from `git` module (from gitpython package).
|
||||
"""
|
||||
super(Git, self).__init__(root_dir)
|
||||
super().__init__(root_dir)
|
||||
|
||||
import git
|
||||
from git.exc import InvalidGitRepositoryError
|
||||
|
||||
+12
-12
@@ -33,13 +33,13 @@ logger = logging.getLogger(__name__)
|
||||
class StageCmdFailedError(DvcException):
|
||||
def __init__(self, stage):
|
||||
msg = "stage '{}' cmd '{}' failed".format(stage.relpath, stage.cmd)
|
||||
super(StageCmdFailedError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class StageFileFormatError(DvcException):
|
||||
def __init__(self, fname, e):
|
||||
msg = "DVC-file '{}' format error: {}".format(fname, str(e))
|
||||
super(StageFileFormatError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class StageFileDoesNotExistError(DvcException):
|
||||
@@ -50,13 +50,13 @@ class StageFileDoesNotExistError(DvcException):
|
||||
if Stage.is_stage_file(sname):
|
||||
msg += " Do you mean '{}'?".format(sname)
|
||||
|
||||
super(StageFileDoesNotExistError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class StageFileAlreadyExistsError(DvcException):
|
||||
def __init__(self, relpath):
|
||||
msg = "stage '{}' already exists".format(relpath)
|
||||
super(StageFileAlreadyExistsError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class StageFileIsNotDvcFileError(DvcException):
|
||||
@@ -67,30 +67,30 @@ class StageFileIsNotDvcFileError(DvcException):
|
||||
if Stage.is_stage_file(sname):
|
||||
msg += " Do you mean '{}'?".format(sname)
|
||||
|
||||
super(StageFileIsNotDvcFileError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class StageFileBadNameError(DvcException):
|
||||
def __init__(self, msg):
|
||||
super(StageFileBadNameError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class StagePathOutsideError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "stage working or file path '{}' is outside of dvc repo"
|
||||
super(StagePathOutsideError, self).__init__(msg.format(path))
|
||||
super().__init__(msg.format(path))
|
||||
|
||||
|
||||
class StagePathNotFoundError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "stage working or file path '{}' does not exist"
|
||||
super(StagePathNotFoundError, self).__init__(msg.format(path))
|
||||
super().__init__(msg.format(path))
|
||||
|
||||
|
||||
class StagePathNotDirectoryError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = "stage working or file path '{}' is not directory"
|
||||
super(StagePathNotDirectoryError, self).__init__(msg.format(path))
|
||||
super().__init__(msg.format(path))
|
||||
|
||||
|
||||
class StageCommitError(DvcException):
|
||||
@@ -99,7 +99,7 @@ class StageCommitError(DvcException):
|
||||
|
||||
class StageUpdateError(DvcException):
|
||||
def __init__(self, path):
|
||||
super(StageUpdateError, self).__init__(
|
||||
super().__init__(
|
||||
"update is not supported for '{}' that is not an "
|
||||
"import.".format(path)
|
||||
)
|
||||
@@ -115,7 +115,7 @@ class MissingDep(DvcException):
|
||||
dep = "dependency"
|
||||
|
||||
msg = "missing '{}': {}".format(dep, ", ".join(map(str, deps)))
|
||||
super(MissingDep, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class MissingDataSource(DvcException):
|
||||
@@ -127,7 +127,7 @@ class MissingDataSource(DvcException):
|
||||
source += "s"
|
||||
|
||||
msg = "missing data '{}': {}".format(source, ", ".join(missing_files))
|
||||
super(MissingDataSource, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
@decorator
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ class StateVersionTooNewError(DvcException):
|
||||
"""Thrown when dvc version is older than the state database version."""
|
||||
|
||||
def __init__(self, dvc_version, expected, actual):
|
||||
super(StateVersionTooNewError, self).__init__(
|
||||
super().__init__(
|
||||
"you are using an old version '{dvc_version}' of dvc that is "
|
||||
"using state file version '{expected}' which is not compatible "
|
||||
"with the state file version '{actual}' that is used in this "
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ class BasePathNotInCheckedPathException(DvcException):
|
||||
msg = "Path: {} does not overlap with base path: {}".format(
|
||||
path, base_path
|
||||
)
|
||||
super(DvcException, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
def contains_symlink_up_to(path, base_path):
|
||||
|
||||
+6
-6
@@ -117,7 +117,7 @@ class TestGitFixture(TestDirFixture):
|
||||
N_RETRIES = 5
|
||||
|
||||
def setUp(self):
|
||||
super(TestGitFixture, self).setUp()
|
||||
super().setUp()
|
||||
# NOTE: handles EAGAIN error on BSD systems (osx in our case).
|
||||
# Otherwise when running tests you might get this exception:
|
||||
#
|
||||
@@ -138,12 +138,12 @@ class TestGitFixture(TestDirFixture):
|
||||
|
||||
def tearDown(self):
|
||||
self.git.close()
|
||||
super(TestGitFixture, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
|
||||
class TestGitSubmoduleFixture(TestGitFixture):
|
||||
def setUp(self):
|
||||
super(TestGitSubmoduleFixture, self).setUp()
|
||||
super().setUp()
|
||||
subrepo = Repo.init()
|
||||
subrepo_path = "subrepo"
|
||||
self.git.create_submodule(subrepo_path, subrepo_path, subrepo.git_dir)
|
||||
@@ -152,19 +152,19 @@ class TestGitSubmoduleFixture(TestGitFixture):
|
||||
|
||||
class TestDvcFixture(TestDirFixture):
|
||||
def setUp(self):
|
||||
super(TestDvcFixture, self).setUp()
|
||||
super().setUp()
|
||||
self.dvc = DvcRepo.init(self.root_dir, no_scm=True)
|
||||
|
||||
|
||||
class TestDvcGitFixture(TestGitFixture):
|
||||
def setUp(self):
|
||||
super(TestDvcGitFixture, self).setUp()
|
||||
super().setUp()
|
||||
self.dvc = DvcRepo.init(self.root_dir)
|
||||
self.dvc.scm.commit("init dvc")
|
||||
|
||||
def tearDown(self):
|
||||
self.dvc.scm.close()
|
||||
super(TestDvcGitFixture, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
|
||||
# NOTE: Inheritance order in the classes below is important.
|
||||
|
||||
@@ -14,7 +14,7 @@ from tests.basic_env import TestDvc
|
||||
|
||||
class TestCache(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestCache, self).setUp()
|
||||
super().setUp()
|
||||
self.cache1_md5 = "123"
|
||||
self.cache2_md5 = "234"
|
||||
self.cache1 = os.path.join(
|
||||
|
||||
@@ -30,7 +30,7 @@ logger = logging.getLogger("dvc")
|
||||
|
||||
class TestCheckout(TestRepro):
|
||||
def setUp(self):
|
||||
super(TestCheckout, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
stages = self.dvc.add(self.DATA_DIR)
|
||||
self.assertEqual(len(stages), 1)
|
||||
|
||||
@@ -296,7 +296,7 @@ class TestRemoteLOCAL(TestDataCloudBase):
|
||||
return RemoteLOCAL
|
||||
|
||||
def test(self):
|
||||
super(TestRemoteLOCAL, self).test()
|
||||
super().test()
|
||||
self.assertTrue(os.path.isdir(self.dname))
|
||||
|
||||
|
||||
@@ -706,7 +706,7 @@ class TestCheckSumRecalculation(TestDvc):
|
||||
|
||||
class TestShouldWarnOnNoChecksumInLocalAndRemoteCache(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestShouldWarnOnNoChecksumInLocalAndRemoteCache, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
cache_dir = self.mkdtemp()
|
||||
ret = main(["add", self.FOO])
|
||||
|
||||
@@ -8,7 +8,7 @@ from tests.basic_env import TestDvcGit
|
||||
|
||||
class TestDiff(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestDiff, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.new_file = "new_test_file"
|
||||
self.create(self.new_file, self.new_file)
|
||||
@@ -56,7 +56,7 @@ class TestDiffCmdLine(TestDiff):
|
||||
|
||||
class TestDiffDir(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestDiffDir, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
stage = self.dvc.add(self.DATA_DIR)[0]
|
||||
self.git.index.add([self.DATA_DIR + ".dvc"])
|
||||
@@ -116,7 +116,7 @@ class TestDiffDirRepoDeletedFile(TestDiffDir):
|
||||
maxDiff = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestDiffDirRepoDeletedFile, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.b_ref = self.a_ref
|
||||
tmp = self.new_checksum
|
||||
@@ -153,7 +153,7 @@ class TestDiffDirRepoDeletedFile(TestDiffDir):
|
||||
|
||||
class TestDiffFileNotFound(TestDiffDir):
|
||||
def setUp(self):
|
||||
super(TestDiffFileNotFound, self).setUp()
|
||||
super().setUp()
|
||||
self.unknown_file = "unknown_file_" + str(id(self))
|
||||
|
||||
def test(self):
|
||||
@@ -165,7 +165,7 @@ class TestDiffModifiedFile(TestDiff):
|
||||
maxDiff = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestDiffModifiedFile, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.old_checksum = self.new_checksum
|
||||
self.new_file_content = "new_test_file_bigger_content_123456789"
|
||||
@@ -200,7 +200,7 @@ class TestDiffDirWithFile(TestDiffDir):
|
||||
maxDiff = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestDiffDirWithFile, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.a_ref = self.git.git.rev_parse(self.git.head.commit, short=True)
|
||||
self.old_checksum = self.new_checksum
|
||||
|
||||
@@ -12,7 +12,7 @@ from tests.basic_env import TestDir, TestDvcGit
|
||||
|
||||
class TestGC(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestGC, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.dvc.add(self.FOO)
|
||||
self.dvc.add(self.DATA_DIR)
|
||||
@@ -112,7 +112,7 @@ class TestGCMultipleDvcRepos(TestDvcGit):
|
||||
self.assertEqual(total, num)
|
||||
|
||||
def setUp(self):
|
||||
super(TestGCMultipleDvcRepos, self).setUp()
|
||||
super().setUp()
|
||||
self.additional_path = TestDir.mkdtemp()
|
||||
self.additional_git = Repo.init(self.additional_path)
|
||||
self.additional_dvc = DvcRepo.init(self.additional_path)
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestDefaultOutput(TestDvc):
|
||||
|
||||
class TestShouldRemoveOutsBeforeImport(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestShouldRemoveOutsBeforeImport, self).setUp()
|
||||
super().setUp()
|
||||
tmp_dir = self.mkdtemp()
|
||||
self.external_source = os.path.join(tmp_dir, "file")
|
||||
with open(self.external_source, "w") as fobj:
|
||||
@@ -63,7 +63,7 @@ class TestShouldRemoveOutsBeforeImport(TestDvc):
|
||||
|
||||
class TestImportFilename(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestImportFilename, self).setUp()
|
||||
super().setUp()
|
||||
tmp_dir = self.mkdtemp()
|
||||
self.external_source = os.path.join(tmp_dir, "file")
|
||||
with open(self.external_source, "w") as fobj:
|
||||
|
||||
@@ -15,7 +15,7 @@ from tests.basic_env import TestDvcGit
|
||||
|
||||
class TestMetricsBase(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestMetricsBase, self).setUp()
|
||||
super().setUp()
|
||||
self.dvc.scm.commit("init")
|
||||
|
||||
branches = ["foo", "bar", "baz"]
|
||||
@@ -386,7 +386,7 @@ class TestMetrics(TestMetricsBase):
|
||||
|
||||
class TestMetricsRecursive(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestMetricsRecursive, self).setUp()
|
||||
super().setUp()
|
||||
self.dvc.scm.commit("init")
|
||||
|
||||
self.dvc.scm.checkout("nested", create_new=True)
|
||||
@@ -763,7 +763,7 @@ class TestMetricsType(TestDvcGit):
|
||||
xpaths = [None, None, "branch", "0,0", "0,branch", "0,0", "0,branch"]
|
||||
|
||||
def setUp(self):
|
||||
super(TestMetricsType, self).setUp()
|
||||
super().setUp()
|
||||
self.dvc.scm.commit("init")
|
||||
|
||||
for branch in self.branches:
|
||||
|
||||
@@ -8,7 +8,7 @@ from tests.func.test_repro import TestReproChangedDeepData
|
||||
|
||||
class TestPipelineShowSingle(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestPipelineShowSingle, self).setUp()
|
||||
super().setUp()
|
||||
self.stage = "foo.dvc"
|
||||
ret = main(["add", self.FOO])
|
||||
self.assertEqual(ret, 0)
|
||||
@@ -123,7 +123,7 @@ def test_dot_outs(repo_dir, dvc_repo):
|
||||
|
||||
class TestPipelineShowOuts(TestRepro):
|
||||
def setUp(self):
|
||||
super(TestPipelineShowOuts, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def test_outs(self):
|
||||
ret = main(["pipeline", "show", self.file1_stage, "--outs"])
|
||||
|
||||
@@ -47,7 +47,7 @@ from tests.utils.httpd import StaticFileServer, ContentMD5Handler
|
||||
|
||||
class TestRepro(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestRepro, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
stages = self.dvc.add(self.FOO)
|
||||
self.assertEqual(len(stages), 1)
|
||||
@@ -372,7 +372,7 @@ class TestReproDryNoExec(TestDvc):
|
||||
|
||||
class TestReproChangedDeepData(TestReproChangedData):
|
||||
def setUp(self):
|
||||
super(TestReproChangedDeepData, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.file2 = "file2"
|
||||
self.file2_stage = self.file2 + ".dvc"
|
||||
@@ -453,7 +453,7 @@ class TestReproPipeline(TestReproChangedDeepData):
|
||||
|
||||
class TestReproPipelines(TestDvc):
|
||||
def setUp(self):
|
||||
super(TestReproPipelines, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
stages = self.dvc.add(self.FOO)
|
||||
self.assertEqual(len(stages), 1)
|
||||
@@ -1102,7 +1102,7 @@ class TestReproExternalSSH(TestReproExternalBase):
|
||||
|
||||
class TestReproExternalLOCAL(TestReproExternalBase):
|
||||
def setUp(self):
|
||||
super(TestReproExternalLOCAL, self).setUp()
|
||||
super().setUp()
|
||||
self.tmpdir = TestDvc.mkdtemp()
|
||||
ret = main(["config", "cache.type", "hardlink"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
@@ -874,9 +874,7 @@ class TestNewRunShouldNotRemoveOutsOnPersist(TestRerunWithSameOutputs):
|
||||
|
||||
class TestShouldNotCheckoutUponCorruptedLocalHardlinkCache(TestDvc):
|
||||
def setUp(self):
|
||||
super(
|
||||
TestShouldNotCheckoutUponCorruptedLocalHardlinkCache, self
|
||||
).setUp()
|
||||
super().setUp()
|
||||
ret = main(["config", "cache.type", "hardlink"])
|
||||
self.assertEqual(ret, 0)
|
||||
self.dvc = DvcRepo(".")
|
||||
|
||||
@@ -13,7 +13,7 @@ from tests.basic_env import TestGitSubmodule
|
||||
|
||||
class TestWorkingTree(TestDir):
|
||||
def setUp(self):
|
||||
super(TestWorkingTree, self).setUp()
|
||||
super().setUp()
|
||||
self.tree = WorkingTree()
|
||||
|
||||
def test_open(self):
|
||||
@@ -79,14 +79,14 @@ class GitTreeTests(object):
|
||||
|
||||
class TestGitTree(TestGit, GitTreeTests):
|
||||
def setUp(self):
|
||||
super(TestGitTree, self).setUp()
|
||||
super().setUp()
|
||||
self.scm = SCM(self._root_dir)
|
||||
self.tree = GitTree(self.git, "master")
|
||||
|
||||
|
||||
class TestGitSubmoduleTree(TestGitSubmodule, GitTreeTests):
|
||||
def setUp(self):
|
||||
super(TestGitSubmoduleTree, self).setUp()
|
||||
super().setUp()
|
||||
self.scm = SCM(self._root_dir)
|
||||
self.tree = GitTree(self.git, "master")
|
||||
self._pushd(self._root_dir)
|
||||
|
||||
Reference in New Issue
Block a user