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
4 changes: 1 addition & 3 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/5811f4817ba24da923506d134fff2610b8f95ff2/direnvrc" "sha256-IN2rc7pbaBxxjcdIpYOe9lkpiyjSr2V2AwF6KwlnWYQ="

use devenv
use flake
3 changes: 1 addition & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ jobs:
max-parallel: 5
matrix:
python-version:
- 3.7
- 3.8
- 3.9
- "3.10"
- 3.11
- 3.12

steps:
- uses: actions/checkout@v1
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ jobs:
max-parallel: 5
matrix:
python-version:
- 3.7
- 3.8
- 3.9
- "3.10"
- 3.10
- 3.11
- 3.12

steps:
- uses: actions/checkout@v1
Expand Down Expand Up @@ -58,4 +57,4 @@ jobs:
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
password: ${{ secrets.pypi_password }}
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

138 changes: 0 additions & 138 deletions devenv.lock

This file was deleted.

4 changes: 0 additions & 4 deletions devenv.nix

This file was deleted.

3 changes: 0 additions & 3 deletions devenv.yaml

This file was deleted.

59 changes: 59 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
inputs = {
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
python3Packages.tox
python39
python310
python311
python312
];
};
}
);
}
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[tool.black]
target-version = ["py34", "py35", "py36", "py37", "py38"]

[tool.pyright]
venvPath = "."
venv = ".tox/py311"
6 changes: 2 additions & 4 deletions rflink/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import asyncio
import logging
import sys
from importlib.metadata import version
from typing import Dict, Optional, Sequence, Type # noqa: unused-import

import pkg_resources
from docopt import docopt

from .protocol import ( # noqa: unused-import
Expand Down Expand Up @@ -54,9 +54,7 @@ def main(
argv: Sequence[str] = sys.argv[1:], loop: Optional[asyncio.AbstractEventLoop] = None
) -> None:
"""Parse argument and setup main program loop."""
args = docopt(
__doc__, argv=argv, version=pkg_resources.require("rflink")[0].version
)
args = docopt(__doc__, argv=argv, version=version("rflink"))

level = logging.ERROR
if args["-v"]:
Expand Down
21 changes: 9 additions & 12 deletions rflink/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@
import asyncio
import concurrent
import logging
import socket
from datetime import timedelta
from fnmatch import fnmatchcase
from functools import partial
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
overload,
)

import socket

from serial_asyncio_fast import create_serial_connection

from .parser import (
Expand Down Expand Up @@ -240,9 +237,7 @@ def handle_response_packet(self, packet: PacketType) -> None:
self._last_ack = packet
self._command_ack.set()

async def send_command_ack(
self, device_id: str, action: str
) -> Generator[Any, None, Optional[bool]]:
async def send_command_ack(self, device_id: str, action: str) -> "bool | None":
"""Send command, wait for gateway to repond with acknowledgment."""
# serialize commands
await self._ready_to_send.acquire()
Expand Down Expand Up @@ -396,7 +391,7 @@ def create_rflink_connection(
disconnect_callback: Optional[Callable[[Optional[Exception]], None]] = None,
ignore: Optional[Sequence[str]] = None,
loop: Optional[asyncio.AbstractEventLoop] = None,
) -> "Coroutine[Any, Any, Tuple[asyncio.BaseTransport, ProtocolBase]]":
) -> "Coroutine[Any, Any, tuple[asyncio.Transport, asyncio.Protocol]]":
"""Create Rflink manager class, returns transport coroutine."""
...

Expand All @@ -413,7 +408,7 @@ def create_rflink_connection(
disconnect_callback: Optional[Callable[[Optional[Exception]], None]] = None,
ignore: Optional[Sequence[str]] = None,
loop: Optional[asyncio.AbstractEventLoop] = None,
) -> "Coroutine[Any, Any, Tuple[asyncio.BaseTransport, ProtocolBase]]":
) -> "Coroutine[Any, Any, tuple[asyncio.Transport, asyncio.Protocol]]":
"""Create Rflink manager class, returns transport coroutine."""
...

Expand All @@ -429,7 +424,7 @@ def create_rflink_connection(
disconnect_callback: Optional[Callable[[Optional[Exception]], None]] = None,
ignore: Optional[Sequence[str]] = None,
loop: Optional[asyncio.AbstractEventLoop] = None,
) -> "Coroutine[Any, Any, Tuple[asyncio.BaseTransport, ProtocolBase]]":
) -> "Coroutine[Any, Any, tuple[asyncio.Transport, asyncio.Protocol]]":
"""Create Rflink manager class, returns transport coroutine."""
if loop is None:
loop = asyncio.get_event_loop()
Expand All @@ -444,10 +439,12 @@ def create_rflink_connection(
keepalive=keepalive,
)

conn: Coroutine[Any, Any, tuple[asyncio.Transport, asyncio.Protocol]]

# setup serial connection if no transport specified
if host:
conn = loop.create_connection(protocol_factory, host, cast(int, port))
else:
conn = create_serial_connection(loop, protocol_factory, port, baud)
conn = create_serial_connection(loop, protocol_factory, str(port), baud)

return conn # type: ignore
return conn
Loading