kopia lustrzana https://github.com/pimoroni/pimoroni-pico
CI: Update Python linting.
rodzic
f5e830176b
commit
50522e44dd
|
@ -1,4 +1,4 @@
|
||||||
name: Python
|
name: Python Linting
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -7,24 +7,26 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Python Linting
|
name: Python Linting
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Python
|
||||||
|
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
|
||||||
|
with:
|
||||||
|
python-version: '3.13'
|
||||||
|
|
||||||
- name: Install Python Deps
|
- name: Install Python Deps
|
||||||
run: python3 -m pip install flake8
|
run: source ci/python.sh && qa_prepare_all
|
||||||
|
|
||||||
- name: Lint micropython/modules_py
|
- name: Lint MicroPython Examples
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: source ci/python.sh && qa_examples_check
|
||||||
python3 -m flake8 --show-source --ignore E501 micropython/modules_py
|
|
||||||
|
|
||||||
- name: Lint micropython/examples
|
- name: Lint MicroPython Modules
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: source ci/python.sh && qa_modules_check
|
||||||
python3 -m flake8 --show-source --ignore E501 micropython/examples
|
|
||||||
|
|
||||||
- name: Lint .py tools in C++ examples
|
- name: Lint Python Tools
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: source ci/python.sh && qa_tools_check
|
||||||
python3 -m flake8 --show-source --ignore E501 examples
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Include:
|
||||||
|
# F = Pyflakes
|
||||||
|
# Q = Quotes
|
||||||
|
# E/W = pycodestyle (Whitespace, Line lengths etc)
|
||||||
|
# B - flake8-bugbear = Unused loop variables, sloppy code
|
||||||
|
# COM - flake8-commas
|
||||||
|
# BLE - flake8-blind-except
|
||||||
|
# C4 - flake8-comprehensions
|
||||||
|
# ISC - flake8-implicit-str-concat = Implicit string concat, eg: `"hello" "world"` on one line
|
||||||
|
# ICN - flake8-import-conventions = Import conventions
|
||||||
|
# PIE - flake8-pie = Misc silliness, catches range with a 0 start argument
|
||||||
|
# RET - flake8-return = Enforces straight-forward code around return statements
|
||||||
|
# SLF - flake8-self
|
||||||
|
# ARG - flake8-unused-arguments
|
||||||
|
|
||||||
|
# Ignore:
|
||||||
|
# E501 - "line too long". How narrow is your screen!?
|
||||||
|
# E402 - "module level import not at top of file". Needs must!
|
||||||
|
# COM812 - "Add trailing comma". These are a little obnoxious and weird.
|
||||||
|
# ICN001 - "numpy should be imported as np". No. No it should not.
|
||||||
|
|
||||||
|
QA_INCLUDE="F,Q,W,E,B,COM,BLE,C4,ISC,ICN,PIE,RSE,RET,SLF,ARG"
|
||||||
|
QA_IGNORE="E501,E402,COM812,ICN001"
|
||||||
|
QA_EXCLUDE="micropython/examples/common/lib/tinyweb/server.py,micropython/examples/pico_wireless/*"
|
||||||
|
|
||||||
|
function qa_prepare_all {
|
||||||
|
pip install ruff
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_check {
|
||||||
|
ruff check --select "$QA_INCLUDE" --ignore "$QA_IGNORE" --exclude "$QA_EXCLUDE" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_fix {
|
||||||
|
ruff check --select "$QA_INCLUDE" --ignore "$QA_IGNORE" --exclude "$QA_EXCLUDE" --fix "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_examples_check {
|
||||||
|
qa_check micropython/examples
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_examples_fix {
|
||||||
|
qa_fix micropython/examples
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_modules_check {
|
||||||
|
qa_check micropython/modules_py
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_modules_fix {
|
||||||
|
qa_fix micropython/modules_py
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_tools_check {
|
||||||
|
qa_check examples
|
||||||
|
}
|
||||||
|
|
||||||
|
function qa_tools_fix {
|
||||||
|
qa_fix examples
|
||||||
|
}
|
Ładowanie…
Reference in New Issue