forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ruff (eventually replacing autoflake, pyupgrade, flake8) (h…
- Loading branch information
Showing
9 changed files
with
185 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,7 +324,62 @@ jobs: | |
. venv/bin/activate | ||
shopt -s globstar | ||
pre-commit run --hook-stage manual flake8 --files {homeassistant,tests}/components/${{ needs.info.outputs.integrations_glob }}/{*,**/*} | ||
lint-ruff: | ||
name: Check ruff | ||
runs-on: ubuntu-latest | ||
needs: | ||
- info | ||
- pre-commit | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/[email protected] | ||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
uses: actions/[email protected] | ||
id: python | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
check-latest: true | ||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: venv | ||
key: >- | ||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ | ||
needs.info.outputs.pre-commit_cache_key }} | ||
- name: Fail job if Python cache restore failed | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: | | ||
echo "Failed to restore Python virtual environment from cache" | ||
exit 1 | ||
- name: Restore pre-commit environment from cache | ||
id: cache-precommit | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ${{ env.PRE_COMMIT_CACHE }} | ||
key: >- | ||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | ||
needs.info.outputs.pre-commit_cache_key }} | ||
- name: Fail job if pre-commit cache restore failed | ||
if: steps.cache-precommit.outputs.cache-hit != 'true' | ||
run: | | ||
echo "Failed to restore pre-commit environment from cache" | ||
exit 1 | ||
- name: Register ruff problem matcher | ||
run: | | ||
echo "::add-matcher::.github/workflows/matchers/ruff.json" | ||
- name: Run ruff (fully) | ||
if: needs.info.outputs.test_full_suite == 'true' | ||
run: | | ||
. venv/bin/activate | ||
pre-commit run --hook-stage manual ruff --all-files | ||
- name: Run ruff (partially) | ||
if: needs.info.outputs.test_full_suite == 'false' | ||
shell: bash | ||
run: | | ||
. venv/bin/activate | ||
shopt -s globstar | ||
pre-commit run --hook-stage manual ruff --files {homeassistant,tests}/components/${{ needs.info.outputs.integrations_glob }}/{*,**/*} | ||
lint-isort: | ||
name: Check isort | ||
runs-on: ubuntu-20.04 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "ruff-error", | ||
"severity": "error", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.*):(\\d+):(\\d+):\\s([EF]\\d{3}\\s.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4 | ||
} | ||
] | ||
}, | ||
{ | ||
"owner": "ruff-warning", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.*):(\\d+):(\\d+):\\s([CDNW]\\d{3}\\s.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ pycodestyle==2.10.0 | |
pydocstyle==6.2.3 | ||
pyflakes==3.0.1 | ||
pyupgrade==3.3.1 | ||
ruff==0.0.230 | ||
yamllint==1.28.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters