Skip to content

Commit 07a03dd

Browse files
committed
Change linting to Ruff
1 parent 927dc92 commit 07a03dd

File tree

10 files changed

+139
-125
lines changed

10 files changed

+139
-125
lines changed

.devcontainer.json

+18-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"customizations": {
1515
"vscode": {
1616
"extensions": [
17+
"charliermarsh.ruff",
1718
"github.vscode-pull-request-github",
1819
"ms-python.python",
1920
"ms-python.vscode-pylance",
@@ -22,19 +23,27 @@
2223
"settings": {
2324
"files.eol": "\n",
2425
"editor.tabSize": 4,
25-
"python.analysis.autoSearchPaths": false,
26-
"python.linting.pylintEnabled": true,
27-
"python.linting.enabled": true,
28-
"python.linting.flake8Enabled": true,
29-
"python.formatting.provider": "black",
30-
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
31-
"python.defaultInterpreterPath": "/usr/local/bin/python",
3226
"editor.formatOnPaste": false,
3327
"editor.formatOnSave": true,
3428
"editor.formatOnType": true,
35-
"files.trimTrailingWhitespace": true
29+
"files.trimTrailingWhitespace": true,
30+
"python.analysis.typeCheckingMode": "basic",
31+
"python.analysis.autoImportCompletions": true,
32+
"python.defaultInterpreterPath": "/usr/local/bin/python",
33+
"[python]": {
34+
"editor.defaultFormatter": "charliermarsh.ruff"
35+
}
3636
}
3737
}
3838
},
39-
"remoteUser": "vscode"
39+
"remoteUser": "vscode",
40+
"features": {
41+
"ghcr.io/devcontainers-extra/features/apt-packages:1": {
42+
"packages": [
43+
"ffmpeg",
44+
"libturbojpeg0",
45+
"libpcap-dev"
46+
]
47+
}
48+
}
4049
}

.github/workflows/cron.yaml

-20
This file was deleted.

.github/workflows/lint.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Lint"
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
pull_request:
8+
branches:
9+
- "master"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
ruff-format:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
21+
- name: Set up Python 3.12
22+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
23+
with:
24+
python-version: "3.12"
25+
cache: "pip"
26+
27+
- name: "Install requirements"
28+
run: python3 -m pip install -r requirements.txt
29+
30+
- name: Run ruff format
31+
run: |
32+
ruff format --diff --target-version=py312 .
33+
34+
ruff:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39+
40+
- name: Set up Python 3.12
41+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
42+
with:
43+
python-version: "3.12"
44+
cache: "pip"
45+
46+
- name: "Install requirements"
47+
run: python3 -m pip install -r requirements.txt
48+
49+
- name: Run ruff
50+
run: |
51+
ruff check --output-format=github .

.github/workflows/pull.yml

-30
This file was deleted.

.github/workflows/push.yml

-33
This file was deleted.

.github/workflows/validate.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Validate"
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
push:
8+
branches:
9+
- "main"
10+
pull_request:
11+
branches:
12+
- "main"
13+
14+
jobs:
15+
hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest
16+
name: "Hassfest Validation"
17+
runs-on: "ubuntu-latest"
18+
steps:
19+
- name: "Checkout the repository"
20+
uses: "actions/checkout@v4.2.2"
21+
22+
- name: "Run hassfest validation"
23+
uses: "home-assistant/actions/hassfest@master"
24+
25+
hacs: # https://github.com/hacs/action
26+
name: "HACS Validation"
27+
runs-on: "ubuntu-latest"
28+
steps:
29+
- name: "Checkout the repository"
30+
uses: "actions/checkout@v4.2.2"
31+
32+
- name: "Run HACS validation"
33+
uses: "hacs/action@main"
34+
with:
35+
category: "integration"

.ruff.toml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml
2+
3+
target-version = "py312"
4+
5+
[lint]
6+
select = [
7+
"ALL",
8+
]
9+
10+
ignore = [
11+
"ANN101", # Missing type annotation for `self` in method
12+
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
13+
"D203", # no-blank-line-before-class (incompatible with formatter)
14+
"D212", # multi-line-summary-first-line (incompatible with formatter)
15+
"COM812", # incompatible with formatter
16+
"ISC001", # incompatible with formatter
17+
]
18+
19+
[lint.flake8-pytest-style]
20+
fixture-parentheses = false
21+
22+
[lint.pyupgrade]
23+
keep-runtime-typing = true
24+
25+
[lint.mccabe]
26+
max-complexity = 25

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pip>=21.3.1
22
colorlog
33
homeassistant
4+
ruff==0.8.4

scripts/lint

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
ruff format .
8+
ruff check . --fix

setup.cfg

-33
This file was deleted.

0 commit comments

Comments
 (0)