← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~aaron-whitehouse/duplicity/pep8_test_fixes into lp:duplicity

 

Aaron Whitehouse has proposed merging lp:~aaron-whitehouse/duplicity/pep8_test_fixes into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)

For more details, see:
https://code.launchpad.net/~aaron-whitehouse/duplicity/pep8_test_fixes/+merge/317733

* Fix PEP-8 testing by moving to using pycodestyle library.
* Temporarily add ignores to allow these tests to pass.
* Fix E305 PEP8 errors: expected 2 blank lines after class or function definition, found 1.
-- 
Your team duplicity-team is requested to review the proposed merge of lp:~aaron-whitehouse/duplicity/pep8_test_fixes into lp:duplicity.
=== modified file 'bin/duplicity'
--- bin/duplicity	2017-01-19 17:54:29 +0000
+++ bin/duplicity	2017-02-20 00:07:15 +0000
@@ -1541,6 +1541,7 @@
     finally:
         tempdir.default().cleanup()
 
+
 if __name__ == "__main__":
     try:
         with_tempdir(main)

=== modified file 'duplicity/backends/acdclibackend.py'
--- duplicity/backends/acdclibackend.py	2016-08-18 16:06:51 +0000
+++ duplicity/backends/acdclibackend.py	2017-02-20 00:07:15 +0000
@@ -148,4 +148,5 @@
         commandline = self.acd_cmd + " rm '%s'" % (remote_file_path)
         self.subprocess_popen(commandline)
 
+
 duplicity.backend.register_backend("acd+acdcli", ACDBackend)

=== modified file 'duplicity/backends/adbackend.py'
--- duplicity/backends/adbackend.py	2017-01-15 22:08:29 +0000
+++ duplicity/backends/adbackend.py	2017-02-20 00:07:15 +0000
@@ -404,4 +404,5 @@
         response.raise_for_status()
         del self.names_to_ids[remote_filename]
 
+
 duplicity.backend.register_backend('ad', ADBackend)

=== modified file 'duplicity/backends/azurebackend.py'
--- duplicity/backends/azurebackend.py	2016-05-11 21:07:04 +0000
+++ duplicity/backends/azurebackend.py	2017-02-20 00:07:15 +0000
@@ -102,4 +102,5 @@
         if isinstance(e, self.AzureMissingResourceError):
             return log.ErrorCode.backend_not_found
 
+
 duplicity.backend.register_backend('azure', AzureBackend)

=== modified file 'duplicity/backends/copycombackend.py'
--- duplicity/backends/copycombackend.py	2015-04-20 06:37:11 +0000
+++ duplicity/backends/copycombackend.py	2017-02-20 00:07:15 +0000
@@ -304,6 +304,7 @@
         except CoPyCloud.Error as e:
             raise BackendException(e)
 
