Skip to content
This repository has been 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

Open
AniX opened this issue Oct 5, 2018 · 2 comments · May be fixed by #150
Open

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

AniX opened this issue Oct 5, 2018 · 2 comments · May be fixed by #150

Comments

@AniX
Copy link

AniX commented Oct 5, 2018

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?

@theacodes
Copy link
Contributor

We could just add a .flake8 file to ignore these errors outright, or drop the use of flake8-import-order. I'm fine with either approach.

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

Pylint is obnoxious for legacy codebases, don't bother.

AniX pushed a commit to qyberion/webapp2 that referenced this issue Nov 6, 2018
…cent flake8 versions

- add .flake8, ignore must also include (replaced) default-ignore,
 and a few of them are mutually exclusive
- ignore class I, for import rules that are in conflict with Google
 Python Style Guide
- reformatting some places in code to avoid errors
- not yet addressed: W605 invalid escape sequence '\d'
AniX pushed a commit to qyberion/webapp2 that referenced this issue Nov 6, 2018
…cent flake8 versions

- address W504 line break after binary operator and E501 line too long
- not yet addressed: W605 invalid escape sequence '\d'
AniX pushed a commit to qyberion/webapp2 that referenced this issue Nov 6, 2018
…cent flake8 versions

resolve `W605 invalid escape sequence '\x'`, see
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior

flake8 3.6.0 produces W605 in docstrings that are not raw-string
@remko
Copy link

remko commented Dec 12, 2019

@theacodes I fixed the build job in #150

@remko remko linked a pull request Dec 12, 2019 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants