Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: allow arguments to be forwarded to flake8 in lint-python.sh #13649

Merged
merged 1 commit into from Oct 8, 2018

Conversation

Projects
None yet
7 participants
@jamesob
Copy link
Member

commented Jul 12, 2018

In order to use lint-python.sh from within various in-editor linting frameworks (e.g. ALE, flycheck), we need to allow its arguments to be forwarded to the wrapped flake8 invocation.

For what it's worth, here's my bitcoin-specific ALE vim config for doing so (requires this changeset):

$ grep python /home/james/src/bitcoin/.exrc

let g:ale_python_flake8_executable="/home/james/src/bitcoin/test/lint/lint-python.sh"

@jamesob jamesob force-pushed the jamesob:2018-07-python-lint-args branch 2 times, most recently Jul 12, 2018

test/lint/lint-python.sh Outdated
@@ -77,4 +80,4 @@ export LC_ALL=C
# W605 invalid escape sequence "x"
# W606 'async' and 'await' are reserved keywords starting with Python 3.7

flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 "$ARGS"

This comment has been minimized.

Copy link
@promag

promag Jul 13, 2018

Member

Can you try ...W606 "${@:-.}"?

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Jul 16, 2018

No more conflicts as of last run.
@laanwj

This comment has been minimized.

Copy link
Member

commented Aug 31, 2018

This should be easy to merge, however needs rebase and comment addressed.

ping @jamesob

@ken2812221

This comment has been minimized.

Copy link
Member

commented Aug 31, 2018

I would suggest to do this:

diff --git a/test/lint/lint-python.sh b/test/lint/lint-python.sh
index 5afb70f2e..9ebd171eb 100755
--- a/test/lint/lint-python.sh
+++ b/test/lint/lint-python.sh
@@ -8,7 +8,7 @@

 export LC_ALL=C

-ARGS="$*"
+ARGS="$@"
 [ -z "$ARGS" ] && ARGS="."

 # E101 indentation contains mixed spaces and tabs
@@ -80,4 +80,4 @@ ARGS="$*"
 # W605 invalid escape sequence "x"
 # W606 'async' and 'await' are reserved keywords starting with Python 3.7

-flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 "$ARGS"
+flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 $ARGS

Then we can use multiple files:
./test/lint/lint-python.sh $(git ls-files -- '*.py')

@jamesob jamesob force-pushed the jamesob:2018-07-python-lint-args branch Sep 24, 2018

@jamesob

This comment has been minimized.

Copy link
Member Author

commented Sep 24, 2018

Rebased and took some combination of @promag and @ken2812221's recommended changes. I'd have abandoned this change if it didn't make writing tests slightly more pleasant :).

@DrahtBot DrahtBot removed the Needs rebase label Sep 24, 2018

@jamesob jamesob force-pushed the jamesob:2018-07-python-lint-args branch to 854c85a Sep 24, 2018

@MarcoFalke MarcoFalke merged commit 854c85a into bitcoin:master Oct 8, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

MarcoFalke added a commit that referenced this pull request Oct 8, 2018

Merge #13649: test: allow arguments to be forwarded to flake8 in lint…
…-python.sh

854c85a test: allow arguments to be forwarded to flake8 in lint-python.sh (James O'Beirne)

Pull request description:

  In order to use `lint-python.sh` from within various in-editor linting frameworks (e.g. [ALE](https://github.com/w0rp/ale), [flycheck](https://github.com/flycheck/flycheck)), we need to allow its arguments to be forwarded to the wrapped flake8 invocation.

  For what it's worth, here's my bitcoin-specific ALE vim config for doing so (requires this changeset):
  ```vim
  $ grep python /home/james/src/bitcoin/.exrc

  let g:ale_python_flake8_executable="/home/james/src/bitcoin/test/lint/lint-python.sh"
  ```

Tree-SHA512: 0d5500238ea5fde26ee9c21f6518a3a3dc8409c77ad1271ff7e7a94ef45a8c8d2e1b8ad3df3075dd4062ee0fff534625b1bc79613f869cd3c2d9260814ffc7ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.