Migrate to ruff for python linting (#240)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
name: CLI Lint
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
paths:
|
||||
- 'qmk_cli/**'
|
||||
- 'pyproject.toml'
|
||||
- '.github/workflows/cli_lint.yml'
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-slim
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Activate virtualenv
|
||||
shell: bash
|
||||
run: |
|
||||
python -m venv .ci_venv
|
||||
source .ci_venv/bin/activate
|
||||
echo PATH=$PATH >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Install dependencies
|
||||
run: python -m pip install --group dev
|
||||
|
||||
- name: Run lint
|
||||
run: ruff check --no-cache --output-format=github
|
||||
|
||||
- name: Run format
|
||||
run: yapf -r --diff qmk_cli
|
||||
+16
-1
@@ -40,7 +40,7 @@ dependencies = [
|
||||
dev = [
|
||||
"build",
|
||||
"bumpversion",
|
||||
"flake8",
|
||||
"ruff",
|
||||
"twine",
|
||||
"yapf",
|
||||
]
|
||||
@@ -60,6 +60,21 @@ include-package-data = false
|
||||
[tool.setuptools.packages]
|
||||
find = {namespaces = false}
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py39"
|
||||
|
||||
include = ['qmk_cli/**/*.py']
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "B", "N", "W", "COM", "C901", "PGH004"]
|
||||
ignore = [
|
||||
"E501", # QMK is ok with long lines.
|
||||
"E231", # Conflicts with our yapf config
|
||||
]
|
||||
|
||||
[tool.ruff.lint.mccabe]
|
||||
max-complexity = 14 # Let's slowly crank this down
|
||||
|
||||
[tool.yapfignore]
|
||||
ignore_patterns = [
|
||||
".direnv/**/*",
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ from pathlib import Path
|
||||
from milc import cli
|
||||
|
||||
|
||||
def AbsPath(arg):
|
||||
def AbsPath(arg): # noqa: N802
|
||||
"""Resolve relative paths to the original working directory.
|
||||
"""
|
||||
arg = Path(arg)
|
||||
|
||||
@@ -53,7 +53,7 @@ KNOWN_BOOTLOADERS = {
|
||||
('2A03', '0036'): 'caterina: Arduino Leonardo',
|
||||
('2A03', '0037'): 'caterina: Arduino Micro',
|
||||
('314B', '0106'): 'apm32-dfu: APM32 DFU ISP Mode',
|
||||
('342D', 'DFA0'): 'wb32-dfu: WB32 Device in DFU Mode'
|
||||
('342D', 'DFA0'): 'wb32-dfu: WB32 Device in DFU Mode',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def env(cli):
|
||||
'QMK_FIRMWARE': home if is_qmk_firmware(Path(home)) else "",
|
||||
'QMK_USERSPACE': userspace if is_qmk_userspace(Path(userspace)) else "",
|
||||
'QMK_DISTRIB_DIR': os.environ.get('QMK_DISTRIB_DIR', ""),
|
||||
'QMK_PATH_PREFIX': os.environ.get('QMK_PATH_PREFIX', "")
|
||||
'QMK_PATH_PREFIX': os.environ.get('QMK_PATH_PREFIX', ""),
|
||||
}
|
||||
|
||||
# Now munge the current cli config
|
||||
|
||||
Reference in New Issue
Block a user