[PATCH] flake8 fixes

Philippe Pepiot philippe.pepiot at logilab.fr
Mon Oct 29 12:28:09 CET 2018


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1540812329 -3600
#      Mon Oct 29 12:25:29 2018 +0100
# Node ID 5f2a98b0f270d5622a4174f0f321eb32aceb72f2
# Parent  4e1b2f8215e200454f4db4fddc5f9fb2048e5638
# Available At https://hg.logilab.org/review/cubes/saem_ref
#              hg pull https://hg.logilab.org/review/cubes/saem_ref -r 5f2a98b0f270
flake8 fixes

Fix new flake8 3.6.0 checks, mostly line break after binary operator and local
variable 'exc' is assigned to but never used.

diff --git a/cubicweb_saem_ref/entities/oai.py b/cubicweb_saem_ref/entities/oai.py
--- a/cubicweb_saem_ref/entities/oai.py
+++ b/cubicweb_saem_ref/entities/oai.py
@@ -46,8 +46,8 @@ class ArkOAIPMHRecordAdapter(OAIPMHRecor
     """
 
     __abstract__ = True
-    __select__ = (OAIPMHRecordAdapter.__select__ &
-                  score_entity(lambda x: hasattr(x, 'ark')))
+    __select__ = (OAIPMHRecordAdapter.__select__
+                  & score_entity(lambda x: hasattr(x, 'ark')))
     identifier_attribute = 'ark'
 
     @property
diff --git a/cubicweb_saem_ref/entities/skos.py b/cubicweb_saem_ref/entities/skos.py
--- a/cubicweb_saem_ref/entities/skos.py
+++ b/cubicweb_saem_ref/entities/skos.py
@@ -111,8 +111,8 @@ def not_in_draft_scheme(concept):
 
 class ConceptOAIPMHRecordAdapter(oai.ArkOAIPMHRecordAdapter):
     """OAI-PMH adapter for ConceptScheme entity type."""
-    __select__ = (oai.ArkOAIPMHRecordAdapter.__select__ & is_instance('Concept') &
-                  score_entity(not_in_draft_scheme))
+    __select__ = (oai.ArkOAIPMHRecordAdapter.__select__ & is_instance('Concept')
+                  & score_entity(not_in_draft_scheme))
     metadata_formats = {'rdf': (oai.RDF_METADATAFORMAT, 'primary.rdf')}
 
     @classmethod
diff --git a/cubicweb_saem_ref/pviews.py b/cubicweb_saem_ref/pviews.py
--- a/cubicweb_saem_ref/pviews.py
+++ b/cubicweb_saem_ref/pviews.py
@@ -63,7 +63,7 @@ def eac_import(request):
         return {'error': 'Unexpected EAC data',
                 'details': err % params}
 
-    except Exception as exc:  # pylint: disable=broad-except
+    except Exception:  # pylint: disable=broad-except
         cnx.exception('error while importing EAC using web service')
         request.response.status_int = 500
         return {'error': 'EAC import failed'}
diff --git a/cubicweb_saem_ref/views/__init__.py b/cubicweb_saem_ref/views/__init__.py
--- a/cubicweb_saem_ref/views/__init__.py
+++ b/cubicweb_saem_ref/views/__init__.py
@@ -186,9 +186,9 @@ class AddEntityComponent(component.CtxCo
     """Component with 'add' link to be displayed in 'same etype' views usually 'SameETypeListView'.
     """
     __regid__ = 'saem.add_entity'
-    __select__ = (component.CtxComponent.__select__ & multi_lines_rset() & has_permission('add') &
-                  is_instance('AuthorityRecord', 'ConceptScheme',
-                              'SEDAArchiveTransfer', 'SEDAArchiveUnit'))
+    __select__ = (component.CtxComponent.__select__ & multi_lines_rset() & has_permission('add')
+                  & is_instance('AuthorityRecord', 'ConceptScheme',
+                                'SEDAArchiveTransfer', 'SEDAArchiveUnit'))
     context = 'navtop'
     extra_kwargs = {'SEDAArchiveUnit': {'unit_type': 'unit_content'}}
 
diff --git a/cubicweb_saem_ref/views/authorityrecord.py b/cubicweb_saem_ref/views/authorityrecord.py
--- a/cubicweb_saem_ref/views/authorityrecord.py
+++ b/cubicweb_saem_ref/views/authorityrecord.py
@@ -106,8 +106,8 @@ class EquivalentConceptOrTextField(ff.Fi
         if not entity.has_eid() or getattr(entity, self.name) != text_val:
             yield (ff.Field(name=self.name, role='subject', eidparam=True), text_val)
         if (not entity.has_eid() and equivalent_eids) \
-           or (entity.has_eid() and
-               set(x.eid for x in entity.equivalent_concept) != equivalent_eids):
+           or (entity.has_eid()
+               and set(x.eid for x in entity.equivalent_concept) != equivalent_eids):
             subfield = ff.Field(name='equivalent_concept', role='subject', eidparam=True)
             # register the association between the value and the field, because on entity creation,
             # process_posted will be recalled on the newly created field, and if we don't do that it
@@ -193,8 +193,8 @@ class CitationLinkView(EntityView):
                 xml_escape(entity.uri), xml_escape(desc),
                 xml_escape(title)))
         else:
-            title = (entity.note or
-                     u'{0} #{1}'.format(self._cw._('Citation'), entity.eid))
+            title = (entity.note
+                     or u'{0} #{1}'.format(self._cw._('Citation'), entity.eid))
             self.w(u'<i class="truncate">%s</i>' % title)
 
 
@@ -667,8 +667,8 @@ class AuthorityRecordAssociationRelation
     """
     __regid__ = 'saem.authorityrecord.association_relations'
     __select__ = EntityView.__select__ & (
-        has_related_entities('association_from', role='object') |
-        has_related_entities('association_to', role='object'))
+        has_related_entities('association_from', role='object')
+        | has_related_entities('association_to', role='object'))
 
     def entity_call(self, entity, **kwargs):
         self.w(tags.h2(self._cw._('associated with')))
