From 3098460f567707fad5d5d63015f60e9798e83d61 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 17 Aug 2019 16:36:59 +0100 Subject: [PATCH] misc minor style fixes & optimisations --- .gitignore | 1 + dvc/remote/local/__init__.py | 16 ++++++++-------- dvc/remote/ssh/__init__.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 514e9ba8b..d2a206fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ innosetup/config.ini *.exe .coverage +.coverage.* *.swp diff --git a/dvc/remote/local/__init__.py b/dvc/remote/local/__init__.py index 0572e5945..e0e0cb3d6 100644 --- a/dvc/remote/local/__init__.py +++ b/dvc/remote/local/__init__.py @@ -334,7 +334,8 @@ class RemoteLOCAL(RemoteBASE): return ret - def _fill_statuses(self, checksum_info_dir, local_exists, remote_exists): + @staticmethod + def _fill_statuses(checksum_info_dir, local_exists, remote_exists): # Using sets because they are way faster for lookups local = set(local_exists) remote = set(remote_exists) @@ -436,7 +437,8 @@ class RemoteLOCAL(RemoteBASE): download=True, ) - def _log_missing_caches(self, checksum_info_dict): + @staticmethod + def _log_missing_caches(checksum_info_dict): missing_caches = [ (md5, info) for md5, info in checksum_info_dict.items() @@ -444,10 +446,8 @@ class RemoteLOCAL(RemoteBASE): ] if missing_caches: missing_desc = "".join( - [ - "\nname: {}, md5: {}".format(info["name"], md5) - for md5, info in missing_caches - ] + "\nname: {}, md5: {}".format(info["name"], md5) + for md5, info in missing_caches ) msg = ( "Some of the cache files do not exist neither locally " @@ -479,8 +479,8 @@ class RemoteLOCAL(RemoteBASE): os.chmod(path, os.stat(path).st_mode | stat.S_IWRITE) def _unprotect_dir(self, path): - for path in walk_files(path, self.repo.dvcignore): - RemoteLOCAL._unprotect_file(path) + for fname in walk_files(path, self.repo.dvcignore): + RemoteLOCAL._unprotect_file(fname) def unprotect(self, path_info): path = path_info.fspath diff --git a/dvc/remote/ssh/__init__.py b/dvc/remote/ssh/__init__.py index e0b8f45e4..826a68591 100644 --- a/dvc/remote/ssh/__init__.py +++ b/dvc/remote/ssh/__init__.py @@ -93,7 +93,7 @@ class RemoteSSH(RemoteBASE): @staticmethod def _load_user_ssh_config(hostname): user_config_file = RemoteSSH.ssh_config_filename() - user_ssh_config = dict() + user_ssh_config = {} if hostname and os.path.exists(user_config_file): ssh_config = paramiko.SSHConfig() with open(user_config_file) as f: