Skip to content

Commit 3393fa1

Browse files
authored
Merge pull request #402 from halfguru/chore/ruff-uv-migration
Replace black/isort/flake8 with ruff, migrate to uv/pyproject.toml
2 parents 7fbd206 + 492380e commit 3393fa1

28 files changed

Lines changed: 2082 additions & 1426 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"features": {
3+
"ghcr.io/devcontainers/features/github-cli:1": {
4+
"version": "1.1.0",
5+
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671",
6+
"integrity": "sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671"
7+
},
8+
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {
9+
"version": "1.0.0",
10+
"resolved": "ghcr.io/jsburckhardt/devcontainer-features/uv@sha256:542a0bc2203205b3c696de650ba862f280b20af3543493cc232edd9ac35791f7",
11+
"integrity": "sha256:542a0bc2203205b3c696de650ba862f280b20af3543493cc232edd9ac35791f7"
12+
}
13+
}
14+
}

.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 --group dev --group test && 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.1.0
28+
29+
- name: Install dependencies
30+
run: uv sync --group dev
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.1.0
51+
52+
- name: Install dependencies
53+
run: uv sync --group test
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: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,32 @@
11
---
22
repos:
33
- repo: https://github.com/PyCQA/bandit
4-
rev: '1.7.9'
4+
rev: '1.9.2'
55
hooks:
66
- id: bandit
77
args:
88
- --quiet
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-format
16+
args: [--quiet]
17+
files: ^pyhilo/.+\.py$
18+
- id: ruff
19+
args: [--fix, --exit-non-zero-on-fix]
20+
files: ^pyhilo/.+\.py$
2121
- repo: https://github.com/codespell-project/codespell
22-
rev: v2.2.6
22+
rev: v2.4.1
2323
hooks:
2424
- id: codespell
2525
args:
2626
- --skip="./.*,*.json"
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:
@@ -51,9 +38,13 @@ repos:
5138
- types-PyYAML
5239

5340
- repo: https://github.com/pre-commit/pre-commit-hooks
54-
rev: v5.0.0
41+
rev: v6.0.0
5542
hooks:
5643
- id: check-json
44+
# Exclude .devcontainer.json and .vscode since it uses JSONC
45+
exclude: (.vscode|.devcontainer)
46+
- id: check-yaml
47+
- id: trailing-whitespace
5748
- id: no-commit-to-branch
5849
args:
5950
- --branch=dev
@@ -64,7 +55,7 @@ repos:
6455
# - id: pydocstyle
6556
# files: ^((pyhilo|tests)/.+)?[^/]+\.py$
6657
- repo: https://github.com/gruntwork-io/pre-commit
67-
rev: v0.1.12
58+
rev: v0.1.30
6859
hooks:
6960
- id: shellcheck
7061
files: ^script/.+

.prettierignore

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

.yamllint

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

0 commit comments

Comments
 (0)