|
5 | 5 | jobs: |
6 | 6 | autopep8: |
7 | 7 | runs-on: ubuntu-latest |
| 8 | + env: |
| 9 | + # Error codes organized following https://pep8.readthedocs.io/en/latest/intro.html#error-codes |
| 10 | + # |
| 11 | + # E1 - Indentation |
| 12 | + # E111 - Fix indentation to be a multiple of four. |
| 13 | + # E115 - Fix expected indented block (comment). |
| 14 | + # |
| 15 | + # E2 - Whitespace |
| 16 | + # E211 - Remove extraneous whitespace before '('. |
| 17 | + # E222 - Fix multiple spaces after operator. |
| 18 | + # E225 - Fix missing whitespace around operator. |
| 19 | + # E241 - Fix extraneous whitespace around keywords. |
| 20 | + # E242 - Remove extraneous whitespace around operator. |
| 21 | + # E251 - Remove whitespace around parameter '=' sign. |
| 22 | + # E252 - Missing whitespace around parameter equals. |
| 23 | + # E27 - Fix extraneous whitespace around keywords. |
| 24 | + # |
| 25 | + # E3 - Blank line |
| 26 | + # E303 - Remove extra blank lines. |
| 27 | + # E304 - Remove blank line following function decorator. |
| 28 | + # E306 - Expected 1 blank line before a nested definition. |
| 29 | + # |
| 30 | + # E4 - Import |
| 31 | + # E401 - Put imports on separate lines. |
| 32 | + # |
| 33 | + # E5 - Line length |
| 34 | + # E502 - Remove extraneous escape of newline. |
| 35 | + # |
| 36 | + # E7 - Statement |
| 37 | + # E70 - Put semicolon-separated compound statement on separate lines. |
| 38 | + # E701 - Put colon-separated compound statement on separate lines. |
| 39 | + # E702 - Put semicolon-separated compound statement on separate lines. |
| 40 | + # E711 - Fix comparison with None. |
| 41 | + # E712 - Fix comparison with boolean. |
| 42 | + # E713 - Use 'not in' for test for membership. |
| 43 | + # E714 - Use 'is not' test for object identity. |
| 44 | + # E721 - Use "isinstance()" instead of comparing types directly. |
| 45 | + # E731 - Use a def when use do not assign a lambda expression. |
| 46 | + # |
| 47 | + # W2 - Whitespace warning |
| 48 | + # W291 - Remove trailing whitespace. |
| 49 | + # W292 - Add a single newline at the end of the file. |
| 50 | + # W293 - Remove trailing whitespace on blank line. |
| 51 | + # |
| 52 | + # W3 - Blank line warning |
| 53 | + # W391 - Remove trailing blank lines. |
| 54 | + # |
| 55 | + # W5 - Line break warning |
| 56 | + # W504 - Fix line break after binary operator. |
| 57 | + # |
| 58 | + # W6 - Deprecation warning |
| 59 | + # W601 - Use "in" rather than "has_key()". |
| 60 | + # W602 - Fix deprecated form of raising exception. |
| 61 | + # W603 - Use "!=" instead of "<>" |
| 62 | + # W604 - Use "repr()" instead of backticks. |
| 63 | + # W605 - Fix invalid escape sequence 'x'. |
| 64 | + # W690 - Fix various deprecated code (via lib2to3). |
| 65 | + AUTOPEP8_CODES: | |
| 66 | + E111,E115, |
| 67 | + E211,E222,E225,E241,E242,E251,E252,E27, |
| 68 | + E303,E304,E306, |
| 69 | + E401, |
| 70 | + E502, |
| 71 | + E70,E701,E702,E711,E712,E713,E714,E721,E731, |
| 72 | + W291,W292,W293, |
| 73 | + W391, |
| 74 | + W504, |
| 75 | + W601,W602,W603,W604,W605,W690 |
8 | 76 | steps: |
9 | 77 | - uses: actions/checkout@v2 |
10 | 78 | id: checkout |
| 79 | + - name: Process autopep8 codes |
| 80 | + id: process_codes |
| 81 | + run: | |
| 82 | + # Convert multiline codes to single line, removing newlines and extra spaces |
| 83 | + PROCESSED_CODES=$(echo "$AUTOPEP8_CODES" | tr -d '\n' | tr -s ' ' | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//') |
| 84 | + echo "AUTOPEP8_SELECT=$PROCESSED_CODES" >> $GITHUB_ENV |
| 85 | + echo "Processed codes: $PROCESSED_CODES" |
11 | 86 | - name: autopep8 |
12 | 87 | uses: peter-evans/autopep8@v1 |
13 | 88 | if: ${{ github.repository }} == 'LMFDB/lmfdb' |
14 | 89 | with: |
15 | | - # see generate_autopep8codes.py |
16 | | - # E241 - Fix extraneous whitespace around keywords. |
17 | | - # E242 - Remove extraneous whitespace around operator. |
18 | | - # E251 - Remove whitespace around parameter '=' sign. |
19 | | - # E252 - Missing whitespace around parameter equals. |
20 | | - # E27 - Fix extraneous whitespace around keywords. |
21 | | - # E266 - Fix too many leading '#' for block comments. |
22 | | - # W291 - Remove trailing whitespace. |
23 | | - # W292 - Add a single newline at the end of the file. |
24 | | - # W293 - Remove trailing whitespace on blank line. |
25 | | - # E303 - Remove extra blank lines. |
26 | | - # E304 - Remove blank line following function decorator. |
27 | | - # E306 - Expected 1 blank line before a nested definition. |
28 | | - # W391 - Remove trailing blank lines. |
29 | | - # E401 - Put imports on separate lines. |
30 | | - # E502 - Remove extraneous escape of newline. |
31 | | - # W504 - Fix line break after binary operator. |
32 | | - # W601 - Use "in" rather than "has_key()". |
33 | | - # W602 - Fix deprecated form of raising exception. |
34 | | - # W603 - Use "!=" instead of "<>" |
35 | | - # W604 - Use "repr()" instead of backticks. |
36 | | - # W605 - Fix invalid escape sequence 'x'. |
37 | | - # W690 - Fix various deprecated code (via lib2to3). |
38 | | - # E70 - Put semicolon-separated compound statement on separate lines. |
39 | | - # E701 - Put colon-separated compound statement on separate lines. |
40 | | - # E711 - Fix comparison with None. |
41 | | - # E712 - Fix comparison with boolean. |
42 | | - # E713 - Use 'not in' for test for membership. |
43 | | - # E714 - Use 'is not' test for object identity. |
44 | | - # E721 - Use "isinstance()" instead of comparing types directly. |
45 | | - # E722 - Fix bare except. |
46 | | - # E731 - Use a def when use do not assign a lambda expression. |
47 | | - args: --recursive --in-place --aggressive --select=E241,E242,E251,E252,E266,E27,W291,W292,W293,E303,E304,E306,W391,E401,E502,W504,W601,W602,W603,W604,W605,W690,E70,E701,E711,E712,E713,E714,E721,E722,E731 lmfdb/ |
| 90 | + # Args using processed environment variable |
| 91 | + args: --recursive --in-place --aggressive --select=${{ env.AUTOPEP8_SELECT }} lmfdb/ |
48 | 92 |
|
49 | 93 | - name: Create Pull Request |
50 | 94 | uses: peter-evans/create-pull-request@v3 |
|
0 commit comments