Skip to content

Commit c02c18d

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 1cbde70 commit c02c18d

9 files changed

Lines changed: 2150 additions & 1796 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
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 && pre-commit install-hooks",
15+
"postCreateCommand": "uv sync --all-groups && uv run prek install -f",
1616
// Configure tool-specific properties.
1717
"customizations": {
1818
"vscode": {

.github/workflows/main.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,25 @@ jobs:
2525
with:
2626
python-version: "${{ matrix.python-version }}"
2727

28-
- name: Set up Poetry
29-
uses: Gr1N/setup-poetry@v9
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
30+
with:
31+
enable-cache: true
3032

3133
- name: Cache venv
3234
uses: actions/cache@v5
3335
with:
3436
path: .venv
35-
key: venv-${{ hashFiles('**/poetry.lock') }}
37+
key: venv-${{ hashFiles('**/uv.lock') }}
3638

37-
- name: Cache pre-commit
39+
- name: Cache prek
3840
uses: actions/cache@v5
3941
with:
40-
path: ~/.cache/pre-commit/
41-
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} # yamllint disable-line
42+
path: ~/.cache/prek/
43+
key: ${{ runner.os }}-prek-${{ hashFiles('**/uv.lock') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} # yamllint disable-line
4244

4345
- name: Install dependencies
44-
run: poetry install
46+
run: uv sync --all-groups
4547

4648
- name: Register problems matchers
4749
run: |
@@ -50,5 +52,5 @@ jobs:
5052
echo "::add-matcher::.github/workflows/matchers/mypy.json"
5153
echo "::add-matcher::.github/workflows/matchers/python.json"
5254
53-
- name: Apply all pre-commit
54-
run: poetry run pre-commit run -a
55+
- name: Apply all prek hooks
56+
run: uv run prek run -a

.github/workflows/publish-pypi-test.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yamllint disable-file
2-
# This workflows will upload a Python Package
3-
# using Poetry when a release is created
2+
# This workflow will upload a Python package
3+
# using uv when a release is created
44

55
name: Publish Python Package (test)
66

@@ -18,13 +18,11 @@ jobs:
1818
uses: actions/setup-python@v6
1919
with:
2020
python-version: '3.x'
21-
- name: Set up Poetry
22-
uses: Gr1N/setup-poetry@v9
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
2323
- name: Build and publish to PyPi
2424
env:
25-
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }}
25+
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
2626
run: |
27-
poetry config http-basic.testpypi ${{ secrets.TEST_PYPI_API_TOKEN }} ""
28-
poetry build
29-
poetry config repositories.testpypi https://test.pypi.org/legacy/
30-
poetry publish -r testpypi
27+
uv build
28+
uv publish --publish-url https://test.pypi.org/legacy/

.github/workflows/release.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# This workflow will upload a Python Package using
2-
# Poetry when a release is published
1+
# This workflow will upload a Python package when a release is published
32

43
name: Publish Python Package (PyPi)
54

@@ -22,13 +21,13 @@ jobs:
2221
uses: actions/setup-python@v6
2322
with:
2423
python-version: '3.x'
25-
- name: Set up Poetry
26-
uses: Gr1N/setup-poetry@v9
27-
- name: Bump Poetry version
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v7
26+
- name: Bump project version
2827
run: |
2928
tag=${{ github.event.release.tag_name }}
3029
version_number=${tag#?}
31-
poetry version $version_number
30+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "$version_number"
3231
- name: Commit changes
3332
uses: EndBug/add-and-commit@v4
3433
with:
@@ -39,6 +38,6 @@ jobs:
3938
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4039
- name: Build package distribution
4140
run: |
42-
poetry build
41+
uv build
4342
- name: Publish package distributions to PyPI
4443
uses: pypa/gh-action-pypi-publish@release/v1

docs/testing.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ The test suite uses `pytest` with async support to validate the client's behavio
1414

1515
```bash
1616
# Run all tests
17-
poetry run pytest
17+
uv run pytest
1818

1919
# Run only unit tests
20-
poetry run pytest tests/unit/
20+
uv run pytest tests/unit/
2121

2222
# Run with coverage report
23-
poetry run pytest --cov=sagemcom_api
23+
uv run pytest --cov=sagemcom_api
2424

2525
# Run with coverage HTML report
26-
poetry run pytest --cov=sagemcom_api --cov-report=html
26+
uv run pytest --cov=sagemcom_api --cov-report=html
2727

2828
# Run specific test file
29-
poetry run pytest tests/unit/test_client_basic.py
29+
uv run pytest tests/unit/test_client_basic.py
3030

3131
# Run specific test
32-
poetry run pytest tests/unit/test_client_basic.py::test_login_success
32+
uv run pytest tests/unit/test_client_basic.py::test_login_success
3333
```
3434

3535
## Test Structure
@@ -155,7 +155,7 @@ await client.logout() # Would raise StopIteration (no 3rd response)
155155

156156
Run coverage reports regularly:
157157
```bash
158-
poetry run pytest --cov=sagemcom_api --cov-report=term-missing
158+
uv run pytest --cov=sagemcom_api --cov-report=term-missing
159159
```
160160

161161
The `--cov-report=term-missing` shows which lines lack coverage.

0 commit comments

Comments
 (0)