Skip to content

Commit 2ac5c90

Browse files
authored
Merge pull request #845 from plugwise/prek
Chores (mainly migrating to prek)
2 parents da06d2e + 371f99e commit 2ac5c90

File tree

13 files changed

+34
-74
lines changed

13 files changed

+34
-74
lines changed

.github/workflows/verify.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
name: Latest commit
55

66
env:
7-
CACHE_VERSION: 2
7+
CACHE_VERSION: 3
88
DEFAULT_PYTHON: "3.14"
9-
PRE_COMMIT_HOME: ~/.cache/pre-commit
109
VENV: venv
1110

1211
on:
@@ -45,15 +44,15 @@ jobs:
4544
needs: cache
4645
name: Prepare
4746
steps:
48-
- name: Prepare code checkout and python/pre-commit setup
47+
- name: Prepare code checkout and python/prek(pre-commit) setup
4948
id: cache-reuse
5049
uses: plugwise/gh-actions/prepare-python-and-code@v2
5150
with:
5251
cache-key: ${{ needs.cache.outputs.cache-key }}
5352
fail-on-miss: false # First time create cache (if not already exists)
5453
python-version: ${{ needs.cache.outputs.python-version }}
5554
venv-dir: ${{ env.VENV }}
56-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
55+
prek-home: ${{ env.PREK_HOME }}
5756

5857
ruff:
5958
runs-on: ubuntu-latest
@@ -73,7 +72,7 @@ jobs:
7372
cache-key: ${{ needs.cache.outputs.cache-key }}
7473
python-version: ${{ needs.cache.outputs.python-version }}
7574
venv-dir: ${{ env.VENV }}
76-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
75+
prek-home: ${{ env.PREK_HOME }}
7776
- name: Ruff (with fix)
7877
run: |
7978
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
@@ -109,20 +108,15 @@ jobs:
109108
cache-key: ${{ needs.cache.outputs.cache-key }}
110109
python-version: ${{ needs.cache.outputs.python-version }}
111110
venv-dir: ${{ env.VENV }}
112-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
111+
prek-home: ${{ env.PREK_HOME }}
113112
- name: Verify commit
114113
run: |
115114
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
116-
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint
117-
- name: Biome lint
118-
run: |
119-
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
120-
mkdir -p ./tmp && curl -sL "https://github.com/biomejs/biome/releases/latest/download/biome-linux-x64" -o ./tmp/biome && chmod +x ./tmp/biome
121-
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual biome
115+
prek run --show-diff-on-failure --color=always --all-files --hook-stage manual pylint
122116
- name: Lint markdown files
123117
run: |
124118
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
125-
pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual markdownlint
119+
prek run --show-diff-on-failure --color=always --all-files --hook-stage manual pymarkdown
126120
127121
pytest:
128122
runs-on: ubuntu-latest
@@ -150,7 +144,7 @@ jobs:
150144
cache-key: ${{ needs.cache.outputs.cache-key }}
151145
python-version: ${{ steps.python.outputs.python-version }} # Force to installed python minor
152146
venv-dir: ${{ env.VENV }}
153-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
147+
prek-home: ${{ env.PREK_HOME }}
154148
- name: Run all tests
155149
run: |
156150
. venv-${{ steps.python.outputs.python-version }}/bin/activate
@@ -182,7 +176,7 @@ jobs:
182176
cache-key: ${{ needs.cache.outputs.cache-key }}
183177
python-version: ${{ needs.cache.outputs.python-version }}
184178
venv-dir: ${{ env.VENV }}
185-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
179+
prek-home: ${{ env.PREK_HOME }}
186180
- name: Run mypy
187181
run: |
188182
. venv-${{ needs.cache.outputs.python-version }}/bin/activate
@@ -227,7 +221,7 @@ jobs:
227221
cache-key: ${{ needs.cache.outputs.cache-key }}
228222
python-version: ${{ needs.cache.outputs.python-version }}
229223
venv-dir: ${{ env.VENV }}
230-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
224+
prek-home: ${{ env.PREK_HOME }}
231225
- name: Download all coverage artifacts
232226
uses: actions/download-artifact@v7
233227
with:
@@ -309,7 +303,7 @@ jobs:
309303
cache-key: ${{ needs.cache.outputs.cache-key }}
310304
python-version: ${{ needs.cache.outputs.python-version }}
311305
venv-dir: ${{ env.VENV }}
312-
precommit-home: ${{ env.PRE_COMMIT_HOME }}
306+
prek-home: ${{ env.PREK_HOME }}
313307
- name: Run complexity report (click to view details)
314308
run: |
315309
. venv-${{ needs.cache.outputs.python-version }}/bin/activate

