Skip to content

Commit c7b4d27

Browse files
committed
Migrate toolchain from Poetry/black/isort/flake8 to ruff + uv
- Replace black, isort, flake8 with ruff (formatter + linter) - Replace Poetry with uv for dependency management - Drop Node.js/npm/prettier entirely - Raise minimum Python version to 3.11 - Add pytest to CI alongside pre-commit - Add mock-based unit tests for core modules (64 tests) - Remove dead config: .flake8, .yamllint, .prettierignore, .nvmrc - Update devcontainer, dependabot, and CI workflow
1 parent 0bef2da commit c7b4d27

27 files changed

Lines changed: 1813 additions & 1421 deletions

.devcontainer/devcontainer.json

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"containerEnv": {
3-
"POETRY_VIRTUALENVS_IN_PROJECT": "true"
4-
},
52
"customizations": {
63
"codespaces": {
74
"openFiles": [
@@ -13,53 +10,44 @@
1310
"vscode": {
1411
"extensions": [
1512
"charliermarsh.ruff",
16-
"esbenp.prettier-vscode",
17-
"esbenp.prettier-vscode",
1813
"GitHub.vscode-github-actions",
1914
"GitHub.vscode-pull-request-github",
2015
"ms-python.mypy-type-checker",
21-
"ms-python.pylint",
2216
"ms-python.python",
2317
"ms-python.vscode-pylance",
2418
"redhat.vscode-yaml",
25-
"redhat.vscode-yaml",
2619
"ryanluker.vscode-ecoverage-gutters",
27-
"visualstudioexptteam.vscodeintellicode"
20+
"tamasfe.even-better-toml"
2821
],
2922
"settings": {
3023
"[python]": {
3124
"editor.codeActionsOnSave": {
3225
"source.fixAll": true,
3326
"source.organizeImports": true,
3427
"files.trimTrailingWhitespace": true
35-
}
28+
},
29+
"editor.defaultFormatter": "charliermarsh.ruff"
3630
},
3731
"coverage-gutters.customizable.context-menu": true,
3832
"coverage-gutters.customizable.status-bar-toggler-watchCoverageAndVisibleEditors-enabled": true,
3933
"coverage-gutters.showGutterCoverage": false,
4034
"coverage-gutters.showLineCoverage": true,
4135
"coverage-gutters.xmlname": "coverage.xml",
42-
"python.analysis.extraPaths": ["${workspaceFolder}/pyhilo"],
4336
"python.defaultInterpreterPath": ".venv/bin/python",
44-
"python.formatting.provider": "ruff",
4537
"python.testing.cwd": "${workspaceFolder}",
4638
"python.testing.pytestArgs": ["--cov-report=xml"],
47-
"python.testing.pytestEnabled": true,
39+
"python.testing.enabled": true,
4840
"ruff.importStrategy": "fromEnvironment",
4941
"ruff.interpreter": [".venv/bin/python"],
5042
"terminal.integrated.defaultProfile.linux": "zsh"
5143
}
5244
}
5345
},
5446
"features": {
55-
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
5647
"ghcr.io/devcontainers/features/github-cli:1": {},
57-
"ghcr.io/devcontainers/features/node:1": {},
58-
"ghcr.io/devcontainers/features/python:1": {
59-
"installTools": false
60-
}
48+
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {}
6149
},
62-
"image": "mcr.microsoft.com/devcontainers/python:3",
50+
"image": "mcr.microsoft.com/devcontainers/python:3.11-bookworm",
6351
"name": "A Python3, async interface to the Hilo API",
64-
"updateContentCommand": ". ${NVM_DIR}/nvm.sh && nvm install && nvm use && npm install && poetry install && poetry run pre-commit install"
52+
"postCreateCommand": "uv sync && uv run pre-commit install"
6553
}

.flake8

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

.github/dependabot.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ updates:
44
directory: "/"
55
schedule:
66
interval: weekly
7-
- package-ecosystem: pip
8-
directory: "/.github/workflows"
9-
schedule:
10-
interval: weekly
11-
- package-ecosystem: pip
7+
- package-ecosystem: uv
128
directory: "/"
139
schedule:
1410
interval: weekly

.github/workflows/constraints.txt

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

.github/workflows/tests.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Linting
1+
name: CI
22

33
on:
44
push:
@@ -23,17 +23,34 @@ jobs:
2323
with:
2424
python-version: ${{ env.DEFAULT_PYTHON }}
2525

26-
- name: Upgrade pip
27-
run: |
28-
pip install --constraint=.github/workflows/constraints.txt pip
29-
pip --version
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v8.0.0
28+
29+
- name: Install dependencies
30+
run: uv sync
3031

