Replace black/isort/flake8 with ruff, migrate to uv/pyproject.toml#927
Replace black/isort/flake8 with ruff, migrate to uv/pyproject.toml#927ic-dev21 merged 8 commits intodvd-dev:mainfrom
Conversation
- Replace black, isort, and flake8 with ruff (formatter + linter) in pre-commit config - Add pyproject.toml with full PEP 621 metadata (replaces setup.cfg) - Delete requirements.txt, requirements_test.txt, setup.cfg - Update Dockerfile.dev for Python 3.14 and uv - Update CI workflow to use uv setup action - Update dev scripts to use uv sync - Update README and CONTRIBUTING docs (black -> ruff references) - Fix stale test mocks for python-hilo>=2026.3.5 API changes - Update snapshot for newer HA entity registry schema
|
Thank you for your contribution. I think pre-commit fails from not being explicitely installed? |
57bd4ce to
1a5bf12
Compare
Yeah, sorry for that, didn't test this locally. It should work now with uv command |
Will test this locally, I'm not a dev at all and I'm still learning as I go. I do know we had a ruff dependency but I'm pretty sure the way it is currently setup it wasn't being used at all. |
To give you more context, ruff has become the industry standard for Python linting and formatting. It replaces black, isort and flake8. It's used by major projects like FastAPI, Pandas, Django, etc. Same for uv, modern replacement for pip which is much faster. See the links below that explains how they achieve their higher performance: Home Assistant itself also is migrating to both their dev guidelines I believe:
Another Quebec-based HA integration, https://github.com/hydroqc/hydroqc-ha, also uses ruff and uv if you'd like to see a similar setup in practice. Let me know if you have more questions! |
I genuinely appreciate you taking the time to explain (I'm fine with either french or english by the way, if you have any preferences). We do also have the python-hilo library that does the API stuff in the background that probably would benefit from a similar treatment. Time is somewhat tight this week but I'm very interested in learning more about all of this. I'm guessing I will also need to modify dependabot and maybe others? |
- Delete requirements.txt and requirements_test.txt (restored by mistake) - Update dependabot.yml: pip -> uv ecosystem - Remove stale pip pin from constraints.txt - Update CONTRIBUTING.md: pip install -> uv pip install - Update .vscode/tasks.json: use uv run for pytest and pre-commit
Pas de problème! Je peux jeter un coup d'oeil à python-hilo. Je viens de re-faire un tour dans ma PR pour d'autres éléments manquants pour la migration et j'ai commit d'autres changements incluant dependabot. |
f054c4f to
e66f374
Compare
Going back to python 3.12 to maintain some backward compatibility to about 2 years. This will make sure users on older HA versions can still run the component.
|
@halfguru salut, j'ai joué un peu dans tes plates-bandes. Tu en penses quoi? |
Add the correct classifiers
LGTM |
Motivation
Why ruff?
Why uv?
pyproject.tomlis the modern standard (PEP 621), consolidatessetup.cfg,requirements.txt,requirements_test.txtinto one fileuv.lockSummary
ruff-pre-commitin.pre-commit-config.yamlpyproject.tomlwith full PEP 621 metadata, replacingsetup.cfg,requirements.txt, andrequirements_test.txtuvfor dependency management (Python 3.14)scripts/setup,scripts/setup_commit_hook.sh) to useuv sync --group testpython-hilo>=2026.3.5API changes (get_devices→get_device_cache/wait_for_device_cache/get_location_ids/get_gateway)Removed files
setup.cfg: migrated topyproject.toml.flake8.yml: migrated topyproject.tomlrequirements.txt: replaced by[project.dependencies]inpyproject.tomlrequirements_test.txt: replaced by[project.optional-dependencies]inpyproject.toml