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

@jamesob
Copy link
Member

@jamesob jamesob 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 2018-07-python-lint-args branch 2 times, most recently from 00e002b to 96c1a4c Jul 12, 2018
@@ -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"
Copy link
Member

@promag promag Jul 13, 2018

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

@DrahtBot
Copy link
Contributor

@DrahtBot DrahtBot commented Jul 16, 2018

No more conflicts as of last run.

@laanwj
Copy link
Member

@laanwj laanwj commented Aug 31, 2018

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

ping @jamesob

@ken2812221
Copy link
Contributor

@ken2812221 ken2812221 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 2018-07-python-lint-args branch from 96c1a4c to 3c4b7b1 Sep 24, 2018
@jamesob
Copy link
Member Author

@jamesob jamesob 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 :).

@jamesob jamesob force-pushed the 2018-07-python-lint-args branch from 3c4b7b1 to 854c85a Sep 24, 2018
@MarcoFalke MarcoFalke merged commit 854c85a into bitcoin:master Oct 8, 2018
2 checks passed
MarcoFalke added a commit that referenced this issue Oct 8, 2018
…-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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants