Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Build-job "lint" fails with newer version of flake8-import-order #139

@AniX

Description

@AniX

In travis, the build-job of NOX_SESSION="lint" fails for the latest commit deb3444. The build-job did run successfully one year ago, see log.

I'd like to get the failures resolved first, before making any (substantial) changes to the code. I'm looking for advice.

This is the relevant snippet from the build job's log:

nox > Running session lint
nox > /home/travis/virtualenv/python2.7.14/bin/python -m virtualenv /home/travis/build/qyberion/webapp2/.nox/lint
nox > chdir /home/travis/build/qyberion/webapp2
nox > pip install --upgrade flake8 flake8-import-order
nox > flake8 --import-order-style=google webapp2.py webapp2_extras tests example
webapp2.py:45:1: I202 Additional newline in a group of imports. 'import webob' is identified as Third Party and 'from six.moves.urllib.parse import urlunsplit' is identified as Third Party.
webapp2_extras/auth.py:28:1: I202 Additional newline in a group of imports. 'from webapp2_extras import sessions' is identified as Third Party and 'import webapp2' is identified as Third Party.
webapp2_extras/i18n.py:33:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'import six' is identified as Third Party.
webapp2_extras/local.py:34:5: E722 do not use bare except'
webapp2_extras/routes.py:25:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from six.moves.urllib import parse' is identified as Third Party.
webapp2_extras/sessions.py:27:1: I202 Additional newline in a group of imports. 'from webapp2_extras import securecookie' is identified as Third Party and 'import webapp2' is identified as Third Party.
webapp2_extras/appengine/sessions_memcache.py:24:1: I202 Additional newline in a group of imports. 'from webapp2_extras import sessions' is identified as Third Party and 'from google.appengine.api import memcache' is identified as Third Party.
webapp2_extras/appengine/sessions_ndb.py:57:1: I202 Additional newline in a group of imports. 'from webapp2_extras import sessions' is identified as Third Party and 'from google.appengine.api import memcache' is identified as Third Party.
tests/extras_routes_test.py:20:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests.test_base import BaseTestCase' is identified as Third Party.
tests/extras_sessions_test.py:20:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests.test_base import BaseTestCase' is identified as Third Party.
tests/handler_test.py:25:1: I202 Additional newline in a group of imports. 'from tests.test_base import BaseTestCase' is identified as Third Party and 'from six.moves.urllib.parse import unquote_plus' is identified as Third Party.
tests/handler_test.py:27:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests.test_base import BaseTestCase' is identified as Third Party.
tests/misc_test.py:20:1: I202 Additional newline in a group of imports. 'from tests.test_base import BaseTestCase' is identified as Third Party and 'import six' is identified as Third Party.
tests/request_test.py:21:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests.test_base import BaseTestCase' is identified as Third Party.
tests/response_test.py:20:1: I202 Additional newline in a group of imports. 'from tests import test_base' is identified as Third Party and 'import six' is identified as Third Party.
tests/response_test.py:22:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests import test_base' is identified as Third Party.
tests/gae/extras_appengine_sessions_memcache_test.py:18:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests.gae import test_base' is identified as Third Party.
tests/gae/extras_appengine_sessions_ndb_test.py:18:1: I202 Additional newline in a group of imports. 'from tests.gae import test_base' is identified as Third Party and 'from google.appengine.api import memcache' is identified as Third Party.
tests/gae/extras_auth_test.py:17:1: I202 Additional newline in a group of imports. 'from tests.gae import test_base' is identified as Third Party and 'from google.appengine.ext.ndb import model' is identified as Third Party.
tests/gae/extras_auth_test.py:19:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from tests.gae import test_base' is identified as Third Party.
tests/gae/test_base.py:19:1: I202 Additional newline in a group of imports. 'from google.appengine.ext.ndb import model' is identified as Third Party and 'from google.appengine.ext import testbed' is identified as Third Party.
tests/gae/test_base.py:22:1: I202 Additional newline in a group of imports. 'import webapp2' is identified as Third Party and 'from google.appengine.ext.ndb import tasklets' is identified as Third Party.
tests/gae/webapp1_test.py:18:1: I202 Additional newline in a group of imports. 'import test_base' is identified as Third Party and 'from google.appengine.ext import webapp' is identified as Third Party.
nox > Command flake8 --import-order-style=google webapp2.py webapp2_extras tests example failed with exit code 1
nox > Session lint failed.

I believe that all errors relate to changes in more recent versions of flake8-import-order.

I202

It seems that the build-job mostly fails due to style violations detected by flake8 --import-order-style=google for a new error class "I" that has been added in newer versions of flake8-import-order:

  • I100: Your import statements are in the wrong order.
  • I101: The names in your from import are in the wrong order.
  • I201: Missing newline between import groups.
  • I202: Additional newline in a group of imports.

Error I202 occurs 22 times in the log. As far as I can see, flake8 considers webapp2 as 3rd-party library while the flagged imports are grouped as defined in the Google Python Style Guide. AFAIK the latter is the most recent and relevant style guide.

E722

Basically, there is one E722 error, do not use bare except, related to this line. Related comment warns:
# catch all, py.* fails with so many different errors.

Should the error be ignored ( # noqa: E722)? Or is it better to narrow down to except Exception?

It seems that according to Google Python Style Guide Exception would be too broad anyway.

flake8 or pylint

Google Python Style Guide also recommends to use pylint. Is using flake8 still OK?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions