diff --git a/dvc/command/cache.py b/dvc/command/cache.py index 752a60714..62b64e4da 100644 --- a/dvc/command/cache.py +++ b/dvc/command/cache.py @@ -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): diff --git a/dvc/command/config.py b/dvc/command/config.py index 13f700c1b..079eee5ef 100644 --- a/dvc/command/config.py +++ b/dvc/command/config.py @@ -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) diff --git a/dvc/command/remote.py b/dvc/command/remote.py index e39024c68..0655d440c 100644 --- a/dvc/command/remote.py +++ b/dvc/command/remote.py @@ -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) diff --git a/dvc/config.py b/dvc/config.py index 206e17317..cc2fbdb4d 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -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 \n".format(command) ) - super(NoRemoteError, self).__init__(msg, cause=cause) + super().__init__(msg, cause=cause) def supported_cache_type(types): diff --git a/dvc/dependency/base.py b/dvc/dependency/base.py index 7a2062b21..270fdbba7 100644 --- a/dvc/dependency/base.py +++ b/dvc/dependency/base.py @@ -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) ) diff --git a/dvc/dependency/repo.py b/dvc/dependency/repo.py index 2bcda628e..a12e53f09 100644 --- a/dvc/dependency/repo.py +++ b/dvc/dependency/repo.py @@ -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 diff --git a/dvc/exceptions.py b/dvc/exceptions.py index bcfeb4789..8192a674d 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -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)) diff --git a/dvc/lock.py b/dvc/lock.py index 2a899acc0..ed2f2e21a 100644 --- a/dvc/lock.py +++ b/dvc/lock.py @@ -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 diff --git a/dvc/logger.py b/dvc/logger.py index 024667053..abe5757b9 100644 --- a/dvc/logger.py +++ b/dvc/logger.py @@ -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): diff --git a/dvc/output/base.py b/dvc/output/base.py index edc5780bd..0fca876c4 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -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): diff --git a/dvc/output/local.py b/dvc/output/local.py index a5585a052..0e1b72dc9 100644 --- a/dvc/output/local.py +++ b/dvc/output/local.py @@ -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: diff --git a/dvc/progress.py b/dvc/progress.py index b9898a907..f3c568923 100644 --- a/dvc/progress.py +++ b/dvc/progress.py @@ -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) diff --git a/dvc/remote/azure.py b/dvc/remote/azure.py index 96967aae4..72c3bee42 100644 --- a/dvc/remote/azure.py +++ b/dvc/remote/azure.py @@ -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://") diff --git a/dvc/remote/base.py b/dvc/remote/base.py index e9ec778b6..df71c9819 100644 --- a/dvc/remote/base.py +++ b/dvc/remote/base.py @@ -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, ) diff --git a/dvc/remote/gdrive.py b/dvc/remote/gdrive.py index bba3fb950..a23f9f17f 100644 --- a/dvc/remote/gdrive.py +++ b/dvc/remote/gdrive.py @@ -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 diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py index 05c620fb0..0419dc440 100644 --- a/dvc/remote/gs.py +++ b/dvc/remote/gs.py @@ -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) diff --git a/dvc/remote/hdfs.py b/dvc/remote/hdfs.py index d6adeb02e..4ce620408 100644 --- a/dvc/remote/hdfs.py +++ b/dvc/remote/hdfs.py @@ -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: diff --git a/dvc/remote/http.py b/dvc/remote/http.py index 9dbb6fa64..caa094b97 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -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 diff --git a/dvc/remote/local.py b/dvc/remote/local.py index 54de5f495..4a6204dcd 100644 --- a/dvc/remote/local.py +++ b/dvc/remote/local.py @@ -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) diff --git a/dvc/remote/oss.py b/dvc/remote/oss.py index 2eb6cf958..b918d9ddd 100644 --- a/dvc/remote/oss.py +++ b/dvc/remote/oss.py @@ -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 diff --git a/dvc/remote/s3.py b/dvc/remote/s3.py index 5693f97c0..eb7d2e6b2 100644 --- a/dvc/remote/s3.py +++ b/dvc/remote/s3.py @@ -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) diff --git a/dvc/remote/ssh/__init__.py b/dvc/remote/ssh/__init__.py index 7f9a59bcb..e5755db76 100644 --- a/dvc/remote/ssh/__init__.py +++ b/dvc/remote/ssh/__init__.py @@ -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) diff --git a/dvc/repo/get.py b/dvc/repo/get.py index db591dbb9..17607bbfa 100644 --- a/dvc/repo/get.py +++ b/dvc/repo/get.py @@ -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" ) diff --git a/dvc/rwlock.py b/dvc/rwlock.py index f7afa5f55..fdc51b7fd 100644 --- a/dvc/rwlock.py +++ b/dvc/rwlock.py @@ -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 ) diff --git a/dvc/scm/base.py b/dvc/scm/base.py index 7ff877ae9..482c02e08 100644 --- a/dvc/scm/base.py +++ b/dvc/scm/base.py @@ -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, ) diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 06521f540..245c9b7ef 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -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 diff --git a/dvc/stage.py b/dvc/stage.py index 5d0a0bf19..204910864 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -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 diff --git a/dvc/state.py b/dvc/state.py index 336569024..4b5b0889b 100644 --- a/dvc/state.py +++ b/dvc/state.py @@ -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 " diff --git a/dvc/utils/fs.py b/dvc/utils/fs.py index d116924b2..929867bb6 100644 --- a/dvc/utils/fs.py +++ b/dvc/utils/fs.py @@ -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): diff --git a/tests/basic_env.py b/tests/basic_env.py index 8a6667c45..119a59918 100644 --- a/tests/basic_env.py +++ b/tests/basic_env.py @@ -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. diff --git a/tests/func/test_cache.py b/tests/func/test_cache.py index 0943df7fe..eb44bbacd 100644 --- a/tests/func/test_cache.py +++ b/tests/func/test_cache.py @@ -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( diff --git a/tests/func/test_checkout.py b/tests/func/test_checkout.py index 73d614b17..8ca43c24b 100644 --- a/tests/func/test_checkout.py +++ b/tests/func/test_checkout.py @@ -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) diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index 2de59d2e7..9ee5599b7 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -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]) diff --git a/tests/func/test_diff.py b/tests/func/test_diff.py index dd9be725d..15d2cc982 100644 --- a/tests/func/test_diff.py +++ b/tests/func/test_diff.py @@ -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 diff --git a/tests/func/test_gc.py b/tests/func/test_gc.py index fea5b8d27..386f168cf 100644 --- a/tests/func/test_gc.py +++ b/tests/func/test_gc.py @@ -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) diff --git a/tests/func/test_import_url.py b/tests/func/test_import_url.py index 855484371..de212da73 100644 --- a/tests/func/test_import_url.py +++ b/tests/func/test_import_url.py @@ -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: diff --git a/tests/func/test_metrics.py b/tests/func/test_metrics.py index ee5e89516..5a37699e5 100644 --- a/tests/func/test_metrics.py +++ b/tests/func/test_metrics.py @@ -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: diff --git a/tests/func/test_pipeline.py b/tests/func/test_pipeline.py index c1de332d5..312efdddb 100644 --- a/tests/func/test_pipeline.py +++ b/tests/func/test_pipeline.py @@ -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"]) diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py index 057f947c1..0348d500f 100644 --- a/tests/func/test_repro.py +++ b/tests/func/test_repro.py @@ -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) diff --git a/tests/func/test_run.py b/tests/func/test_run.py index 61db6c98e..5d43b5083 100644 --- a/tests/func/test_run.py +++ b/tests/func/test_run.py @@ -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(".") diff --git a/tests/func/test_tree.py b/tests/func/test_tree.py index ef4412e8c..64bd2d324 100644 --- a/tests/func/test_tree.py +++ b/tests/func/test_tree.py @@ -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)