.markdownlint.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ repos:
8686
name: "Setup"
8787
entry: /usr/bin/env bash -c 'test -d ./venv || scripts/setup.sh'
8888
language: script
89-
- id: setup_test
90-
name: "Setup (extended for testing"
91-
entry: /usr/bin/env bash -c 'test -f ./tmp/biome || scripts/setup_test.sh pre-commit'
92-
language: script
9389
- id: userdata
9490
name: "Validating userdata"
9591
entry: scripts/pre-commit.sh
@@ -115,11 +111,8 @@ repos:
115111
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" NO_FIXTURES="1" scripts/tests_and_coverage.sh test_and_coverage'
116112
language: script
117113
pass_filenames: false
118-
- id: biome
119-
name: "Biome (prettier)"
120-
entry: ./tmp/biome check fixtures/ plugwise/ tests/ --files-ignore-unknown=true --no-errors-on-unmatched --json-formatter-indent-width=2 --json-formatter-indent-style=space
121-
language: script
122-
- repo: https://github.com/igorshubovych/markdownlint-cli
123-
rev: v0.47.0
114+
- repo: https://github.com/jackdewinter/pymarkdown
115+
rev: v0.9.34
124116
hooks:
125-
- id: markdownlint
117+
- id: pymarkdown
118+
name: MarkDown Lint

.pymarkdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "plugins": { "md013": { "enabled": false } } }

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## Ongoing
44

55
- More code optimizations via PR[#843](https://github.com/plugwise/python-plugwise/pull/843)
6+
- Chores:
7+
- Introduce prek (for pre-commit) & align with v2 gh-actions
8+
- Remove biome (as prettier was reinstated)
9+
- Replace node-based markdownlint with pythonic library
610

711
## v1.11.2
812

biome.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

plugwise/legacy/smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ async def set_switch_state(
227227
For individual switches, sets the state directly.
228228
For group switches, sets the state for each member in the group separately.
229229
For switch-locks, sets the lock state using a different data format.
230-
Return the requested state when succesful, the current state otherwise.
230+
Return the requested state when successful, the current state otherwise.
231231
"""
232232
current_state = self.gw_entities[appl_id]["switches"]["relay"]
233233
requested_state = state == STATE_ON

plugwise/smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ async def set_switch_state(
406406
For individual switches, sets the state directly.
407407
For group switches, sets the state for each member in the group separately.
408408
For switch-locks, sets the lock state using a different data format.
409-
Return the requested state when succesful, the current state otherwise.
409+
Return the requested state when successful, the current state otherwise.
410410
"""
411411
model_type = cast(SwitchType, model)
412412
current_state = self.gw_entities[appl_id]["switches"][model_type]

requirements_commit.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
coverage
66
ruff
77
mypy
8-
pre-commit
8+
prek>=0.2.27
99
pylint
1010
pylint_strict_informational==0.1

scripts/manual_fixtures.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ def json_writer(manual_name: str, output: dict) -> None:
3636
adam_multiple_devices_per_zone = base.copy()
3737

3838
# Change schedule to not present for "446ac08dd04d4eff8ac57489757b7314"
39-
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"]["available_schedules"] = []
40-
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"]["select_schedule"] = None
39+
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"][
40+
"available_schedules"
41+
] = []
42+
adam_multiple_devices_per_zone["446ac08dd04d4eff8ac57489757b7314"][
43+
"select_schedule"
44+
] = None
4145

4246
json_writer("m_adam_multiple_devices_per_zone", adam_multiple_devices_per_zone)
4347

0 commit comments

Comments
 (0)