Skip to content

Commit fc5ddac

Browse files
authored
Merge pull request #70 from baodrate/uv
Use uv
2 parents 003bdda + 71e19c8 commit fc5ddac

File tree

10 files changed

+782
-90
lines changed

10 files changed

+782
-90
lines changed

.devcontainer/devcontainer.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/docker-existing-dockerfile
33
{
44
"name": "Existing Dockerfile",
5-
// Sets the run context to one level up instead of the .devcontainer folder.
6-
"context": "..",
7-
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
8-
"dockerFile": "../Dockerfile.dev",
5+
"build": {
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerfile": "../Dockerfile.dev"
10+
},
911
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1012
// "forwardPorts": [],
1113
// Install package in "dev mode" to expose CLI
12-
"postCreateCommand": "pip3 install -e .",
14+
"postCreateCommand": "uv sync --dev --frozen",
15+
"postStartCommand": "uv sync --dev --frozen",
16+
"postAttachCommand": "uv sync --dev --frozen",
1317
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
1418
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
1519
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
@@ -19,26 +23,22 @@
1923
"customizations": {
2024
"vscode": {
2125
"extensions": [
26+
"ms-python.python",
2227
"charliermarsh.ruff",
2328
"ms-python.pylint"
24-
]
25-
},
26-
"settings": {
27-
"editor.formatOnPaste": false,
28-
"editor.formatOnSave": true,
29-
"editor.formatOnType": true,
30-
"files.trimTrailingWhitespace": true,
31-
"terminal.integrated.defaultProfile.linux": "zsh",
32-
"[python]": {
33-
"editor.defaultFormatter": "charliermarsh.ruff"
34-
},
35-
"ruff.format.args": [
36-
"--config",
37-
"line-length=127"
3829
],
39-
"pylint.args": [
40-
"--max-line-length=127"
41-
]
30+
"settings": {
31+
"python.defaultInterpreterPath": ".venv/bin/python",
32+
"python.terminal.activateEnvInCurrentTerminal": true,
33+
"editor.formatOnPaste": false,
34+
"editor.formatOnSave": true,
35+
"editor.formatOnType": true,
36+
"files.trimTrailingWhitespace": true,
37+
"terminal.integrated.defaultProfile.linux": "zsh",
38+
"[python]": {
39+
"editor.defaultFormatter": "charliermarsh.ruff"
40+
}
41+
}
4242
}
4343
}
4444
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uv.lock linguist-generated

.github/workflows/python-package.yml

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,71 @@ on:
77
push:
88
branches: [ "master" ]
99
pull_request:
10-
branches: [ "master" ]
1110

1211
jobs:
1312
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.13"]
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Install uv and set the Python version
23+
uses: astral-sh/setup-uv@v7
24+
with:
25+
python-version: ${{ matrix.python-version }}
1426

27+
- name: Build package
28+
run: uv build
29+
30+
test:
1531
runs-on: ubuntu-latest
1632
strategy:
1733
fail-fast: false
1834
matrix:
19-
python-version: ["3.13.x"]
35+
python-version: ["3.13"]
2036

2137
steps:
2238
- uses: actions/checkout@v3
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v3
39+
40+
- name: Install uv and set the Python version
41+
uses: astral-sh/setup-uv@v7
2542
with:
2643
python-version: ${{ matrix.python-version }}
44+
2745
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
python -m pip install flake8 pytest
31-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32-
python -m pip install build
33-
- name: Lint with flake8
34-
run: |
35-
# stop the build if there are Python syntax errors or undefined names
36-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
46+
run: uv sync --locked --all-extras --dev
47+
48+
- name: Lint with ruff
49+
# stop the build if there are Python syntax errors or undefined names
50+
run: uv run ruff check --select=E9,F63,F7,F82 --output-format=github
51+
3952
- name: Test with pytest
4053
run: |
41-
pytest
42-
- name: Build package
43-
run: python -m build
54+
uv run pytest
55+
56+
lint:
57+
continue-on-error: true
58+
59+
runs-on: ubuntu-latest
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
python-version: ["3.13"]
64+
65+
steps:
66+
- uses: actions/checkout@v3
67+
68+
- name: Install uv and set the Python version
69+
uses: astral-sh/setup-uv@v7
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
73+
- name: Install dependencies
74+
run: uv sync --locked --all-extras --dev
75+
76+
- name: Lint with ruff
77+
run: uv run ruff check --output-format=github

.github/workflows/python-publish.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,24 @@ jobs:
1919
deploy:
2020

2121
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
python-version: ["3.13"]
2225

2326
steps:
2427
- uses: actions/checkout@v3
25-
- name: Set up Python
26-
uses: actions/setup-python@v3
28+
29+
- name: Install uv and set the Python version
30+
uses: astral-sh/setup-uv@v7
2731
with:
28-
python-version: '3.13.x'
32+
python-version: ${{ matrix.python-version }}
33+
2934
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install build
35+
run: uv sync --locked --all-extras --dev
36+
3337
- name: Build package
34-
run: python -m build
38+
run: uv build
39+
3540
- name: Publish package
3641
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
3742
with:

.vscode/settings.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@
66
"terminal.integrated.defaultProfile.linux": "zsh",
77
"[python]": {
88
"editor.defaultFormatter": "charliermarsh.ruff"
9-
},
10-
"ruff.lineLength": 127,
11-
"pylint.args": [
12-
"--max-line-length=127"
13-
]
9+
}
1410
}

