From 4d55d3c989f43a0b29c356072ab5a88f38663ecc Mon Sep 17 00:00:00 2001 From: toxazhl Date: Wed, 13 Mar 2024 18:55:42 +0200 Subject: [PATCH] first --- .github/workflows/publish.yml | 36 ++++ .gitignore | 26 +++ LICENSE | 21 ++ README.md | 66 +++++++ example/example.py | 52 +++++ fastmqtt/__init__.py | 12 ++ fastmqtt/exceptions.py | 2 + fastmqtt/fastmqtt.py | 159 +++++++++++++++ fastmqtt/message_handler.py | 105 ++++++++++ fastmqtt/response.py | 109 +++++++++++ fastmqtt/router.py | 85 ++++++++ fastmqtt/subscription_manager.py | 76 ++++++++ fastmqtt/utils.py | 11 ++ poetry.lock | 324 +++++++++++++++++++++++++++++++ pyproject.toml | 60 ++++++ 15 files changed, 1144 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 example/example.py create mode 100644 fastmqtt/__init__.py create mode 100644 fastmqtt/exceptions.py create mode 100644 fastmqtt/fastmqtt.py create mode 100644 fastmqtt/message_handler.py create mode 100644 fastmqtt/response.py create mode 100644 fastmqtt/router.py create mode 100644 fastmqtt/subscription_manager.py create mode 100644 fastmqtt/utils.py create mode 100644 poetry.lock create mode 100644 pyproject.toml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..747ef79 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish to PyPI + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + environment: + name: pypi + url: https://pypi.org/project/fastmqtt + permissions: + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch entire history for poetry-dynamic-versioning, see: https://github.com/mtkennerly/poetry-dynamic-versioning/issues/55 + - name: Set up Python + uses: actions/setup-python@v4 # Uses the Python version in .python-version + - name: Install poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Setup dynamic versioning + run: poetry self add "poetry-dynamic-versioning[plugin]" + - name: Build package + run: poetry build + - name: Publish to PyPI # Uses trusted publishing and thus doesn't need a token + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf5ca50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Project +.idea/ +.vscode/ +.venv/ +.tests/ +.env +.DS_Store +venv/ + +# Cache +__pycache__/ +*.py[cod] +.cache/ +.ruff_cache/ +.mypy_cache/ +.pytest_cache/ +.coverage/ + +# Build +env/ +build/ +_build/ +dist/ +site/ +*.egg-info/ +*.egg diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5308d6f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 nullmatawasoradesu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff5a6cd --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +**README.md** + +# FastMQTT + +A performant, flexible, and user-friendly MQTT client library built on top of aiomqtt. FastMQTT simplifies message handling, advanced subscriptions, and convenient request-response patterns within the MQTT protocol. + +**Key Features** + +* **Efficient Message Handling:** Streamlined asynchronous message processing. +* **Robust Router:** Define topic-based message routing with QoS, no_local, retain options. +* **Subscription Management:** Effortlessly manage subscriptions, including retained messages. +* **Request-Response Patterns:** Convenient `ResponseContext` for request-response communication over MQTT. +* **Correlation Tracking:** Automatic correlation ID generation to match responses with their requests. +* **aiomqtt Foundation:** Built upon the reliable aiomqtt library for core MQTT functionality. + +**Installation** + +```bash +pip install fastmqtt +``` + +**Basic Usage** + +```python +import asyncio +from fastmqtt import FastMQTT, MQTTRouter + +router = MQTTRouter() + +@router.on_message("my/topic") # Subscribe and handle incoming messages +async def message_handler(message: Message, properties: dict): + print(f"Message received: {message.payload.decode()} on topic {message.topic}") + +async def main(): + client = FastMQTT("mqtt.example.com", routers=[router]) + + async with client: # Connect and automatically handle subscriptions + await client.publish("my/topic", "Hello from FastMQTT!") + await asyncio.sleep(5) # Keep running for a bit + +if __name__ == "__main__": + asyncio.run(main()) +``` + +**Request-Response Example** + +```python +@router.on_message("temperature/request") +async def temp_request_handler(message: Message, properties: dict): + # Simulate getting a temperature reading + return 25 # Return the temperature + +async def main(): + client = FastMQTT("mqtt.example.com", routers=[router]) + + async with client: + async with client.response_context(f"temperature/response/{client.identifier}") as ctx: + response = await ctx.request("temperature/request") + print(f"Temperature: {response.payload.decode()}") +``` + +**Contributions** + +We welcome contributions to improve FastMQTT! Please open issues for bug reports or feature suggestions, and fork the repository to submit pull requests. + +Let me know if you'd like modifications or have specific aspects you want to emphasize in the README! diff --git a/example/example.py b/example/example.py new file mode 100644 index 0000000..ff41e9e --- /dev/null +++ b/example/example.py @@ -0,0 +1,52 @@ +import asyncio +import json +from typing import Any + +from aiomqtt import Message + +from fastmqtt import FastMQTT, MQTTRouter, Retain + +router = MQTTRouter() + + +@router.on_message("test/fastmqtt/print_message", retain_handling=Retain.DO_NOT_SEND) +async def on_print_message(message: Message, properties: dict[str, Any]): + print(f"Received message: {message.payload.decode()}") + + +@router.on_message("test/fastmqtt/process/substruction", retain_handling=Retain.DO_NOT_SEND) +async def on_process_substruction(message: Message, properties: dict[str, Any]): + payload = json.loads(message.payload) + return payload["a"] - payload["b"] + + +@router.on_message("test/fastmqtt/process/multiplication", retain_handling=Retain.DO_NOT_SEND) +async def on_process_multiplication(message: Message, properties: dict[str, Any]): + payload = json.loads(message.payload) + return payload["a"] * payload["b"] + + +async def main(): + # fastmqtt = FastMQTT("test.mosquitto.org") + # fastmqtt.include_router(router) + # async with fastmqtt: + # OR + async with FastMQTT("test.mosquitto.org", routers=[router]) as fastmqtt: + await fastmqtt.publish("test/fastmqtt/print_message", "Hello, world!") + + async with fastmqtt.response_context( + f"test/fastmqtt/process/response/{fastmqtt.identifier}" + ) as ctx: + response = await ctx.request( + "test/fastmqtt/process/substruction", json.dumps({"a": 10, "b": 5}) + ) + print(f"Substruction result: {response.payload.decode()}") + + response = await ctx.request( + "test/fastmqtt/process/multiplication", json.dumps({"a": 20, "b": 30}) + ) + print(f"Multiplication result: {response.payload.decode()}") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/fastmqtt/__init__.py b/fastmqtt/__init__.py new file mode 100644 index 0000000..f90a451 --- /dev/null +++ b/fastmqtt/__init__.py @@ -0,0 +1,12 @@ +from .exceptions import FastMQTTError +from .fastmqtt import FastMQTT +from .router import MQTTRouter +from .subscription_manager import Retain, Subscription + +__all__ = [ + "FastMQTT", + "MQTTRouter", + "FastMQTTError", + "Retain", + "Subscription", +] diff --git a/fastmqtt/exceptions.py b/fastmqtt/exceptions.py new file mode 100644 index 0000000..b0c35a4 --- /dev/null +++ b/fastmqtt/exceptions.py @@ -0,0 +1,2 @@ +class FastMQTTError(Exception): + pass diff --git a/fastmqtt/fastmqtt.py b/fastmqtt/fastmqtt.py new file mode 100644 index 0000000..a65d914 --- /dev/null +++ b/fastmqtt/fastmqtt.py @@ -0,0 +1,159 @@ +import asyncio +import logging +import ssl +from typing import Any, Callable, Iterable, Sequence + +import paho.mqtt.client as mqtt +from aiomqtt import Client as MQTTClient +from aiomqtt import ( + Message, + ProtocolVersion, + ProxySettings, + TLSParameters, + Will, +) +from aiomqtt.types import PayloadType, SocketOption +from paho.mqtt.packettypes import PacketTypes + +from .message_handler import MessageHandler +from .response import ResponseContext +from .router import MQTTRouter +from .subscription_manager import Subscription, SubscriptionManager +from .utils import properties_from_dict + +WebSocketHeaders = dict[str, str] | Callable[[dict[str, str]], dict[str, str]] + + +class FastMQTT(MQTTRouter): + def __init__( + self, + hostname: str, + port: int = 1883, + *, + username: str | None = None, + password: str | None = None, + logger: logging.Logger | None = None, + identifier: str | None = None, + queue_type: type[asyncio.Queue[Message]] | None = None, + will: Will | None = None, + clean_session: bool | None = None, + transport: str = "tcp", + timeout: float | None = None, + keepalive: int = 60, + bind_address: str = "", + bind_port: int = 0, + clean_start: int = mqtt.MQTT_CLEAN_START_FIRST_ONLY, + max_queued_incoming_messages: int | None = None, + max_queued_outgoing_messages: int | None = None, + max_inflight_messages: int | None = None, + max_concurrent_outgoing_calls: int | None = None, + properties: mqtt.Properties | None = None, + tls_context: ssl.SSLContext | None = None, + tls_params: TLSParameters | None = None, + tls_insecure: bool | None = None, + proxy: ProxySettings | None = None, + socket_options: Iterable[SocketOption] | None = None, + websocket_path: str | None = None, + websocket_headers: WebSocketHeaders | None = None, + routers: Sequence[MQTTRouter] | None = None, + ): + super().__init__() + self.client = MQTTClient( + hostname, + port, + username=username, + password=password, + logger=logger, + identifier=identifier, + queue_type=queue_type, + protocol=ProtocolVersion.V5, + will=will, + clean_session=clean_session, + transport=transport, + timeout=timeout, + keepalive=keepalive, + bind_address=bind_address, + bind_port=bind_port, + clean_start=clean_start, + max_queued_incoming_messages=max_queued_incoming_messages, + max_queued_outgoing_messages=max_queued_outgoing_messages, + max_inflight_messages=max_inflight_messages, + max_concurrent_outgoing_calls=max_concurrent_outgoing_calls, + properties=properties, + tls_context=tls_context, + tls_params=tls_params, + tls_insecure=tls_insecure, + proxy=proxy, + socket_options=socket_options, + websocket_path=websocket_path, + websocket_headers=websocket_headers, + ) + self.subscriptions_map: dict[int, Subscription] = {} + self.sub_manager = SubscriptionManager(self) + self.message_handler = MessageHandler(self) + + if routers is not None: + for router in routers: + self.include_router(router) + + @property + def identifier(self) -> str: + return self.client.identifier + + def include_router(self, router: MQTTRouter) -> None: + included_subscriptions = self.subscriptions.copy() + for router_sub in router.subscriptions: + for included_sub in included_subscriptions: + if included_sub.topic == router_sub.topic: + included_sub.callbacks.extend(router_sub.callbacks) + break + else: + self.subscriptions.append(router_sub) + + async def __aenter__(self): + await self.client.__aenter__() + await self.message_handler.__aenter__() + await self.subscribe_all() + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.client.__aexit__(exc_type, exc_value, traceback) + await self.message_handler.__aexit__(exc_type, exc_value, traceback) + + async def subscribe_all(self) -> None: + await self.sub_manager.subscribe_all() + + async def publish( + self, + topic: str, + payload: PayloadType = None, + qos: int = 0, + retain: bool = False, + properties: dict[str, Any] | None = None, + ) -> None: + mqtt_properties = None + if properties is not None: + mqtt_properties = properties_from_dict(properties, PacketTypes.PUBLISH) + + await self.client.publish( + topic=topic, + payload=payload, + qos=qos, + retain=retain, + properties=mqtt_properties, + ) + + def response_context( + self, + response_topic: str, + qos: int = 0, + default_timeout: float | None = 60, + **kwargs, + ) -> ResponseContext: + return ResponseContext( + self, + response_topic, + qos, + default_timeout, + **kwargs, + ) diff --git a/fastmqtt/message_handler.py b/fastmqtt/message_handler.py new file mode 100644 index 0000000..3f6dbfe --- /dev/null +++ b/fastmqtt/message_handler.py @@ -0,0 +1,105 @@ +import asyncio +import contextlib +import logging +from typing import TYPE_CHECKING, Any + +import aiomqtt + +from .exceptions import FastMQTTError +from .subscription_manager import Subscription + +if TYPE_CHECKING: + from .fastmqtt import FastMQTT + +log = logging.getLogger(__name__) + + +class MessageHandler: + def __init__(self, fastmqtt: "FastMQTT"): + self.fastmqtt = fastmqtt + self._messages_handler_lock = asyncio.Lock() + self._messages_handler_task = None + + async def __aenter__(self): + self._messages_handler_task = asyncio.create_task(self._messages_handler()) + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + if self._messages_handler_task is None: + return + + self._messages_handler_task.cancel() + + with contextlib.suppress(asyncio.CancelledError): + await self._messages_handler_task + + self._messages_handler_task = None + + async def _wrap_message( + self, + subscription: Subscription, + message: aiomqtt.Message, + properties: dict[str, Any], + ) -> None: + results = await asyncio.gather( + *(callback(message, properties) for callback in subscription.callbacks) + ) + response_properties = None + response_topic = properties.get("ResponseTopic") + correlation_data = properties.get("CorrelationData") + if correlation_data is not None: + correlation_data_new = bytes.fromhex(correlation_data) + response_properties = {"CorrelationData": correlation_data_new} + + if any(results) and response_topic is None: + raise FastMQTTError("Callback returned result, but message has no response_topic") + + if response_topic is not None: + for result in results: + await self.fastmqtt.publish( + response_topic, + result, + properties=response_properties, + ) + + async def _messages_handler(self) -> None: + if self._messages_handler_lock.locked(): + raise FastMQTTError("Messages handler is already running") + + async with self._messages_handler_lock: + while True: + try: + async for message in self.fastmqtt.client.messages: + if message.properties is None: + log.error("Message has no properties (%s)", message.topic) + continue + + properties = message.properties.json() + identifiers = properties.get("SubscriptionIdentifier") + if not identifiers: + log.warning( + "Message has no SubscriptionIdentifier (%s)", + message.topic, + ) + continue + + for identifier in identifiers: + subscription = self.fastmqtt.subscriptions_map.get(identifier) + + if subscription is None: + log.error( + "Message has unknown SubscriptionIdentifier %s (%s)", + identifier, + message.topic, + ) + continue + + asyncio.create_task( + self._wrap_message(subscription, message, properties) + ) + + except asyncio.CancelledError: + return + + except Exception as e: + log.exception("Error in messages handler: %s", e) diff --git a/fastmqtt/response.py b/fastmqtt/response.py new file mode 100644 index 0000000..375d551 --- /dev/null +++ b/fastmqtt/response.py @@ -0,0 +1,109 @@ +import asyncio +import itertools +from typing import TYPE_CHECKING, Any, Callable + +from aiomqtt import Message +from aiomqtt.types import PayloadType + +from .exceptions import FastMQTTError +from .subscription_manager import Retain, Subscription + +if TYPE_CHECKING: + from .fastmqtt import FastMQTT + + +class CorrelationIntGenerator: + def __init__(self, limit: int = 2**16): + self._correlation_data_counter = itertools.cycle(range(1, limit)) + + def __call__(self) -> bytes: + val = next(self._correlation_data_counter) + return val.to_bytes((val.bit_length() + 7) // 8, "big") + + +class ResponseContext: + def __init__( + self, + fastmqtt: "FastMQTT", + response_topic: str, + qos: int = 0, + default_timeout: float | None = 60, + correlation_generator: Callable[[], bytes] = CorrelationIntGenerator(), + ): + self._fastmqtt = fastmqtt + self._response_topic = response_topic + self._qos = qos + self._default_timeout = default_timeout + self._futures: dict[bytes, asyncio.Future[Message]] = {} + self._subscription: Subscription | None = None + self._identifier: int | None = None + self._correlation_generator = correlation_generator + + async def subscribe(self) -> None: + self._subscription = self._fastmqtt.register( + self._callback, + self._response_topic, + self._qos, + retain_handling=Retain.DO_NOT_SEND, + ) + self._identifier = await self._fastmqtt.sub_manager.subscribe(self._subscription) + + async def close(self) -> None: + if self._identifier is not None: + await self._fastmqtt.sub_manager.unsubscribe(self._identifier, self._callback) + + self._identifier = None + self._subscription = None + for future in self._futures.values(): + future.cancel() + + async def __aenter__(self): + await self.subscribe() + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() + + async def _callback(self, message: Message, properties: dict[str, Any]) -> None: + correlation_data = properties.get("CorrelationData") + if correlation_data is None: + raise FastMQTTError( + f"correlation_data is None in response callback ({message.topic.value})" + ) + + future = self._futures.pop(bytes.fromhex(correlation_data)) + future.set_result(message) + + async def request( + self, + topic: str, + payload: PayloadType = None, + qos: int = 0, + retain: bool = False, + properties: dict[str, Any] | None = None, + ) -> Message: + if properties is None: + properties = {} + + correlation_data = self._correlation_generator() + + properties["CorrelationData"] = correlation_data + properties["ResponseTopic"] = self._response_topic + + if correlation_data in self._futures: + raise FastMQTTError(f"correlation_data {correlation_data} already in use") + + future = asyncio.Future[Message]() + self._futures[correlation_data] = future + try: + await self._fastmqtt.publish( + topic=topic, + payload=payload, + qos=qos, + retain=retain, + properties=properties, + ) + return await future + + finally: + self._futures.pop(correlation_data, None) diff --git a/fastmqtt/router.py b/fastmqtt/router.py new file mode 100644 index 0000000..cc5b063 --- /dev/null +++ b/fastmqtt/router.py @@ -0,0 +1,85 @@ +import logging +from typing import Any, Callable + +import aiomqtt + +from .subscription_manager import ( + CallbackType, + Retain, + Subscription, +) + +log = logging.getLogger(__name__) + + +class MQTTRouter: + def __init__(self): + self.subscriptions: list[Subscription] = [] + + def _check_different(self, subscription: Subscription, **new_attrs) -> None: + for name, value in new_attrs.items(): + exist_sub_attr = getattr(subscription, name) + + if exist_sub_attr != value: + log.warning( + "Subscription %s has different %s. Existing: %s, New: %s", + subscription.topic, + name, + exist_sub_attr, + value, + ) + + def register( + self, + callback: CallbackType, + topic: str, + qos: int = 0, + no_local: bool = False, + retain_as_published: bool = False, + retain_handling: Retain = Retain.SEND_ON_SUBSCRIBE, + ) -> Subscription: + for subscription in self.subscriptions: + if str(subscription.topic) == topic: + subscription.callbacks.append(callback) + self._check_different( + subscription, + qos=qos, + no_local=no_local, + retain_as_published=retain_as_published, + retain_handling=retain_handling, + ) + return subscription + + subscription = Subscription( + [callback], + aiomqtt.Topic(topic), + qos, + no_local, + retain_as_published, + retain_handling, + ) + + self.subscriptions.append(subscription) + + return subscription + + def on_message( + self, + topic: str, + qos: int = 0, + no_local: bool = False, + retain_as_published: bool = False, + retain_handling: Retain = Retain.SEND_ON_SUBSCRIBE, + ) -> Callable[..., Any]: + def wrapper(callback: CallbackType) -> CallbackType: + self.register( + callback, + topic, + qos, + no_local, + retain_as_published, + retain_handling, + ) + return callback + + return wrapper diff --git a/fastmqtt/subscription_manager.py b/fastmqtt/subscription_manager.py new file mode 100644 index 0000000..8cd6341 --- /dev/null +++ b/fastmqtt/subscription_manager.py @@ -0,0 +1,76 @@ +import itertools +from dataclasses import dataclass +from enum import IntEnum +from typing import TYPE_CHECKING, Any, Awaitable, Callable + +import aiomqtt +from paho.mqtt.packettypes import PacketTypes +from paho.mqtt.subscribeoptions import SubscribeOptions + +from .exceptions import FastMQTTError +from .utils import properties_from_dict + +if TYPE_CHECKING: + from .fastmqtt import FastMQTT + + +CallbackType = Callable[[aiomqtt.Message, dict[str, Any]], Awaitable[Any]] + + +class Retain(IntEnum): + SEND_ON_SUBSCRIBE = 0 + SEND_IF_NEW_SUB = 1 + DO_NOT_SEND = 2 + + +@dataclass +class Subscription: + callbacks: list[CallbackType] + topic: aiomqtt.Topic + qos: int = 0 + no_local: bool = False + retain_as_published: bool = False + retain_handling: Retain = Retain.SEND_ON_SUBSCRIBE + + +class SubscriptionManager: + def __init__(self, fastmqtt: "FastMQTT"): + self.fastmqtt = fastmqtt + self.subscription_id_counter = itertools.count(1) + + async def subscribe(self, subscription: Subscription) -> int: + identifier = next(self.subscription_id_counter) + properties = properties_from_dict( + {"SubscriptionIdentifier": identifier}, + PacketTypes.SUBSCRIBE, + ) + + await self.fastmqtt.client.subscribe( + topic=subscription.topic.value, + qos=subscription.qos, + options=SubscribeOptions( + qos=subscription.qos, + noLocal=subscription.no_local, + retainAsPublished=subscription.retain_as_published, + retainHandling=subscription.retain_handling, + ), + properties=properties, + ) + self.fastmqtt.subscriptions_map[identifier] = subscription + return identifier + + async def subscribe_all(self) -> None: + for subscription in self.fastmqtt.subscriptions: + await self.subscribe(subscription) + + async def unsubscribe(self, identifier: int, callback: CallbackType | None = None) -> None: + subscription = self.fastmqtt.subscriptions_map.get(identifier) + if subscription is None: + raise FastMQTTError(f"Unknown subscription identifier {identifier}") + + if callback is not None: + subscription.callbacks.remove(callback) + + if callback is None or not subscription.callbacks: + await self.fastmqtt.client.unsubscribe(subscription.topic.value) + del self.fastmqtt.subscriptions_map[identifier] diff --git a/fastmqtt/utils.py b/fastmqtt/utils.py new file mode 100644 index 0000000..78c0e06 --- /dev/null +++ b/fastmqtt/utils.py @@ -0,0 +1,11 @@ +from typing import Any + +from paho.mqtt.properties import Properties + + +def properties_from_dict(properties: dict[str, Any], packet_type: int) -> Properties: + mqtt_properties = Properties(packet_type) + for key, value in properties.items(): + setattr(mqtt_properties, key, value) + + return mqtt_properties diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..c733e82 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,324 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "aiomqtt" +version = "2.0.0" +description = "The idiomatic asyncio MQTT client, wrapped around paho-mqtt" +optional = false +python-versions = ">=3.8,<4.0" +files = [ + {file = "aiomqtt-2.0.0-py3-none-any.whl", hash = "sha256:f3b97eca4a5a2c40769ed14f660520f733be1d2ec383a9976153fe49141e2fa2"}, + {file = "aiomqtt-2.0.0.tar.gz", hash = "sha256:3d480429334bdba4e4b9936c6cc198ea4f76a94d36cf294e0f713ec59f6a2120"}, +] + +[package.dependencies] +paho-mqtt = ">=1.6.0,<2.0.0" +typing-extensions = {version = ">=4.4.0,<5.0.0", markers = "python_version < \"3.10\""} + +[[package]] +name = "black" +version = "23.12.1" +description = "The uncompromising code formatter." +optional = false +python-versions = ">=3.8" +files = [ + {file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"}, + {file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"}, + {file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"}, + {file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"}, + {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, + {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, + {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, + {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, + {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, + {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, + {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, + {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, + {file = "black-23.12.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1fa88a0f74e50e4487477bc0bb900c6781dbddfdfa32691e780bf854c3b4a47f"}, + {file = "black-23.12.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a4d6a9668e45ad99d2f8ec70d5c8c04ef4f32f648ef39048d010b0689832ec6d"}, + {file = "black-23.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b18fb2ae6c4bb63eebe5be6bd869ba2f14fd0259bda7d18a46b764d8fb86298a"}, + {file = "black-23.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:c04b6d9d20e9c13f43eee8ea87d44156b8505ca8a3c878773f68b4e4812a421e"}, + {file = "black-23.12.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3e1b38b3135fd4c025c28c55ddfc236b05af657828a8a6abe5deec419a0b7055"}, + {file = "black-23.12.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4f0031eaa7b921db76decd73636ef3a12c942ed367d8c3841a0739412b260a54"}, + {file = "black-23.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97e56155c6b737854e60a9ab1c598ff2533d57e7506d97af5481141671abf3ea"}, + {file = "black-23.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:dd15245c8b68fe2b6bd0f32c1556509d11bb33aec9b5d0866dd8e2ed3dba09c2"}, + {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, + {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, +] + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +packaging = ">=22.0" +pathspec = ">=0.9.0" +platformdirs = ">=2" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + +[[package]] +name = "click" +version = "8.1.7" +description = "Composable command line interface toolkit" +optional = false +python-versions = ">=3.7" +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "libcst" +version = "1.1.0" +description = "A concrete syntax tree with AST-like properties for Python 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10 programs." +optional = false +python-versions = ">=3.8" +files = [ + {file = "libcst-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:63f75656fd733dc20354c46253fde3cf155613e37643c3eaf6f8818e95b7a3d1"}, + {file = "libcst-1.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8ae11eb1ea55a16dc0cdc61b41b29ac347da70fec14cc4381248e141ee2fbe6c"}, + {file = "libcst-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4bc745d0c06420fe2644c28d6ddccea9474fb68a2135904043676deb4fa1e6bc"}, + {file = "libcst-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c1f2da45f1c45634090fd8672c15e0159fdc46853336686959b2d093b6e10fa"}, + {file = "libcst-1.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:003e5e83a12eed23542c4ea20fdc8de830887cc03662432bb36f84f8c4841b81"}, + {file = "libcst-1.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:3ebbb9732ae3cc4ae7a0e97890bed0a57c11d6df28790c2b9c869f7da653c7c7"}, + {file = "libcst-1.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d68c34e3038d3d1d6324eb47744cbf13f2c65e1214cf49db6ff2a6603c1cd838"}, + {file = "libcst-1.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9dffa1795c2804d183efb01c0f1efd20a7831db6a21a0311edf90b4100d67436"}, + {file = "libcst-1.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc9b6ac36d7ec9db2f053014ea488086ca2ed9c322be104fbe2c71ca759da4bb"}, + {file = "libcst-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78b7a38ec4c1c009ac39027d51558b52851fb9234669ba5ba62283185963a31c"}, + {file = "libcst-1.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5297a16e575be8173185e936b7765c89a3ca69d4ae217a4af161814a0f9745a7"}, + {file = "libcst-1.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:7ccaf53925f81118aeaadb068a911fac8abaff608817d7343da280616a5ca9c1"}, + {file = "libcst-1.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:75816647736f7e09c6120bdbf408456f99b248d6272277eed9a58cf50fb8bc7d"}, + {file = "libcst-1.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c8f26250f87ca849a7303ed7a4fd6b2c7ac4dec16b7d7e68ca6a476d7c9bfcdb"}, + {file = "libcst-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d37326bd6f379c64190a28947a586b949de3a76be00176b0732c8ee87d67ebe"}, + {file = "libcst-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3d8cf974cfa2487b28f23f56c4bff90d550ef16505e58b0dca0493d5293784b"}, + {file = "libcst-1.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82d1271403509b0a4ee6ff7917c2d33b5a015f44d1e208abb1da06ba93b2a378"}, + {file = "libcst-1.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:bca1841693941fdd18371824bb19a9702d5784cd347cb8231317dbdc7062c5bc"}, + {file = "libcst-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f36f592e035ef84f312a12b75989dde6a5f6767fe99146cdae6a9ee9aff40dd0"}, + {file = "libcst-1.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f561c9a84eca18be92f4ad90aa9bd873111efbea995449301719a1a7805dbc5c"}, + {file = "libcst-1.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:97fbc73c87e9040e148881041fd5ffa2a6ebf11f64b4ccb5b52e574b95df1a15"}, + {file = "libcst-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99fdc1929703fd9e7408aed2e03f58701c5280b05c8911753a8d8619f7dfdda5"}, + {file = "libcst-1.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bf69cbbab5016d938aac4d3ae70ba9ccb3f90363c588b3b97be434e6ba95403"}, + {file = "libcst-1.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:fe41b33aa73635b1651f64633f429f7aa21f86d2db5748659a99d9b7b1ed2a90"}, + {file = "libcst-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:73c086705ed34dbad16c62c9adca4249a556c1b022993d511da70ea85feaf669"}, + {file = "libcst-1.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3a07ecfabbbb8b93209f952a365549e65e658831e9231649f4f4e4263cad24b1"}, + {file = "libcst-1.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c653d9121d6572d8b7f8abf20f88b0a41aab77ff5a6a36e5a0ec0f19af0072e8"}, + {file = "libcst-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f1cd308a4c2f71d5e4eec6ee693819933a03b78edb2e4cc5e3ad1afd5fb3f07"}, + {file = "libcst-1.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8afb6101b8b3c86c5f9cec6b90ab4da16c3c236fe7396f88e8b93542bb341f7c"}, + {file = "libcst-1.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:d22d1abfe49aa60fc61fa867e10875a9b3024ba5a801112f4d7ba42d8d53242e"}, + {file = "libcst-1.1.0.tar.gz", hash = "sha256:0acbacb9a170455701845b7e940e2d7b9519db35a86768d86330a0b0deae1086"}, +] + +[package.dependencies] +pyyaml = ">=5.2" +typing-extensions = ">=3.7.4.2" +typing-inspect = ">=0.4.0" + +[package.extras] +dev = ["Sphinx (>=5.1.1)", "black (==23.9.1)", "build (>=0.10.0)", "coverage (>=4.5.4)", "fixit (==2.0.0.post1)", "flake8 (>=3.7.8,<5)", "hypothesis (>=4.36.0)", "hypothesmith (>=0.0.4)", "jinja2 (==3.1.2)", "jupyter (>=1.0.0)", "maturin (>=0.8.3,<0.16)", "nbsphinx (>=0.4.2)", "prompt-toolkit (>=2.0.9)", "pyre-check (==0.9.18)", "setuptools-rust (>=1.5.2)", "setuptools-scm (>=6.0.1)", "slotscheck (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "ufmt (==2.2.0)", "usort (==1.0.7)"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + +[[package]] +name = "packaging" +version = "24.0" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, + {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, +] + +[[package]] +name = "paho-mqtt" +version = "1.6.1" +description = "MQTT version 5.0/3.1.1 client class" +optional = false +python-versions = "*" +files = [ + {file = "paho-mqtt-1.6.1.tar.gz", hash = "sha256:2a8291c81623aec00372b5a85558a372c747cbca8e9934dfe218638b8eefc26f"}, +] + +[package.extras] +proxy = ["PySocks"] + +[[package]] +name = "pathspec" +version = "0.12.1" +description = "Utility library for gitignore style pattern matching of file paths." +optional = false +python-versions = ">=3.8" +files = [ + {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, + {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, +] + +[[package]] +name = "platformdirs" +version = "4.2.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, + {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] + +[[package]] +name = "pyyaml" +version = "6.0.1" +description = "YAML parser and emitter for Python" +optional = false +python-versions = ">=3.6" +files = [ + {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, + {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, + {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, + {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, + {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, + {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, + {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, + {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, + {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, + {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, + {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, + {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, + {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, +] + +[[package]] +name = "ruff" +version = "0.1.15" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:5fe8d54df166ecc24106db7dd6a68d44852d14eb0729ea4672bb4d96c320b7df"}, + {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f0bfbb53c4b4de117ac4d6ddfd33aa5fc31beeaa21d23c45c6dd249faf9126f"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0d432aec35bfc0d800d4f70eba26e23a352386be3a6cf157083d18f6f5881c8"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9405fa9ac0e97f35aaddf185a1be194a589424b8713e3b97b762336ec79ff807"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66ec24fe36841636e814b8f90f572a8c0cb0e54d8b5c2d0e300d28a0d7bffec"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6f8ad828f01e8dd32cc58bc28375150171d198491fc901f6f98d2a39ba8e3ff5"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86811954eec63e9ea162af0ffa9f8d09088bab51b7438e8b6488b9401863c25e"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd4025ac5e87d9b80e1f300207eb2fd099ff8200fa2320d7dc066a3f4622dc6b"}, + {file = "ruff-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b17b93c02cdb6aeb696effecea1095ac93f3884a49a554a9afa76bb125c114c1"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ddb87643be40f034e97e97f5bc2ef7ce39de20e34608f3f829db727a93fb82c5"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:abf4822129ed3a5ce54383d5f0e964e7fef74a41e48eb1dfad404151efc130a2"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6c629cf64bacfd136c07c78ac10a54578ec9d1bd2a9d395efbee0935868bf852"}, + {file = "ruff-0.1.15-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1bab866aafb53da39c2cadfb8e1c4550ac5340bb40300083eb8967ba25481447"}, + {file = "ruff-0.1.15-py3-none-win32.whl", hash = "sha256:2417e1cb6e2068389b07e6fa74c306b2810fe3ee3476d5b8a96616633f40d14f"}, + {file = "ruff-0.1.15-py3-none-win_amd64.whl", hash = "sha256:3837ac73d869efc4182d9036b1405ef4c73d9b1f88da2413875e34e0d6919587"}, + {file = "ruff-0.1.15-py3-none-win_arm64.whl", hash = "sha256:9a933dfb1c14ec7a33cceb1e49ec4a16b51ce3c20fd42663198746efc0427360"}, + {file = "ruff-0.1.15.tar.gz", hash = "sha256:f6dfa8c1b21c913c326919056c390966648b680966febcb796cc9d1aaab8564e"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[[package]] +name = "typing-extensions" +version = "4.10.0" +description = "Backported and Experimental Type Hints for Python 3.8+" +optional = false +python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, + {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, +] + +[[package]] +name = "typing-inspect" +version = "0.9.0" +description = "Runtime inspection utilities for typing module." +optional = false +python-versions = "*" +files = [ + {file = "typing_inspect-0.9.0-py3-none-any.whl", hash = "sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f"}, + {file = "typing_inspect-0.9.0.tar.gz", hash = "sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78"}, +] + +[package.dependencies] +mypy-extensions = ">=0.3.0" +typing-extensions = ">=3.7.4" + +[metadata] +lock-version = "2.0" +python-versions = "^3.8" +content-hash = "be97840a0e4327dccf665782bc03657eff1787ed8df3c883080474e121a7defd" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3f9aa90 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[tool.poetry] +name = "fastmqtt" +version = "0.1.0" +description = "" +authors = ["toxazhl "] +readme = "README.md" +repository = "https://github.com/toxazhl/fastmqtt" + +[tool.poetry.dependencies] +python = "^3.8" +aiomqtt = "^2.0.0" + +[tool.poetry.dev-dependencies] +libcst = "^1.1.0" +black = "^23.12.1" +ruff = "^0.1.14" + +[tool.black] +line_length = 99 +exclude = "\\.?venv|\\.?tests|\\.cache" + + +[tool.ruff] +target-version = "py38" +line-length = 99 +select = [ + "C", + "DTZ", + "E", + "F", + "I", + "ICN", + "ISC", + "N", + "PLC", + "PLE", + "Q", + "S", + "T", + "W", + "YTT", + "RET", + "SIM", + "ASYNC", +] +exclude = [ + ".git", + ".venv", + ".idea", + ".tests", + ".cache", + "build", + "dist", + "scripts", +] + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"