diff --git a/.flake8 b/.flake8 index dafe88a..609b6f1 100644 --- a/.flake8 +++ b/.flake8 @@ -31,3 +31,11 @@ ignore = W504 # allow assigning lambdas (it's useful for single-line functions defined inside other functions) E731 + # while single quotes are nicer, we have double quotes in way too many places + Q000 + # for non-docstring multiline strings we don't really enforce a quote style + Q001 + +per-file-ignores = + # allow nicely aligned parametrizations + **/*_test.py:E241 diff --git a/livesync/indico_livesync/__init__.py b/livesync/indico_livesync/__init__.py index cfe9e71..cb433a7 100644 --- a/livesync/indico_livesync/__init__.py +++ b/livesync/indico_livesync/__init__.py @@ -13,13 +13,13 @@ _ = make_bound_gettext('livesync') __all__ = ('LiveSyncPluginBase', 'LiveSyncBackendBase', 'AgentForm', 'SimpleChange', 'process_records', 'MARCXMLGenerator', 'Uploader', 'MARCXMLUploader') -from .base import LiveSyncPluginBase, LiveSyncBackendBase # isort:skip -from .forms import AgentForm # isort:skip -from .simplify import SimpleChange, process_records # isort:skip -from .marcxml import MARCXMLGenerator # isort:skip -from .uploader import Uploader, MARCXMLUploader # isort:skip +from .base import LiveSyncBackendBase, LiveSyncPluginBase # noqa:E402 +from .forms import AgentForm # noqa:E402 +from .marcxml import MARCXMLGenerator # noqa:E402 +from .simplify import SimpleChange, process_records # noqa:E402 +from .uploader import MARCXMLUploader, Uploader # noqa:E402 @signals.import_tasks.connect def _import_tasks(sender, **kwargs): - import indico_livesync.task + import indico_livesync.task # noqa: F401 diff --git a/livesync/indico_livesync/cli.py b/livesync/indico_livesync/cli.py index ab1ef93..392e972 100644 --- a/livesync/indico_livesync/cli.py +++ b/livesync/indico_livesync/cli.py @@ -103,6 +103,6 @@ def run(agent_id, force=False): try: agent.create_backend().run() db.session.commit() - except: + except Exception: db.session.rollback() raise diff --git a/piwik/indico_piwik/queries/base.py b/piwik/indico_piwik/queries/base.py index 7bab12a..6cda137 100644 --- a/piwik/indico_piwik/queries/base.py +++ b/piwik/indico_piwik/queries/base.py @@ -47,8 +47,7 @@ class PiwikQueryReportEventBase(PiwikQueryReportBase): def call(self, segmentation_enabled=True, **query_params): if segmentation_enabled: query_params['segment'] = self.get_segmentation() - return super().call(module='API', date=[self.start_date, self.end_date], - **query_params) + return super().call(module='API', date=[self.start_date, self.end_date], **query_params) def get_segmentation(self): segmentation = {'customVariablePageName1': ('==', 'Conference'), diff --git a/piwik/indico_piwik/queries/graphs.py b/piwik/indico_piwik/queries/graphs.py index 2622d73..ded6750 100644 --- a/piwik/indico_piwik/queries/graphs.py +++ b/piwik/indico_piwik/queries/graphs.py @@ -20,9 +20,8 @@ class PiwikQueryReportEventGraphBase(PiwikQueryReportEventBase): query_params['height'] = height if width is not None: query_params['width'] = width - return super().call(method='ImageGraph.get', - apiModule=apiModule, apiAction=apiAction, - aliasedGraph='1', graphType=graphType, **query_params) + return super().call(method='ImageGraph.get', apiModule=apiModule, apiAction=apiAction, aliasedGraph='1', + graphType=graphType, **query_params) def get_result(self): """Perform the call and return the graph data @@ -41,13 +40,11 @@ class PiwikQueryReportEventGraphBase(PiwikQueryReportEventBase): class PiwikQueryReportEventGraphCountries(PiwikQueryReportEventGraphBase): def call(self, **query_params): - return super().call(apiModule='UserCountry', apiAction='getCountry', - period='range', width=490, height=260, - graphType='horizontalBar', **query_params) + return super().call(apiModule='UserCountry', apiAction='getCountry', period='range', width=490, height=260, + graphType='horizontalBar', **query_params) class PiwikQueryReportEventGraphDevices(PiwikQueryReportEventGraphBase): def call(self, **query_params): - return super().call(apiModule='UserSettings', apiAction='getOS', - period='range', width=320, height=260, - graphType='horizontalBar', **query_params) + return super().call(apiModule='UserSettings', apiAction='getOS', period='range', width=320, height=260, + graphType='horizontalBar', **query_params) diff --git a/piwik/indico_piwik/queries/metrics.py b/piwik/indico_piwik/queries/metrics.py index 2492e7d..15238cf 100644 --- a/piwik/indico_piwik/queries/metrics.py +++ b/piwik/indico_piwik/queries/metrics.py @@ -69,8 +69,7 @@ class PiwikQueryReportEventMetricDownloads(PiwikQueryReportEventMetricBase): class PiwikQueryReportEventMetricReferrers(PiwikQueryReportEventMetricBase): def call(self, **query_params): - return super().call(method='Referrers.getReferrerType', - period='range', **query_params) + return super().call(method='Referrers.getReferrerType', period='range', **query_params) def get_result(self): """Perform the call and return a list of referrers""" @@ -83,8 +82,7 @@ class PiwikQueryReportEventMetricReferrers(PiwikQueryReportEventMetricBase): class PiwikQueryReportEventMetricUniqueVisits(PiwikQueryReportEventMetricVisitsBase): def call(self, **query_params): - return super().call(method='VisitsSummary.getUniqueVisitors', - **query_params) + return super().call(method='VisitsSummary.getUniqueVisitors', **query_params) class PiwikQueryReportEventMetricVisits(PiwikQueryReportEventMetricVisitsBase): @@ -115,8 +113,7 @@ class PiwikQueryReportEventMetricVisitDuration(PiwikQueryReportEventMetricBase): class PiwikQueryReportEventMetricPeakDateAndVisitors(PiwikQueryReportEventMetricBase): def call(self, **query_params): - return super().call(method='VisitsSummary.getVisits', - **query_params) + return super().call(method='VisitsSummary.getVisits', **query_params) def get_result(self): """Perform the call and return the peak date and how many users""" diff --git a/previewer_jupyter/indico_previewer_jupyter/cpp_highlighter.py b/previewer_jupyter/indico_previewer_jupyter/cpp_highlighter.py index b2f7283..2cdc0d3 100644 --- a/previewer_jupyter/indico_previewer_jupyter/cpp_highlighter.py +++ b/previewer_jupyter/indico_previewer_jupyter/cpp_highlighter.py @@ -59,7 +59,7 @@ class CppHighlighter(Preprocessor): try: if nb.metadata.kernelspec.language == "c++": self.preprocess_cell = self._preprocess_cell_cpp - except: + except Exception: # if no language metadata, keep python as default pass return super().preprocess(nb, resources) diff --git a/storage_s3/indico_storage_s3/__init__.py b/storage_s3/indico_storage_s3/__init__.py index a351ad3..08f6885 100644 --- a/storage_s3/indico_storage_s3/__init__.py +++ b/storage_s3/indico_storage_s3/__init__.py @@ -14,4 +14,4 @@ _ = make_bound_gettext('storage_s3') @signals.import_tasks.connect def _import_tasks(sender, **kwargs): - import indico_storage_s3.task + import indico_storage_s3.task # noqa: F401 diff --git a/update-meta.py b/update-meta.py index 8e160a8..2a68a59 100644 --- a/update-meta.py +++ b/update-meta.py @@ -23,7 +23,7 @@ END_MARKER = '# END GENERATED REQUIREMENTS' def _find_plugins(): subdirs = sorted(x for x in os.walk('.').next()[1] - if x[0] != '.' and x != '_meta' and os.path.exists(os.path.join(x, 'setup.py'))) + if x[0] != '.' and x != '_meta' and os.path.exists(os.path.join(x, 'setup.py'))) for subdir in subdirs: path = os.path.join(subdir, 'setup.py') with open(path) as f: diff --git a/vc_vidyo/indico_vc_vidyo/__init__.py b/vc_vidyo/indico_vc_vidyo/__init__.py index 133d253..d6149b0 100644 --- a/vc_vidyo/indico_vc_vidyo/__init__.py +++ b/vc_vidyo/indico_vc_vidyo/__init__.py @@ -14,4 +14,4 @@ _ = make_bound_gettext('vc_vidyo') @signals.import_tasks.connect def _import_tasks(sender, **kwargs): - import indico_vc_vidyo.task + import indico_vc_vidyo.task # noqa: F401 diff --git a/vc_vidyo/indico_vc_vidyo/util.py b/vc_vidyo/indico_vc_vidyo/util.py index b404444..330fbae 100644 --- a/vc_vidyo/indico_vc_vidyo/util.py +++ b/vc_vidyo/indico_vc_vidyo/util.py @@ -10,7 +10,6 @@ import re from flask_multipass import IdentityRetrievalFailed from indico.core.auth import multipass -from indico.core.db import db from indico.modules.auth import Identity from indico.modules.users import User