Dockerfile.dev

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
FROM mcr.microsoft.com/devcontainers/python:1-3.13
1+
FROM ghcr.io/astral-sh/uv:0.9.30 AS uv
22

3-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3+
FROM mcr.microsoft.com/devcontainers/python:3-3.13
4+
5+
COPY --from=uv --chown=vscode: /uv /uvx /bin/
46

57
RUN \
6-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
7-
&& apt-get update \
8+
apt-get update \
89
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
910
# Additional library needed by some tests and accordingly by VScode Tests Discovery
1011
git \
@@ -13,13 +14,3 @@ RUN \
1314
&& rm -rf /var/lib/apt/lists/*
1415

1516
WORKDIR /workspaces
16-
17-
# Install Python dependencies from requirements
18-
COPY requirements.txt ./
19-
COPY requirements_test.txt ./
20-
RUN pip3 install -r requirements.txt
21-
RUN pip3 install -r requirements_test.txt
22-
RUN rm -f requirements.txt requirements_test.txt
23-
24-
# Set the default shell to bash instead of sh
25-
ENV SHELL /bin/bash

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,37 @@ omada = "tplink_omada_client.cli:main"
2727
[project.urls]
2828
"Homepage" = "https://github.com/MarkGodwin/tplink-omada-api"
2929
"Bug Tracker" = "https://github.com/MarkGodwin/tplink-omada-api/issues"
30+
31+
[dependency-groups]
32+
dev = [
33+
{include-group = "lint"},
34+
{include-group = "test"},
35+
"uv>=0.9.30",
36+
]
37+
lint = [
38+
"pylint>=4.0.4",
39+
"ruff>=0.15.0",
40+
]
41+
test = [
42+
"coverage>=7.4.4",
43+
"pytest>=9.0.0",
44+
"pytest-aiohttp>=1.0.5",
45+
]
46+
47+
[tool.ruff]
48+
line-length = 127
49+
preview = true
50+
51+
[tool.ruff.lint]
52+
extend-select = [
53+
"C90", # mccabe
54+
"E", # pycodestyle
55+
"W", # pycodestyle
56+
"F", # pyflakes
57+
]
58+
59+
[tool.ruff.lint.mccabe]
60+
max-complexity = 10
61+
62+
[tool.pylint.main]
63+
max-line-length = 127

requirements.txt

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

requirements_test.txt

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

0 commit comments

Comments
 (0)