31-
- name: Install Python modules
32-
run: |
33-
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports
34-
3532
- name: Run pre-commit on all files
3633
env:
3734
SKIP: no-commit-to-branch
38-
run: |
39-
pre-commit run --all-files --show-diff-on-failure --color=always
35+
run: uv run pre-commit run --all-files --show-diff-on-failure --color=always
36+
37+
tests:
38+
runs-on: "ubuntu-latest"
39+
name: Tests
40+
steps:
41+
- name: Check out the repository
42+
uses: actions/checkout@v6
43+
44+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
45+
uses: actions/setup-python@v6.2.0
46+
with:
47+
python-version: ${{ env.DEFAULT_PYTHON }}
48+
49+
- name: Install uv
50+
uses: astral-sh/setup-uv@v8.0.0
51+
52+
- name: Install dependencies
53+
run: uv sync
54+
55+
- name: Run tests
56+
run: uv run pytest -v

.nvmrc

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

.pre-commit-config.yaml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ repos:
99
- --format=custom
1010
- --configfile=.bandit.yaml
1111
files: ^pyhilo/.+\.py$
12-
- repo: https://github.com/psf/black
13-
rev: 24.1.1
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.15.9
1414
hooks:
15-
- id: black
16-
args:
17-
- --safe
18-
- --quiet
19-
language_version: python3
20-
files: ^((pyhilo|tests)/.+)?[^/]+\.py$
15+
- id: ruff
16+
args: [--fix, --exit-non-zero-on-fix]
17+
files: ^pyhilo/.+\.py$
18+
- id: ruff-format
19+
args: [--quiet]
20+
files: ^pyhilo/.+\.py$
2121
- repo: https://github.com/codespell-project/codespell
2222
rev: v2.2.6
2323
hooks:
@@ -27,19 +27,6 @@ repos:
2727
- --quiet-level=4
2828
- -L ba,hass,manuel,connexion
2929
exclude_types: [json]
30-
- repo: https://github.com/PyCQA/flake8
31-
rev: 7.0.0
32-
hooks:
33-
- id: flake8
34-
additional_dependencies:
35-
- flake8-docstrings==1.7.0
36-
- pydocstyle==6.3.0
37-
files: ^pyhilo/.+\.py$
38-
- repo: https://github.com/pycqa/isort
39-
rev: 5.13.2
40-
hooks:
41-
- id: isort
42-
files: ^(pyhilo|tests)/.+\.py$
4330
- repo: https://github.com/pre-commit/mirrors-mypy
4431
rev: v1.19.1
4532
hooks:

.prettierignore

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

.yamllint

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

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,32 @@ the [Dev Container][devcontainer] feature of Visual Studio Code.
3030

3131
[![Open in Dev Containers][devcontainer-shield]][devcontainer]
3232

33-
This Python project is fully managed using the [Poetry][poetry] dependency
34-
manager. But also relies on the use of NodeJS for certain checks during
35-
development.
33+
This Python project uses [uv][uv] for dependency management and [ruff][ruff]
34+
for formatting and linting.
3635

3736
You need at least:
3837

3938
- Python 3.11+
40-
- [Poetry][poetry-install]
41-
- NodeJS 20+ (including NPM)
39+
- [uv][uv]
4240

4341
To install all packages, including all development requirements:
4442

4543
```bash
46-
npm install
47-
poetry install
44+
uv sync
4845
```
4946

5047
As this repository uses the [pre-commit][pre-commit] framework, all changes
5148
are linted and tested with each commit. You can run all checks and tests
5249
manually, using the following command:
5350

5451
```bash
55-
poetry run pre-commit run --all-files
52+
uv run pre-commit run --all-files
5653
```
5754

5855
To run just the Python tests:
5956

6057
```bash
61-
poetry run pytest
58+
uv run pytest
6259
```
6360

6461
## Authors & contributors
@@ -84,6 +81,8 @@ check [the contributor's page][contributors].
8481
[poetry-install]: https://python-poetry.org/docs/#installation
8582
[poetry]: https://python-poetry.org
8683
[pre-commit]: https://pre-commit.com/
84+
[uv]: https://docs.astral.sh/uv/
85+
[ruff]: https://docs.astral.sh/ruff/
8786
[dvd-dev]: https://github.com/dvd-dev
8887
[frenck]: https://github.com/frenck
8988
[contributors]: https://github.com/dvd-dev/python-hilo/graphs/contributors

0 commit comments

Comments
 (0)