Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ jobs:

steps:
- uses: "actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5" # v4.3.1
- uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065" # v5.6.0
- uses: "astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e" # v6
with:
enable-cache: true
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip "poetry==2.0.1"
poetry install --extras docs
run: uv sync --extra docs
- name: "Run pre-commit hooks"
run: |
poetry run pre-commit run --all-files --verbose
run: uv run pre-commit run --all-files --verbose

tests:
name: "Python ${{ matrix.python-version}} on ${{ matrix.os }}"
Expand All @@ -43,16 +41,14 @@ jobs:

steps:
- uses: "actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5" # v4.3.1
- uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065" # v5.6.0
- uses: "astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e" # v6
with:
enable-cache: true
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip "poetry==2.0.1"
poetry install --all-extras
run: uv sync --all-extras
- name: "Run tests"
run: |
poetry run pytest --cov miio --cov-report xml
run: uv run pytest --cov miio --cov-report xml
- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac" # v5.5.5
with:
Expand Down
8 changes: 4 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export NEW_RELEASE=0.5.1
2. Update the version number

```
poetry version $NEW_RELEASE
uv version $NEW_RELEASE
```

2. Generate changelog since the last release
Expand Down Expand Up @@ -43,14 +43,14 @@ git push --tags

If not done already, create an API key for pypi (https://pypi.org/manage/account/token/) and configure it:
```
poetry config pypi-token.pypi <token>
uv publish --token <token>
```

To build & release:

```bash
poetry build
poetry publish
uv build
uv publish
```

8. Click the "Draft a new release" button on github, select the new tag and copy & paste the changelog into the description.
11 changes: 5 additions & 6 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ Development environment
-----------------------

This section will shortly go through how to get you started with a working development environment.
We use `poetry <https://python-poetry.org/>`__ for managing the dependencies and packaging, so simply execute::
We use `uv <https://docs.astral.sh/uv>`__ for managing the dependencies and packaging, so simply execute::

poetry install
uv sync

If you were not already inside a virtual environment during the install,
poetry will create one for you.
You can execute commands inside this environment by using ``poetry run <command>``,
uv will create a virtual environment for you automatically.
You can execute commands inside this environment by using ``uv run <command>``,
or alternatively,
enter the virtual environment shell by executing ``poetry shell`` to avoid repeating ``poetry run``.
activate the virtual environment with ``source .venv/bin/activate`` to avoid repeating ``uv run``.

To verify the installation, you can launch tox_ to run all the checks::

Expand Down
10 changes: 5 additions & 5 deletions docs/discovery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ You can install the most recent release using pip:
pip install python-miio


Alternatively, you can clone this repository and use `poetry <https://python-poetry.org>`_ to install the current master:
Alternatively, you can clone this repository and use `uv <https://docs.astral.sh/uv>`_ to install the current master:

.. code-block:: console

git clone https://github.com/rytilahti/python-miio.git
cd python-miio/
poetry install
uv sync

This will install python-miio into a separate virtual environment outside of your regular python installation.
You can then execute installed programs (like ``miiocli``):

.. code-block:: console

poetry run miiocli --help
uv run miiocli --help

.. tip::

If you want to execute more commands in a row, you can activate the
created virtual environment to avoid typing ``poetry run`` for each
created virtual environment to avoid typing ``uv run`` for each
invocation:

.. code-block:: console

poetry shell
source .venv/bin/activate
miiocli --help
miiocli discover

Expand Down
11 changes: 8 additions & 3 deletions miio/push_server/test_serverprotocol.py
Comment thread
rytilahti marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

import pytest

from miio import Message
Expand All @@ -16,17 +18,20 @@


@pytest.fixture
def protocol(mocker, event_loop) -> ServerProtocol:
def protocol(mocker) -> ServerProtocol:
loop = asyncio.new_event_loop()
server = mocker.Mock()

# Mock server id
type(server).device_id = mocker.PropertyMock(return_value=DEVICE_ID)
socket = mocker.Mock()

proto = ServerProtocol(event_loop, socket, server)
proto = ServerProtocol(loop, socket, server)
proto.transport = mocker.Mock()

return proto
yield proto

loop.close()


def test_send_ping_ack(protocol: ServerProtocol, mocker):
Expand Down
Loading
Loading