+
 ''' This must be disabled here, because if a file in list does not exist, the
     Copy server will stop deleting the subsequent stuff, raising an error,
     making test_delete_list to fail.

=== modified file 'duplicity/backends/gdocsbackend.py'
--- duplicity/backends/gdocsbackend.py	2016-06-28 21:03:46 +0000
+++ duplicity/backends/gdocsbackend.py	2017-02-20 00:07:15 +0000
@@ -185,6 +185,7 @@
         # Done!
         return result
 
+
 """ gdata is an alternate way to access gdocs, currently 05/2015 lacking OAuth support """
 duplicity.backend.register_backend('gdata+gdocs', GDocsBackend)
 duplicity.backend.uses_netloc.extend(['gdata+gdocs'])

=== modified file 'duplicity/backends/giobackend.py'
--- duplicity/backends/giobackend.py	2016-01-29 11:43:58 +0000
+++ duplicity/backends/giobackend.py	2017-02-20 00:07:15 +0000
@@ -170,4 +170,5 @@
                                       Gio.FileQueryInfoFlags.NONE, None)
         return {'size': info.get_size()}
 
+
 duplicity.backend.register_backend_prefix('gio', GIOBackend)

=== modified file 'duplicity/backends/hsibackend.py'
--- duplicity/backends/hsibackend.py	2015-11-30 16:50:03 +0000
+++ duplicity/backends/hsibackend.py	2017-02-20 00:07:15 +0000
@@ -57,5 +57,6 @@
         commandline = '%s "rm %s%s"' % (hsi_command, self.remote_prefix, filename)
         self.subprocess_popen(commandline)
 
+
 duplicity.backend.register_backend("hsi", HSIBackend)
 duplicity.backend.uses_netloc.extend(['hsi'])

=== modified file 'duplicity/backends/hubicbackend.py'
--- duplicity/backends/hubicbackend.py	2015-07-04 15:37:53 +0000
+++ duplicity/backends/hubicbackend.py	2017-02-20 00:07:15 +0000
@@ -61,4 +61,5 @@
         self.nso_exc = pyrax.exceptions.NoSuchObject
         self.container = pyrax.cloudfiles.create_container(container)
 
+
 duplicity.backend.register_backend("cf+hubic", HubicBackend)

=== modified file 'duplicity/backends/imapbackend.py'
--- duplicity/backends/imapbackend.py	2016-01-29 11:43:58 +0000
+++ duplicity/backends/imapbackend.py	2017-02-20 00:07:15 +0000
@@ -257,6 +257,7 @@
         self.conn.close()
         self.conn.logout()
 
+
 duplicity.backend.register_backend("imap", ImapBackend)
 duplicity.backend.register_backend("imaps", ImapBackend)
 duplicity.backend.uses_netloc.extend(['imap', 'imaps'])

=== modified file 'duplicity/backends/jottacloudbackend.py'
--- duplicity/backends/jottacloudbackend.py	2016-11-01 18:01:27 +0000
+++ duplicity/backends/jottacloudbackend.py	2017-02-20 00:07:15 +0000
@@ -153,5 +153,6 @@
         # - If your backend needs to clean up after itself, do that here.
         pass
 
+
 duplicity.backend.register_backend("jottacloud", JottaCloudBackend)
 """ jottacloud is a Norwegian backup company """

=== modified file 'duplicity/backends/lftpbackend.py'
--- duplicity/backends/lftpbackend.py	2016-06-28 21:03:46 +0000
+++ duplicity/backends/lftpbackend.py	2017-02-20 00:07:15 +0000
@@ -200,6 +200,7 @@
         log.Debug("STDOUT:\n"
                   "%s" % (l))
 
+
 duplicity.backend.register_backend("ftp", LFTPBackend)
 duplicity.backend.register_backend("ftps", LFTPBackend)
 duplicity.backend.register_backend("fish", LFTPBackend)

=== modified file 'duplicity/backends/localbackend.py'
--- duplicity/backends/localbackend.py	2014-04-28 02:49:39 +0000
+++ duplicity/backends/localbackend.py	2017-02-20 00:07:15 +0000
@@ -73,4 +73,5 @@
         size = target_file.getsize() if target_file.exists() else -1
         return {'size': size}
 
+
 duplicity.backend.register_backend("file", LocalBackend)

=== modified file 'duplicity/backends/megabackend.py'
--- duplicity/backends/megabackend.py	2015-01-31 23:30:49 +0000
+++ duplicity/backends/megabackend.py	2017-02-20 00:07:15 +0000
@@ -122,5 +122,6 @@
 
         return result
 
+
 duplicity.backend.register_backend('mega', MegaBackend)
 duplicity.backend.uses_netloc.extend(['mega'])

=== modified file 'duplicity/backends/multibackend.py'
--- duplicity/backends/multibackend.py	2016-06-28 21:03:46 +0000
+++ duplicity/backends/multibackend.py	2017-02-20 00:07:15 +0000
@@ -296,4 +296,5 @@
                     log.ERROR)
 #           raise BackendException("failed to delete")
 
+
 duplicity.backend.register_backend('multi', MultiBackend)

=== modified file 'duplicity/backends/ncftpbackend.py'
--- duplicity/backends/ncftpbackend.py	2016-01-23 21:03:55 +0000
+++ duplicity/backends/ncftpbackend.py	2017-02-20 00:07:15 +0000
@@ -116,5 +116,6 @@
             (self.flags, filename, self.url_string)
         self.subprocess_popen(commandline)
 
+
 duplicity.backend.register_backend("ncftp+ftp", NCFTPBackend)
 duplicity.backend.uses_netloc.extend(['ncftp+ftp'])

=== modified file 'duplicity/backends/onedrivebackend.py'
--- duplicity/backends/onedrivebackend.py	2017-02-07 16:11:01 +0000
+++ duplicity/backends/onedrivebackend.py	2017-02-20 00:07:15 +0000
@@ -345,4 +345,5 @@
     def _retry_cleanup(self):
         self.initialize_oauth2_session()
 
+
 duplicity.backend.register_backend('onedrive', OneDriveBackend)

=== modified file 'duplicity/backends/par2backend.py'
--- duplicity/backends/par2backend.py	2016-11-16 22:43:11 +0000
+++ duplicity/backends/par2backend.py	2017-02-20 00:07:15 +0000
@@ -210,4 +210,5 @@
     def close(self):
         self.wrapped_backend._close()
 
+
 backend.register_backend_prefix('par2', Par2Backend)

=== modified file 'duplicity/backends/pydrivebackend.py'
--- duplicity/backends/pydrivebackend.py	2016-11-01 14:08:20 +0000
+++ duplicity/backends/pydrivebackend.py	2017-02-20 00:07:15 +0000
@@ -217,6 +217,7 @@
                 return log.ErrorCode.backend_permission_denied
         return log.ErrorCode.backend_error
 
+
 duplicity.backend.register_backend('pydrive', PyDriveBackend)
 """ pydrive is an alternate way to access gdocs """
 duplicity.backend.register_backend('pydrive+gdocs', PyDriveBackend)

=== modified file 'duplicity/backends/rsyncbackend.py'
--- duplicity/backends/rsyncbackend.py	2016-06-12 13:13:57 +0000
+++ duplicity/backends/rsyncbackend.py	2017-02-20 00:07:15 +0000
@@ -153,5 +153,6 @@
             util.ignore_missing(os.unlink, file)
         os.rmdir(dir)
 
+
 duplicity.backend.register_backend("rsync", RsyncBackend)
 duplicity.backend.uses_netloc.extend(['rsync'])

=== modified file 'duplicity/backends/ssh_paramiko_backend.py'
--- duplicity/backends/ssh_paramiko_backend.py	2016-06-29 22:40:59 +0000
+++ duplicity/backends/ssh_paramiko_backend.py	2017-02-20 00:07:15 +0000
@@ -406,6 +406,7 @@
 
         return sshconfig.lookup(host)
 
+
 duplicity.backend.register_backend("sftp", SSHParamikoBackend)
 duplicity.backend.register_backend("scp", SSHParamikoBackend)
 duplicity.backend.register_backend("paramiko+sftp", SSHParamikoBackend)

=== modified file 'duplicity/backends/ssh_pexpect_backend.py'
--- duplicity/backends/ssh_pexpect_backend.py	2016-02-18 16:45:14 +0000
+++ duplicity/backends/ssh_pexpect_backend.py	2017-02-20 00:07:15 +0000
@@ -287,6 +287,7 @@
         commandline = ("%s %s %s" % (self.sftp_command, globals.ssh_options, self.host_string))
         self.run_sftp_command(commandline, commands)
 
+
 duplicity.backend.register_backend("pexpect+sftp", SSHPExpectBackend)
 duplicity.backend.register_backend("pexpect+scp", SSHPExpectBackend)
 duplicity.backend.uses_netloc.extend(['pexpect+sftp', 'pexpect+scp'])

=== modified file 'duplicity/backends/swiftbackend.py'
--- duplicity/backends/swiftbackend.py	2016-08-12 05:24:41 +0000
+++ duplicity/backends/swiftbackend.py	2017-02-20 00:07:15 +0000
@@ -154,4 +154,5 @@
         sobject = self.conn.head_object(self.container, self.prefix + filename)
         return {'size': int(sobject['content-length'])}
 
+
 duplicity.backend.register_backend("swift", SwiftBackend)

=== modified file 'duplicity/backends/sxbackend.py'
--- duplicity/backends/sxbackend.py	2015-01-31 23:30:49 +0000
+++ duplicity/backends/sxbackend.py	2017-02-20 00:07:15 +0000
@@ -49,4 +49,5 @@
         commandline = "sxrm {0}/{1}".format(self.url_string, filename)
         self.subprocess_popen(commandline)
 
+
 duplicity.backend.register_backend("sx", SXBackend)

=== modified file 'duplicity/backends/tahoebackend.py'
--- duplicity/backends/tahoebackend.py	2015-01-31 23:30:49 +0000
+++ duplicity/backends/tahoebackend.py	2017-02-20 00:07:15 +0000
@@ -72,4 +72,5 @@
     def _delete(self, filename):
         self.run("tahoe", "rm", self.get_remote_path(filename))
 
+
 duplicity.backend.register_backend("tahoe", TAHOEBackend)

=== modified file 'duplicity/backends/webdavbackend.py'
--- duplicity/backends/webdavbackend.py	2016-06-29 22:40:59 +0000
+++ duplicity/backends/webdavbackend.py	2017-02-20 00:07:15 +0000
@@ -469,6 +469,7 @@
             if response:
                 response.close()
 
+
 duplicity.backend.register_backend("http", WebDAVBackend)
 duplicity.backend.register_backend("https", WebDAVBackend)
 duplicity.backend.register_backend("webdav", WebDAVBackend)

=== modified file 'duplicity/commandline.py'
--- duplicity/commandline.py	2017-02-11 20:46:45 +0000
+++ duplicity/commandline.py	2017-02-20 00:07:15 +0000
@@ -197,6 +197,7 @@
             optparse.Option.take_action(
                 self, action, dest, opt, value, values, parser)
 
+
 """
 Fix:
     File "/usr/lib/pythonX.X/optparse.py", line XXXX, in print_help

=== modified file 'duplicity/dup_time.py'
--- duplicity/dup_time.py	2017-01-19 00:32:12 +0000
+++ duplicity/dup_time.py	2017-02-20 00:07:15 +0000
@@ -40,6 +40,7 @@
 class TimeException(Exception):
     pass
 
+
 _interval_conv_dict = {"s": 1, "m": 60, "h": 3600, "D": 86400,
                        "W": 7 * 86400, "M": 30 * 86400, "Y": 365 * 86400}
 _integer_regexp = re.compile("^[0-9]+$")

=== modified file 'duplicity/gpginterface.py'
--- duplicity/gpginterface.py	2015-02-01 17:37:37 +0000
+++ duplicity/gpginterface.py	2017-02-20 00:07:15 +0000
@@ -707,6 +707,7 @@
     from . import gpginterface
     return doctest.testmod(GnuPGInterface)
 
+
 # deprecated
 GnuPGInterface = GnuPG
 

=== modified file 'duplicity/robust.py'
--- duplicity/robust.py	2016-06-27 21:12:18 +0000
+++ duplicity/robust.py	2017-02-20 00:07:15 +0000
@@ -64,6 +64,7 @@
     dir_listing.sort()
     return dir_listing
 
+
 from duplicity import librsync
 from duplicity import log
 from duplicity import util

=== modified file 'testing/test_code.py'
--- testing/test_code.py	2016-07-02 19:39:05 +0000
+++ testing/test_code.py	2017-02-20 00:07:15 +0000
@@ -19,11 +19,14 @@
 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 import os
-import sys
 import subprocess
-
 import unittest
 
+if os.getenv('RUN_CODE_TESTS', None) == '1':
+    # Make conditional so that we do not have to import in environments that
+    # do not run the tests (e.g. the build servers)
+    import pycodestyle
+
 from . import _top_dir, DuplicityTestCase  # @IgnorePep8
 
 
@@ -85,17 +88,14 @@
     @unittest.skipUnless(os.getenv('RUN_CODE_TESTS', None) == '1',
                          'Must set environment var RUN_CODE_TESTS=1')
     def test_pep8(self):
-        ignores = [
-            "E402",  # module level import not at top of file
-            "E731",  # do not assign a lambda expression, use a def
-        ]
-        self.run_checker(["pep8",
-                          "--ignore=" + ','.join(ignores),
-                          "--max-line-length=120",
-                          os.path.join(_top_dir, 'duplicity'),
-                          os.path.join(_top_dir, 'bin/duplicity'),
-                          os.path.join(_top_dir, 'bin/rdiffdir')])
-
+        """Test that we conform to PEP-8 using pycodestyle."""
+        # Note that the settings, ignores etc for pycodestyle are set in tox.ini, not here
+        style = pycodestyle.StyleGuide(config_file=os.path.join(_top_dir, 'tox.ini'))
+        result = style.check_files([os.path.join(_top_dir, 'duplicity'),
+                                    os.path.join(_top_dir, 'bin/duplicity'),
+                                    os.path.join(_top_dir, 'bin/rdiffdir')])
+        self.assertEqual(result.total_errors, 0,
+                         "Found %s code style errors (and warnings)." % result.total_errors)
 
 if __name__ == "__main__":
     unittest.main()

=== modified file 'tox.ini'
--- tox.ini	2017-01-15 22:08:29 +0000
+++ tox.ini	2017-02-20 00:07:15 +0000
@@ -8,6 +8,7 @@
     mock
     pexpect
     jottalib
+    pycodestyle
 
 [testenv:lpbuildd-precise]
 setenv=
@@ -20,6 +21,10 @@
 commands=
     {envpython} {toxinidir}/setup.py test {posargs}
 
-[pep8]
-ignore=E402,E731
+[pycodestyle]
+ignore=E402,E722,E731,E741
+# E402 module level import not at top of file
+# E722 do not use bare except
+# E731 do not assign a lambda expression, use a def
+# E741 ambiguous variable name
 max-line-length=120


Follow ups