Skip to content

Commit 12b568f

Browse files
authored
Modernize project and migrate to uv/ruff (#1687)
* Migrate to uv * Migrate to ruff * Add ruff * Update pre-commit * Update * Update dependabot configuration to specify package ecosystems * Fix pytest version constraint in dev-dependencies * Improve testing strategy * Improve release workflow * Remove redundant version bumping step in release workflow * Update flake8 configuration to ignore unused imports * Add ruff linter to the list of selected linters in configuration * Update pre-commit configuration and refine mypy settings * Improve readme * Refine wording in README for clarity and consistency
1 parent 26e02b5 commit 12b568f

File tree

21 files changed

+1545
-2110
lines changed

21 files changed

+1545
-2110
lines changed

.devcontainer/devcontainer.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,33 @@
77
// Features to add to the dev container. More info: https://containers.dev/features.
88
"features": {
99
"ghcr.io/devcontainers/features/github-cli:1": {},
10-
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
10+
"ghcr.io/va-h/devcontainers-features/uv:1": {}
1111
},
1212
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1313
// "forwardPorts": [],
1414
// Use 'postCreateCommand' to run commands after the container is created.
15-
"postCreateCommand": "poetry config virtualenvs.in-project true && poetry install --with dev --no-interaction && . .venv/bin/activate && pre-commit install",
15+
"postCreateCommand": "uv sync && uv run pre-commit install",
1616
// Configure tool-specific properties.
1717
"customizations": {
1818
"vscode": {
1919
"extensions": [
20+
"GitHub.copilot-chat",
2021
"ms-python.python",
21-
"ms-python.black-formatter"
22+
"ms-python.debugpy",
23+
"charliermarsh.ruff",
24+
"github.vscode-github-actions"
2225
],
23-
"settings": {
24-
"python.defaultInterpreterPath": "./.venv/bin/python"
26+
"python.testing.pytestArgs": [
27+
"tests"
28+
],
29+
"python.testing.unittestEnabled": false,
30+
"python.testing.pytestEnabled": true,
31+
"[python]": {
32+
"editor.formatOnSave": true,
33+
"editor.defaultFormatter": "charliermarsh.ruff",
34+
"editor.codeActionsOnSave": {
35+
"source.organizeImports.ruff": "explicit"
36+
}
2537
}
2638
}
2739
}

.github/dependabot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: "uv"
44
directory: "/"
55
schedule:
66
interval: "daily"
77
time: "08:00"
88
open-pull-requests-limit: 10
99

10-
- package-ecosystem: github-actions
10+
- package-ecosystem: "github-actions"
1111
directory: "/"
1212
schedule:
1313
interval: "daily"
1414
time: "08:00"
1515
open-pull-requests-limit: 10
16+
17+
- package-ecosystem: "devcontainers"
18+
directory: "/"
19+
schedule:
20+
interval: weekly

.github/workflows/lint.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
name: "Python ${{ matrix.python-version }}"
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "${{ matrix.python-version }}"
28+
29+
- name: Install the project
30+
run: uv sync --all-extras --dev
31+
32+
- name: Run pre-commit
33+
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files

.github/workflows/main.yaml

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

.github/workflows/release.yml

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow will upload a Python Package using Poetry when a release is published
1+
# This workflow will upload the package to PyPi when a release is published
22

33
name: Publish Python Package (PyPi)
44

@@ -12,32 +12,53 @@ jobs:
1212
environment: release
1313

1414
permissions:
15-
# IMPORTANT: this permission is mandatory for trusted publishing
15+
# IMPORTANT: this permission is mandatory for trusted publishing via PyPi
1616
id-token: write
1717

1818
steps:
1919
- uses: actions/checkout@v4
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
2024
- name: Set up Python
2125
uses: actions/setup-python@v5
2226
with:
2327
python-version: "3.x"
24-
- name: Set up Poetry
25-
uses: Gr1N/setup-poetry@v9
26-
- name: Bump Poetry version
28+
29+
- name: Retrieve version from tag name
30+
id: retrieve-version
31+
run: |
32+
tag=${{ github.event.release.tag_name }}
33+
version_number=${tag#?}
34+
echo version: $version_number
35+
echo "version=$version_number" >> $GITHUB_OUTPUT
36+
37+
- name: Bump project version in pyproject.toml
38+
run: |
39+
VERSION=${{ steps.retrieve-version.outputs.version }}
40+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION
41+
42+
- name: Add changes to current branch and tag
2743
run: |
28-
tag=${{ github.event.release.tag_name }}
29-
version_number=${tag#?}
30-
poetry version $version_number
44+
git config --local user.email "action@github.com"
45+
git config --local user.name "GitHub Action"
46+
47+
git add pyproject.toml
48+
git commit -m "Bump version to ${{ github.event.release.tag_name }}"
49+
3150
- name: Commit changes
32-
uses: EndBug/add-and-commit@v4
33-
with:
34-
message: "Bump version to ${{ github.event.release.tag_name }}"
35-
add: "pyproject.toml"
36-
ref: "main"
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
- name: Build package distribution
4051
run: |
41-
poetry build
42-
- name: Publish package distributions to PyPI
43-
uses: pypa/gh-action-pypi-publish@release/v1
52+
git add pyproject.toml
53+
git commit -m "Bump package version to ${{ steps.retrieve-version.outputs.version }}."
54+
git tag -f -a ${{ github.event.release.tag_name }} -m "Release ${{ steps.retrieve-version.outputs.version }}."
55+
git push origin HEAD:main
56+
git push origin -f ${{ github.event.release.tag_name }}
57+
58+
- name: Build package
59+
run: |
60+
uv build
61+
62+
- name: Publish package to PyPI
63+
run: |
64+
uv publish

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pytest:
10+
name: "Python ${{ matrix.python-version }}"
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "${{ matrix.python-version }}"
28+
29+
- name: Install the project
30+
run: uv sync --all-extras --dev
31+
32+
- name: Run tests
33+
run: uv run pytest tests

.pre-commit-config.yaml

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
13
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
# Ruff version.
6+
rev: v0.12.0
7+
hooks:
8+
# Run the linter.
9+
- id: ruff
10+
args: [ --fix ]
11+
# Run the formatter.
12+
- id: ruff-format
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
314
rev: v5.0.0
415
hooks:
5-
- id: check-json
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: check-json
619
exclude: .devcontainer
7-
- id: check-yaml
8-
- id: trailing-whitespace
9-
- id: end-of-file-fixer
10-
- repo: local
20+
- id: check-yaml
21+
- id: check-added-large-files
22+
- repo: local
1123
hooks:
12-
- id: black
13-
name: black
14-
entry: black
15-
language: system
16-
types: [ python ]
17-
- id: flake8
18-
name: flake8
19-
entry: flake8
20-
language: system
21-
types: [ python ]
22-
- id: isort
23-
name: isort
24-
entry: isort
25-
language: system
26-
types: [ python ]
27-
- id: pyupgrade
28-
name: pyupgrade
29-
entry: pyupgrade
30-
args: ["--py310-plus"]
31-
language: system
32-
types: [ python ]
3324
- id: mypy
3425
name: mypy
3526
entry: mypy
3627
language: system
3728
types: [ python ]
38-
- id: pylint
39-
name: pylint
40-
entry: pylint
41-
language: system
42-
types: [ python ]
29+
exclude: tests

.pylintrc

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

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# Python client for OverKiz API
22

3-
<p align=left>
4-
<a href="https://github.com/iMicknl/python-overkiz-api/actions"><img src="https://github.com/iMicknl/python-overkiz-api/workflows/CI/badge.svg"/></a>
5-
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" /></a>
6-
</p>
3+
A fully asynchronous and user-friendly API client for the OverKiz platform. This client enables interaction with smart devices connected to OverKiz, supporting multiple vendors such as Somfy TaHoma and Atlantic Cozytouch.
74

8-
A fully async and easy to use API client for the (internal) OverKiz API. You can use this client to interact with smart devices connected to the OverKiz platform, used by various vendors like Somfy TaHoma and Atlantic Cozytouch.
9-
10-
This package is mainly used by Home Assistant Core, to offer the Overkiz integration. If you want to use this package in your own project, you can use the [following examples](#getting-started) to get started, or look at the [Home Assistant Code](https://github.com/home-assistant/core/tree/dev/homeassistant/components/overkiz) for more examples.
5+
This package is primarily used by Home Assistant Core to provide the Overkiz integration. If you wish to use this package in your own project, refer to the [examples below](#getting-started) or explore the [Home Assistant source code](https://github.com/home-assistant/core/tree/dev/homeassistant/components/overkiz) for additional usage examples.
116

127
## Supported hubs
138

@@ -143,16 +138,17 @@ async def main() -> None:
143138
asyncio.run(main())
144139
```
145140

146-
## Development
141+
## Contribute
142+
143+
We welcome contributions! To get started with setting up this project for development, follow the steps below.
147144

148-
### DevContainer (recommended)
145+
### Dev Container (recommended)
149146

150-
If you use Visual Studio Code with Docker or GitHub CodeSpaces, you can leverage the available devcontainer. This will install all required dependencies and tools and has the right Python version available. Easy!
147+
If you use Visual Studio Code with Docker or GitHub Codespaces, you can take advantage of the included [Dev Container](https://code.visualstudio.com/docs/devcontainers/containers). This environment comes pre-configured with all necessary dependencies and tools, including the correct Python version, making setup simple and straightforward.
151148

152149
### Manual
153-
- Install Python 3.12
154-
- Install [poetry](https://python-poetry.org): `curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python`
155-
- Clone this repository
156-
- `cd python-overkiz-api`
157-
- Init the project: `poetry install`
158-
- Run `poetry run pre-commit install`
150+
151+
- Ensure Python 3.12 is installed on your system.
152+
- Install [uv](https://docs.astral.sh/uv/getting-started/installation).
153+
- Clone this repository and navigate to it: `cd python-overkiz-api`
154+
- Initialize the project with `uv sync`, then run `uv run pre-commit install`

0 commit comments

Comments
 (0)