Fix broken flake8 configuration
and flake8 errors which were hidden by this breakage.
flake8 --filename options doesn't work as expected:
* it's expected to be a shell pattern, using stdlib's fnmatch.fnmatch function
internally. This funciton thinks that 'cubicweb/x.py' doesn't match 'cubicweb/x.py'
(there must be a reason but that's not the point), hence no file was actually
checked ;
* as this is a list of pattern, each encountered file is checked against each
pattern, leading to run time explosion.
So maintain list of files to check in a separated file and give this list to
flake8 using unix's xarg command.
--- a/MANIFEST.in Tue Jun 30 10:00:53 2015 +0200
+++ b/MANIFEST.in Wed Nov 09 11:42:33 2016 +0100
@@ -5,6 +5,8 @@
include pylintrc
include jshintrc
include tox.ini
+include flake8-ok-files.txt
+
include bin/cubicweb-*
include man/cubicweb-ctl.1
--- a/cubicweb/__init__.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/__init__.py Wed Nov 09 11:42:33 2016 +0100
@@ -29,24 +29,27 @@
import warnings
import zlib
-warnings.filterwarnings('ignore', category=UserWarning,
- message='.*was already imported',
- module='.*pygments')
-
-
from six import PY2, binary_type, text_type
from six.moves import builtins
+from logilab.common.deprecation import deprecated
+from logilab.common.logging_ext import set_log_methods
+from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS
+from yams.schema import role_name as rname
+
+from cubicweb.__pkginfo__ import version as __version__ # noqa
+
+# make all exceptions accessible from the package
+from logilab.common.registry import ObjectNotFound, NoSelectableObject, RegistryNotFound # noqa
+from yams import ValidationError
+from cubicweb._exceptions import * # noqa
+
if PY2:
# http://bugs.python.org/issue10211
from StringIO import StringIO as BytesIO
else:
from io import BytesIO
-from logilab.common.deprecation import deprecated
-from logilab.common.logging_ext import set_log_methods
-from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS
-
# ignore the pygments UserWarnings
warnings.filterwarnings('ignore', category=UserWarning,
message='.*was already imported',
@@ -54,21 +57,12 @@
# pre python 2.7.2 safety
logging.basicConfig()
+set_log_methods(sys.modules[__name__], logging.getLogger('cubicweb'))
# this is necessary for i18n devtools test where chdir is done while __path__ is relative, which
# breaks later imports
-__path__[0] = os.path.abspath(__path__[0])
-CW_SOFTWARE_ROOT = __path__[0]
-
-
-from cubicweb.__pkginfo__ import version as __version__ # noqa
-
-
-set_log_methods(sys.modules[__name__], logging.getLogger('cubicweb'))
-
-# make all exceptions accessible from the package
-from cubicweb._exceptions import * # noqa
-from logilab.common.registry import ObjectNotFound, NoSelectableObject, RegistryNotFound # noqa
+__path__[0] = os.path.abspath(__path__[0]) # noqa
+CW_SOFTWARE_ROOT = __path__[0] # noqa
# '_' is available to mark internationalized string but should not be used to
@@ -249,9 +243,6 @@
return _decorator
-from yams.schema import role_name as rname
-
-
def validation_error(entity, errors, substitutions=None, i18nvalues=None):
"""easy way to retrieve a :class:`cubicweb.ValidationError` for an entity or eid.
--- a/cubicweb/dataimport/stores.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/dataimport/stores.py Wed Nov 09 11:42:33 2016 +0100
@@ -63,7 +63,7 @@
from copy import copy
from itertools import count
-from six import text_type, add_metaclass
+from six import add_metaclass
import pytz
--- a/cubicweb/devtools/testlib.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/devtools/testlib.py Wed Nov 09 11:42:33 2016 +0100
@@ -28,7 +28,6 @@
from inspect import isgeneratorfunction
from itertools import chain
from warnings import warn
-import tempfile
from six import text_type, string_types, reraise
from six.moves import range
@@ -45,7 +44,7 @@
from cubicweb import (ValidationError, NoSelectableObject, AuthenticationError,
BadConnectionId)
-from cubicweb import cwconfig, devtools, web, server, repoapi
+from cubicweb import cwconfig, devtools, web, server
from cubicweb.utils import json
from cubicweb.sobjects import notification
from cubicweb.web import Redirect, application, eid_param
@@ -53,6 +52,7 @@
from cubicweb.server.session import Session
from cubicweb.devtools import SYSTEM_ENTITIES, SYSTEM_RELATIONS, VIEW_VALIDATORS
from cubicweb.devtools import fake, htmlparser, DEFAULT_EMPTY_DB_ID
+from cubicweb.devtools.fill import insert_entity_queries, make_relations_queries
if sys.version_info[:2] < (3, 4):
@@ -852,7 +852,9 @@
path = location
params = {}
else:
- cleanup = lambda p: (p[0], urlunquote(p[1]))
+ def cleanup(p):
+ return (p[0], urlunquote(p[1]))
+
params = dict(cleanup(p.split('=', 1)) for p in params.split('&') if p)
if path.startswith(req.base_url()): # may be relative
path = path[len(req.base_url()):]
@@ -968,8 +970,11 @@
viewfunc = view.render
else:
kwargs['view'] = view
- viewfunc = lambda **k: viewsreg.main_template(req, template,
- rset=rset, **kwargs)
+
+ def viewfunc(**k):
+ return viewsreg.main_template(req, template,
+ rset=rset, **kwargs)
+
return self._test_view(viewfunc, view, template, kwargs)
def _test_view(self, viewfunc, view, template='main-template', kwargs={}):
@@ -1105,11 +1110,8 @@
# auto-populating test classes and utilities ###################################
-from cubicweb.devtools.fill import insert_entity_queries, make_relations_queries
-
# XXX cleanup unprotected_entities & all mess
-
def how_many_dict(schema, cnx, how_many, skip):
"""given a schema, compute how many entities by type we need to be able to
satisfy relations cardinality.
--- a/cubicweb/pyramid/__init__.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/__init__.py Wed Nov 09 11:42:33 2016 +0100
@@ -28,6 +28,7 @@
config.include('cubicweb.pyramid')
return config
+
def settings_from_cwconfig(cwconfig):
'''
Extract settings from pyramid.ini and pyramid-debug.ini (if in debug)
@@ -42,21 +43,21 @@
if cwconfig.debugmode:
settings_filenames.insert(
0, os.path.join(cwconfig.apphome, 'pyramid-debug.ini'))
-
+
settings.update({
'pyramid.debug_authorization': True,
'pyramid.debug_notfound': True,
'pyramid.debug_routematch': True,
'pyramid.reload_templates': True,
})
-
+
for fname in settings_filenames:
if os.path.exists(fname):
cp = SafeConfigParser()
cp.read(fname)
settings.update(cp.items('main'))
break
-
+
return settings
--- a/cubicweb/pyramid/auth.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/auth.py Wed Nov 09 11:42:33 2016 +0100
@@ -159,8 +159,8 @@
defaults={
'hashalg': 'sha512',
'cookie_name': 'pauth_tkt',
- 'max_age': 3600*24*30,
- 'reissue_time': 3600*24,
+ 'max_age': 3600 * 24 * 30,
+ 'reissue_time': 3600 * 24,
'http_only': True,
'secure': True
},
--- a/cubicweb/pyramid/bwcompat.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/bwcompat.py Wed Nov 09 11:42:33 2016 +0100
@@ -103,7 +103,6 @@
if content is not None:
request.response.body = content
-
except LogOut as ex:
# The actual 'logging out' logic should be in separated function
# that is accessible by the pyramid views
--- a/cubicweb/pyramid/core.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/core.py Wed Nov 09 11:42:33 2016 +0100
@@ -7,7 +7,6 @@
import rql
from cubicweb.web.request import CubicWebRequestBase
-from cubicweb import repoapi
import cubicweb
import cubicweb.web
@@ -29,6 +28,7 @@
This behavior makes sure the actual session data is not loaded until
actually accessed.
"""
+
def __init__(self, session, *args, **kw):
super(Connection, self).__init__(session, *args, **kw)
self._session = session
@@ -277,9 +277,9 @@
tools.cnx_attach_entity(session, user)
# Calling the hooks should be done only once, disabling it completely for
# now
- #with session.new_cnx() as cnx:
- #repo.hm.call_hooks('session_open', cnx)
- #cnx.commit()
+ # with session.new_cnx() as cnx:
+ # repo.hm.call_hooks('session_open', cnx)
+ # cnx.commit()
# repo._sessions[session.sessionid] = session
return session
--- a/cubicweb/pyramid/rest_api.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/rest_api.py Wed Nov 09 11:42:33 2016 +0100
@@ -1,10 +1,8 @@
from __future__ import absolute_import
-from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config
from cubicweb.pyramid.resources import EntityResource, ETypeResource
-from cubicweb.pyramid.predicates import MatchIsETypePredicate
@view_config(
--- a/cubicweb/pyramid/test/test_bw_request.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/test/test_bw_request.py Wed Nov 09 11:42:33 2016 +0100
@@ -52,7 +52,7 @@
self.assertIn('https://', r.text)
def test_big_content(self):
- content = b'x'*100001
+ content = b'x' * 100001
req = CubicWebPyramidRequest(
self.make_request('/', {
--- a/cubicweb/pyramid/tools.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/pyramid/tools.py Wed Nov 09 11:42:33 2016 +0100
@@ -72,5 +72,5 @@
"""
repo = config.registry['cubicweb.repository']
interval = int(config.registry.settings.get(
- 'cubicweb.usercache.expiration_time', 60*5))
+ 'cubicweb.usercache.expiration_time', 60 * 5))
repo.looping_task(interval, clear_cache)
--- a/cubicweb/server/repository.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/server/repository.py Wed Nov 09 11:42:33 2016 +0100
@@ -32,6 +32,7 @@
from itertools import chain
from time import time, localtime, strftime
from contextlib import contextmanager
+from logging import getLogger
from six.moves import range, queue
@@ -45,6 +46,7 @@
UnknownEid, AuthenticationError, ExecutionError,
BadConnectionId, ValidationError, Unauthorized,
UniqueTogetherError, onevent, ViolatedConstraint)
+from cubicweb import set_log_methods
from cubicweb import cwvreg, schema, server
from cubicweb.server import ShuttingDown, utils, hook, querier, sources
from cubicweb.server.session import Session, InternalManager
@@ -1032,7 +1034,4 @@
# only defining here to prevent pylint from complaining
info = warning = error = critical = exception = debug = lambda msg, *a, **kw: None
-
-from logging import getLogger
-from cubicweb import set_log_methods
set_log_methods(Repository, getLogger('cubicweb.repository'))
--- a/cubicweb/server/schema2sql.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/server/schema2sql.py Wed Nov 09 11:42:33 2016 +0100
@@ -17,8 +17,6 @@
# with yams. If not, see <http://www.gnu.org/licenses/>.
"""write a schema as sql"""
-
-
from hashlib import md5
from six import string_types, text_type
--- a/cubicweb/server/sqlutils.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/server/sqlutils.py Wed Nov 09 11:42:33 2016 +0100
@@ -16,10 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""SQL utilities functions and classes."""
+
from __future__ import print_function
-
-
import sys
import re
import subprocess
--- a/cubicweb/sobjects/textparsers.py Tue Jun 30 10:00:53 2015 +0200
+++ b/cubicweb/sobjects/textparsers.py Wed Nov 09 11:42:33 2016 +0100
@@ -22,8 +22,6 @@
will provide the text to analyze...
"""
-
-
import re
from cubicweb import UnknownEid
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flake8-ok-files.txt Wed Nov 09 11:42:33 2016 +0100
@@ -0,0 +1,105 @@
+cubicweb/dataimport/csv.py
+cubicweb/dataimport/importer.py
+cubicweb/dataimport/massive_store.py
+cubicweb/dataimport/stores.py
+cubicweb/dataimport/test/data-massimport/schema.py
+cubicweb/dataimport/test/data/schema.py
+cubicweb/dataimport/test/test_csv.py
+cubicweb/dataimport/test/test_pgstore.py
+cubicweb/dataimport/test/test_massive_store.py
+cubicweb/dataimport/test/test_stores.py
+cubicweb/dataimport/test/unittest_importer.py
+cubicweb/devtools/test/data/cubes/i18ntestcube/__init__.py
+cubicweb/devtools/test/data/cubes/__init__.py
+cubicweb/devtools/test/data/schema.py
+cubicweb/devtools/testlib.py
+cubicweb/devtools/test/unittest_devctl.py
+cubicweb/devtools/test/unittest_i18n.py
+cubicweb/devtools/test/unittest_webtest.py
+cubicweb/devtools/webtest.py
+cubicweb/entities/adapters.py
+cubicweb/entities/test/unittest_base.py
+cubicweb/etwist/__init__.py
+cubicweb/ext/__init__.py
+cubicweb/hooks/test/data/hooks.py
+cubicweb/hooks/test/unittest_notification.py
+cubicweb/hooks/test/unittest_security.py
+cubicweb/hooks/test/unittest_syncsession.py
+cubicweb/__init__.py
+cubicweb/__main__.py
+cubicweb/pylintext.py
+cubicweb/server/repository.py
+cubicweb/server/rqlannotation.py
+cubicweb/server/schema2sql.py
+cubicweb/server/session.py
+cubicweb/server/sqlutils.py
+cubicweb/server/test/datacomputed/migratedapp/schema.py
+cubicweb/server/test/datacomputed/schema.py
+cubicweb/server/test/data/entities.py
+cubicweb/server/test/data-migractions/cubes/fakecustomtype/__init__.py
+cubicweb/server/test/data-migractions/cubes/fakeemail/__init__.py
+cubicweb/server/test/data-migractions/cubes/__init__.py
+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_ldapsource.py
+cubicweb/skeleton/test/pytestconf.py
+cubicweb/sobjects/test/unittest_notification.py
+cubicweb/sobjects/test/unittest_register_user.py
+cubicweb/sobjects/textparsers.py
+cubicweb/test/data/cubes/comment/__init__.py
+cubicweb/test/data/cubes/comment/__pkginfo__.py
+cubicweb/test/data/cubes/email/entities.py
+cubicweb/test/data/cubes/email/hooks.py
+cubicweb/test/data/cubes/email/__init__.py
+cubicweb/test/data/cubes/email/__pkginfo__.py
+cubicweb/test/data/cubes/email/views/__init__.py
+cubicweb/test/data/cubes/file/entities/__init__.py
+cubicweb/test/data/cubes/file/hooks/__init__.py
+cubicweb/test/data/cubes/file/__init__.py
+cubicweb/test/data/cubes/file/__pkginfo__.py
+cubicweb/test/data/cubes/file/views.py
+cubicweb/test/data/cubes/forge/__init__.py
+cubicweb/test/data/cubes/forge/__pkginfo__.py
+cubicweb/test/data/cubes/mycube/__init__.py
+cubicweb/test/data/cubes/mycube/__pkginfo__.py
+cubicweb/test/data/migration/0.1.0_common.py
+cubicweb/test/data/migration/0.1.0_repository.py
+cubicweb/test/data_schemareader/schema.py
+cubicweb/test/data/server_migration/bootstrapmigration_repository.py
+cubicweb/test/data/views.py
+cubicweb/test/unittest_binary.py
+cubicweb/test/unittest_mail.py
+cubicweb/test/unittest_repoapi.py
+cubicweb/test/unittest_schema.py
+cubicweb/test/unittest_toolsutils.py
+cubicweb/test/unittest_utils.py
+cubicweb/web/formwidgets.py
+cubicweb/web/test/data/entities.py
+cubicweb/web/test/unittest_http_headers.py
+cubicweb/web/test/unittest_views_basetemplates.py
+cubicweb/web/test/unittest_views_cwsources.py
+cubicweb/web/test/unittest_views_json.py
+cubicweb/web/views/json.py
+cubicweb/web/views/searchrestriction.py
+cubicweb/xy.py
+cubicweb/pyramid/auth.py
+cubicweb/pyramid/bwcompat.py
+cubicweb/pyramid/core.py
+cubicweb/pyramid/defaults.py
+cubicweb/pyramid/init_instance.py
+cubicweb/pyramid/__init__.py
+cubicweb/pyramid/login.py
+cubicweb/pyramid/predicates.py
+cubicweb/pyramid/profile.py
+cubicweb/pyramid/resources.py
+cubicweb/pyramid/rest_api.py
+cubicweb/pyramid/session.py
+cubicweb/pyramid/tools.py
+cubicweb/pyramid/test/__init__.py
+cubicweb/pyramid/test/test_bw_request.py
+cubicweb/pyramid/test/test_core.py
+cubicweb/pyramid/test/test_login.py
+cubicweb/pyramid/test/test_rest_api.py
+cubicweb/pyramid/test/test_tools.py
+cubicweb/pyramid/pyramidctl.py
--- a/tox.ini Tue Jun 30 10:00:53 2015 +0200
+++ b/tox.ini Wed Nov 09 11:42:33 2016 +0100
@@ -25,8 +25,9 @@
skip_install = true
deps =
flake8 >= 3
-commands =
- flake8 {toxinidir}
+whitelist_externals =
+ /bin/sh
+commands = /bin/sh -c "flake8 `xargs -a {toxinidir}/flake8-ok-files.txt`"
[testenv:doc]
changedir = doc
@@ -53,112 +54,6 @@
ignore = W503
max-line-length = 100
exclude = setup.py,doc/*,cubicweb/misc/*,cubicweb/test/*,cubicweb/*/test/*,.tox/*
-filename=
- cubicweb/dataimport/csv.py,
- cubicweb/dataimport/importer.py,
- cubicweb/dataimport/massive_store.py,
- cubicweb/dataimport/stores.py,
- cubicweb/dataimport/test/data-massimport/schema.py,
- cubicweb/dataimport/test/data/schema.py,
- cubicweb/dataimport/test/test_csv.py,
- cubicweb/dataimport/test/test_pgstore.py,
- cubicweb/dataimport/test/test_massive_store.py,
- cubicweb/dataimport/test/test_stores.py,
- cubicweb/dataimport/test/unittest_importer.py,
- cubicweb/devtools/test/data/cubes/i18ntestcube/__init__.py,
- cubicweb/devtools/test/data/cubes/__init__.py,
- cubicweb/devtools/test/data/schema.py,
- cubicweb/devtools/testlib.py,
- cubicweb/devtools/test/unittest_devctl.py,
- cubicweb/devtools/test/unittest_i18n.py,
- cubicweb/devtools/test/unittest_webtest.py,
- cubicweb/devtools/webtest.py,
- cubicweb/entities/adapters.py,
- cubicweb/entities/test/unittest_base.py,
- cubicweb/etwist/__init__.py,
- cubicweb/ext/__init__.py,
- cubicweb/hooks/test/data/hooks.py,
- cubicweb/hooks/test/unittest_notification.py,
- cubicweb/hooks/test/unittest_security.py,
- cubicweb/hooks/test/unittest_syncsession.py,
- cubicweb/__init__.py,
- cubicweb/__main__.py,
- cubicweb/pylintext.py,
- cubicweb/server/repository.py,
- cubicweb/server/rqlannotation.py,
- cubicweb/server/schema2sql.py,
- cubicweb/server/session.py,
- cubicweb/server/sqlutils.py,
- cubicweb/server/test/datacomputed/migratedapp/schema.py,
- cubicweb/server/test/datacomputed/schema.py,
- cubicweb/server/test/data/entities.py,
- cubicweb/server/test/data-migractions/cubes/fakecustomtype/__init__.py,
- cubicweb/server/test/data-migractions/cubes/fakeemail/__init__.py,
- cubicweb/server/test/data-migractions/cubes/__init__.py,
- 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_ldapsource.py,
- cubicweb/skeleton/test/pytestconf.py,
- cubicweb/sobjects/test/unittest_notification.py,
- cubicweb/sobjects/test/unittest_register_user.py,
- cubicweb/sobjects/textparsers.py,
- cubicweb/test/data/cubes/comment/__init__.py,
- cubicweb/test/data/cubes/comment/__pkginfo__.py,
- cubicweb/test/data/cubes/email/entities.py,
- cubicweb/test/data/cubes/email/hooks.py,
- cubicweb/test/data/cubes/email/__init__.py,
- cubicweb/test/data/cubes/email/__pkginfo__.py,
- cubicweb/test/data/cubes/email/views/__init__.py,
- cubicweb/test/data/cubes/file/entities/__init__.py,
- cubicweb/test/data/cubes/file/hooks/__init__.py,
- cubicweb/test/data/cubes/file/__init__.py,
- cubicweb/test/data/cubes/file/__pkginfo__.py,
- cubicweb/test/data/cubes/file/views.py,
- cubicweb/test/data/cubes/forge/__init__.py,
- cubicweb/test/data/cubes/forge/__pkginfo__.py,
- cubicweb/test/data/cubes/mycube/__init__.py,
- cubicweb/test/data/cubes/mycube/__pkginfo__.py,
- cubicweb/test/data/migration/0.1.0_common.py,
- cubicweb/test/data/migration/0.1.0_repository.py,
- cubicweb/test/data_schemareader/schema.py,
- cubicweb/test/data/server_migration/bootstrapmigration_repository.py,
- cubicweb/test/data/views.py,
- cubicweb/test/unittest_binary.py,
- cubicweb/test/unittest_mail.py,
- cubicweb/test/unittest_repoapi.py,
- cubicweb/test/unittest_schema.py,
- cubicweb/test/unittest_toolsutils.py,
- cubicweb/test/unittest_utils.py,
- cubicweb/web/formwidgets.py,
- cubicweb/web/test/data/entities.py,
- cubicweb/web/test/unittest_http_headers.py,
- cubicweb/web/test/unittest_views_basetemplates.py,
- cubicweb/web/test/unittest_views_cwsources.py,
- cubicweb/web/test/unittest_views_json.py,
- cubicweb/web/views/json.py,
- cubicweb/web/views/searchrestriction.py,
- cubicweb/xy.py,
- cubicweb/pyramid/auth.py,
- cubicweb/pyramid/bwcompat.py,
- cubicweb/pyramid/core.py,
- cubicweb/pyramid/defaults.py,
- cubicweb/pyramid/init_instance.py,
- cubicweb/pyramid/__init__.py,
- cubicweb/pyramid/login.py,
- cubicweb/pyramid/predicates.py,
- cubicweb/pyramid/profile.py,
- cubicweb/pyramid/resources.py,
- cubicweb/pyramid/rest_api.py,
- cubicweb/pyramid/session.py,
- cubicweb/pyramid/tools.py,
- cubicweb/pyramid/test/__init__.py,
- cubicweb/pyramid/test/test_bw_request.py,
- cubicweb/pyramid/test/test_core.py,
- cubicweb/pyramid/test/test_login.py,
- cubicweb/pyramid/test/test_rest_api.py,
- cubicweb/pyramid/test/test_tools.py,
- cubicweb/pyramid/pyramidctl.py,
# vim: wrap sts=2 sw=2