Skip to content

Commit

Permalink
Add import order linting using tox and flake8-import-order.
Browse files Browse the repository at this point in the history
Adds two tasks:

- Add a task that just lints everything the way Galaxy's default linting is (py27-lint-imports) and don't enforce it passes on Travis.
- Add a task that just lints a subset we expect to past, hopefully we can grow this subset over time.

Once the inverse of the subset we are testing is just the blacklist, we can eliminate bothtasks and just wrap this into Galaxy's default linting.

These tasks require an older flake8 until PyCQA/flake8-import-order#79 (comment) is part of a released version of flake8.
  • Loading branch information
jmchilton committed Jul 26, 2016
1 parent 9607e52 commit c07bbe0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .ci/flake8_lint_include_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/galaxy/jobs/runners/util/external.py
lib/galaxy/util/bunch.py
5 changes: 5 additions & 0 deletions .ci/flake8_wrapper_imports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -e

flake8 `paste .ci/flake8_lint_include_list.txt`
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ env:
- TOX_ENV=py27-unit
- TOX_ENV=qunit
- TOX_ENV=first_startup
- TOX_ENV=py27-lint-imports
- TOX_ENV=py27-lint-imports-include-list

matrix:
include:
- os: osx
Expand All @@ -16,6 +19,8 @@ matrix:
- os: osx
env: TOX_ENV=py27-unit
language: generic
allow_failures:
- env: TOX_ENV=py27-lint-imports

before_install:
- if [ `uname` == "Darwin" ]; then bash -c "brew update && brew install python"; fi
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
# 501 is line length
# W503 is line breaks before binary operators, which has been reversed in PEP 8.
ignore = E128,E201,E202,E203,E501,E402,W503

# For flake8-import-order
# https://github.com/PyCQA/flake8-import-order/blob/master/tests/test_cases/complete_smarkets.py
import-order-style = smarkets
application-import-names = galaxy
24 changes: 22 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[tox]
envlist = py27-lint, py27-unit, qunit, mako-count, web-controller-line-count, py33-lint, py34-lint, py35-lint
envlist = py27-lint, py27-lint-imports, py27-lint-imports-include-list, py27-unit, qunit, mako-count, web-controller-line-count, py33-lint, py34-lint, py35-lint
skipsdist = True


[testenv:py27-lint]
commands = bash .ci/flake8_wrapper.sh
whitelist_externals = bash
Expand Down Expand Up @@ -31,6 +30,27 @@ deps =
NoseHTML
mock

# Setup tox environments for linting all of Galaxy for imports and
# just a subset we expect to pass (the include import list). Once the
# include list is reduced to just the inverse of Galaxy's linting
# blacklist these can both just be removed and flake8-import-order can
# be added as a dependency to Galaxy's main linting task.
[testenv:py27-lint-imports]
commands = bash .ci/flake8_wrapper.sh
whitelist_externals = bash
skip_install = True
deps =
flake8<3
flake8-import-order

[testenv:py27-lint-imports-include-list]
commands = bash .ci/flake8_wrapper_imports.sh
whitelist_externals = bash
skip_install = True
deps =
flake8<3
flake8-import-order

[testenv:qunit]
commands = bash run_tests.sh -q
whitelist_externals = bash
Expand Down

0 comments on commit c07bbe0

Please sign in to comment.