Fix some flake8 errors 3.25
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 12 Apr 2017 16:14:10 +0200
branch3.25
changeset 12156 0d1d22a3a48b
parent 12155 4ba8fd2cd41a
child 12157 3d8a5119be43
Fix some flake8 errors
cubicweb/hooks/syncsources.py
cubicweb/server/sources/__init__.py
cubicweb/server/sources/native.py
cubicweb/server/test/unittest_datafeed.py
flake8-ok-files.txt
--- a/cubicweb/hooks/syncsources.py	Wed Apr 12 16:12:51 2017 +0200
+++ b/cubicweb/hooks/syncsources.py	Wed Apr 12 16:14:10 2017 +0200
@@ -19,10 +19,6 @@
 
 from cubicweb import _
 
-from socket import gethostname
-
-from logilab.common.decorators import clear_cache
-
 from cubicweb import validation_error
 from cubicweb.predicates import is_instance
 from cubicweb.server import SOURCE_TYPES, hook
@@ -39,12 +35,11 @@
                                         {}, source_entity.eid)
 
 
-# repo sources synchronization #################################################
-
 class SourceAddedHook(SourceHook):
     __regid__ = 'cw.sources.added'
     __select__ = SourceHook.__select__ & is_instance('CWSource')
     events = ('after_add_entity',)
+
     def __call__(self):
         if self.entity.type not in SOURCE_TYPES:
             msg = _('Unknown source type')
@@ -59,6 +54,7 @@
     __regid__ = 'cw.sources.removed'
     __select__ = SourceHook.__select__ & is_instance('CWSource')
     events = ('before_delete_entity',)
+
     def __call__(self):
         if self.entity.name == 'system':
             msg = _("You cannot remove the system source")
@@ -69,6 +65,7 @@
     __regid__ = 'cw.sources.configupdate'
     __select__ = SourceHook.__select__ & is_instance('CWSource')
     events = ('before_update_entity',)
+
     def __call__(self):
         if 'name' in self.entity.cw_edited:
             oldname, newname = self.entity.cw_edited.oldnewvalue('name')
--- a/cubicweb/server/sources/__init__.py	Wed Apr 12 16:12:51 2017 +0200
+++ b/cubicweb/server/sources/__init__.py	Wed Apr 12 16:14:10 2017 +0200
@@ -85,7 +85,7 @@
 
     # these are overridden by set_log_methods below
     # only defining here to prevent pylint from complaining
-    info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
+    info = warning = error = critical = exception = debug = lambda msg, *a, **kw: None
 
     def __init__(self, repo, source_config, eid=None):
         self.repo = repo
@@ -213,12 +213,13 @@
             self.urls = []
 
     PUBLIC_KEYS = ('type', 'uri', 'use-cwuri-as-url')
+
     def remove_sensitive_information(self, sourcedef):
         """remove sensitive information such as login / password from source
         definition
         """
         for key in list(sourcedef):
-            if not key in self.PUBLIC_KEYS:
+            if key not in self.PUBLIC_KEYS:
                 sourcedef.pop(key)
 
     # connections handling #####################################################
@@ -282,7 +283,7 @@
         """add a relation to the source"""
         raise NotImplementedError(self)
 
-    def add_relations(self, cnx,  rtype, subj_obj_list):
+    def add_relations(self, cnx, rtype, subj_obj_list):
         """add a relations to the source"""
         # override in derived classes if you feel you can
         # optimize
--- a/cubicweb/server/sources/native.py	Wed Apr 12 16:12:51 2017 +0200
+++ b/cubicweb/server/sources/native.py	Wed Apr 12 16:14:10 2017 +0200
@@ -229,7 +229,7 @@
                 return self._create_eid(count)
             else:
                 raise
-        except Exception: # WTF?
+        except Exception:  # WTF?
             cnx.rollback()
             self.cnx = None
             source.exception('create eid failed in an unforeseen way on SQL statement %s', sql)
@@ -704,7 +704,7 @@
                         raise UniqueTogetherError(cnx, cstrname=mo.group(0))
                     # old sqlite
                     mo = re.search('columns? (.*) (?:is|are) not unique', arg)
-                    if mo is not None: # sqlite in use
+                    if mo is not None:  # sqlite in use
                         # we left chop the 'cw_' prefix of attribute names
                         rtypes = [c.strip()[3:]
                                   for c in mo.group(1).split(',')]
@@ -1649,12 +1649,12 @@
             self.logger.critical('Restore warning: versions do not match')
             new_cubes = db_versions - archive_versions
             if new_cubes:
-                self.logger.critical('In the db:\n%s', '\n'.join('%s: %s' % (cube, ver)
-                                                            for cube, ver in sorted(new_cubes)))
+                self.logger.critical('In the db:\n%s', '\n'.join(
+                    '%s: %s' % (cube, ver) for cube, ver in sorted(new_cubes)))
             old_cubes = archive_versions - db_versions
             if old_cubes:
-                self.logger.critical('In the archive:\n%s', '\n'.join('%s: %s' % (cube, ver)
-                                                            for cube, ver in sorted(old_cubes)))
+                self.logger.critical('In the archive:\n%s', '\n'.join(
+                    '%s: %s' % (cube, ver) for cube, ver in sorted(old_cubes)))
             if not ASK.confirm('Versions mismatch: continue anyway ?', False):
                 raise ValueError('Unable to restore: versions do not match')
         table_chunks = {}
--- a/cubicweb/server/test/unittest_datafeed.py	Wed Apr 12 16:12:51 2017 +0200
+++ b/cubicweb/server/test/unittest_datafeed.py	Wed Apr 12 16:14:10 2017 +0200
@@ -178,6 +178,7 @@
         self.assertEqual({'type': u'datafeed', 'uri': u'myfeed', 'use-cwuri-as-url': False},
                          dfsource.public_config)
 
+
 if __name__ == '__main__':
     from logilab.common.testlib import unittest_main
     unittest_main()
--- a/flake8-ok-files.txt	Wed Apr 12 16:12:51 2017 +0200
+++ b/flake8-ok-files.txt	Wed Apr 12 16:14:10 2017 +0200
@@ -26,6 +26,7 @@
 cubicweb/etwist/request.py
 cubicweb/etwist/service.py
 cubicweb/ext/__init__.py
+cubicweb/hooks/syncsources.py
 cubicweb/hooks/test/data/hooks.py
 cubicweb/hooks/test/unittest_notificationhooks.py
 cubicweb/hooks/test/unittest_security.py
@@ -53,6 +54,7 @@
 cubicweb/server/test/data-migractions/migratedapp/__init__.py
 cubicweb/server/test/data-schema2sql/__init__.py
 cubicweb/server/test/unittest_checkintegrity.py
+cubicweb/server/test/unittest_datafeed.py
 cubicweb/server/test/unittest_ldapsource.py
 cubicweb/server/test/unittest_serverctl.py
 cubicweb/server/test/unittest_session.py
@@ -63,6 +65,8 @@
 cubicweb/sobjects/test/unittest_notification.py
 cubicweb/sobjects/test/unittest_register_user.py
 cubicweb/sobjects/textparsers.py
+cubicweb/sources/__init__.py
+cubicweb/sources/native.py
 cubicweb/test/data/libpython/cubicweb_comment/__init__.py
 cubicweb/test/data/libpython/cubicweb_comment/__pkginfo__.py
 cubicweb/test/data/libpython/cubicweb_email/entities.py