@@ -711,8 +711,8 @@ class ChronologicalRelationView(EntityVi
     """
     __regid__ = 'saem.authorityrecord.chronological_relation'
     __select__ = EntityView.__select__ & (
-        has_related_entities('chronological_successor', role='object') |
-        has_related_entities('chronological_predecessor', role='object'))
+        has_related_entities('chronological_successor', role='object')
+        | has_related_entities('chronological_predecessor', role='object'))
     title = _('ChronologicalRelation_plural')
 
     def entity_call(self, entity, **kwargs):
@@ -798,8 +798,8 @@ def _node(entity):
 
 class AuthorityRecordGraphView(EntityView):
     __select__ = EntityView.__select__ & (
-        has_related_entities('hierarchical_parent', role='object') |
-        has_related_entities('hierarchical_child', role='object'))
+        has_related_entities('hierarchical_parent', role='object')
+        | has_related_entities('hierarchical_child', role='object'))
 
     __regid__ = 'saem.authorityrecord.hierarchical-links'
     title = _('HierarchicalRelation_plural')
diff --git a/cubicweb_saem_ref/views/clone.py b/cubicweb_saem_ref/views/clone.py
--- a/cubicweb_saem_ref/views/clone.py
+++ b/cubicweb_saem_ref/views/clone.py
@@ -52,9 +52,9 @@ def workflow_state(entity):
 class SEDAArchiveTransferRelatedVersionsComponent(component.EntityCtxComponent):
     """Output a box containing relevant SEDA Profiles related to the current one."""
     __regid__ = 'saem.seda.relatedprofiles'
-    __select__ = (component.EntityCtxComponent.__select__ &
-                  (has_related_entities('new_version_of', role='subject') |
-                   has_related_entities('new_version_of', role='object')))
+    __select__ = (component.EntityCtxComponent.__select__
+                  & (has_related_entities('new_version_of', role='subject')
+                     | has_related_entities('new_version_of', role='object')))
     context = 'incontext'
     order = 11
     title = _('Related versions')
@@ -62,8 +62,8 @@ class SEDAArchiveTransferRelatedVersions
     def predecessor(self):
         """Yield the profile of which the displayed profile is a new version (draft or published).
         """
-        if (workflow_state(self.entity) in (u'published', u'draft') and
-                self.entity.predecessor):
+        if (workflow_state(self.entity) in (u'published', u'draft')
+                and self.entity.predecessor):
             yield self.entity.predecessor
 
     def current_version(self, state):
diff --git a/cubicweb_saem_ref/views/management.py b/cubicweb_saem_ref/views/management.py
--- a/cubicweb_saem_ref/views/management.py
+++ b/cubicweb_saem_ref/views/management.py
@@ -36,8 +36,8 @@ affk.set_field_kwargs('ArkNameAssigningA
 
 
 class ManagementAddEntityComponent(AddEntityComponent):
-    __select__ = (component.CtxComponent.__select__ & has_permission('add') &
-                  is_instance('Organization', 'ArkNameAssigningAuthority'))
+    __select__ = (component.CtxComponent.__select__ & has_permission('add')
+                  & is_instance('Organization', 'ArkNameAssigningAuthority'))
 
 
 class ARKNamingAutorithyAction(actions.ManagersAction):



More information about the saem-devel mailing list