kopia lustrzana https://github.com/Yakifo/amqtt
				
				
				
			lint and mypy cleanup and exceptions due to the need to support imports from different locations depending on python version
							rodzic
							
								
									129aa60ec9
								
							
						
					
					
						commit
						6cbc18d966
					
				|  | @ -6,7 +6,7 @@ import copy | |||
| from functools import wraps | ||||
| import logging | ||||
| import ssl | ||||
| from typing import TYPE_CHECKING, Any, cast, TypeAlias | ||||
| from typing import TYPE_CHECKING, Any, TypeAlias, cast | ||||
| from urllib.parse import urlparse, urlunparse | ||||
| 
 | ||||
| import websockets | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter | ||||
| from amqtt.codecs_amqtt import bytes_to_int, read_or_raise | ||||
| from amqtt.errors import AMQTTError | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| from asyncio import StreamReader | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter | ||||
| from amqtt.codecs_amqtt import ( | ||||
|     bytes_to_int, | ||||
|  |  | |||
|  | @ -1,13 +1,15 @@ | |||
| from abc import ABC, abstractmethod | ||||
| import asyncio | ||||
| 
 | ||||
| try: | ||||
|     from datetime import datetime, UTC | ||||
|     from datetime import UTC, datetime | ||||
| except ImportError: | ||||
|     from datetime import datetime, timezone | ||||
|     UTC = timezone.utc | ||||
| 
 | ||||
| from struct import unpack | ||||
| from typing_extensions import TypeVar, Union, Generic, Self | ||||
| from typing import Generic | ||||
| from typing_extensions import Self, TypeVar | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter, WriterAdapter | ||||
| from amqtt.codecs_amqtt import bytes_to_hex_str, decode_packet_id, int_to_bytes, read_or_raise | ||||
|  | @ -159,7 +161,7 @@ class PacketIdVariableHeader(MQTTVariableHeader): | |||
|         return f"{self.__class__.__name__}(packet_id={self.packet_id})" | ||||
| 
 | ||||
| 
 | ||||
| _VH = TypeVar("_VH", bound=Union[MQTTVariableHeader, None]) | ||||
| _VH = TypeVar("_VH", bound=MQTTVariableHeader | None) | ||||
| 
 | ||||
| 
 | ||||
| class MQTTPayload(Generic[_VH], ABC): | ||||
|  | @ -184,7 +186,7 @@ class MQTTPayload(Generic[_VH], ABC): | |||
|         pass | ||||
| 
 | ||||
| 
 | ||||
| _P = TypeVar("_P", bound=Union[MQTTPayload[MQTTVariableHeader], None]) | ||||
| _P = TypeVar("_P", bound=MQTTPayload[MQTTVariableHeader] | None) | ||||
| 
 | ||||
| 
 | ||||
| class MQTTPacket(Generic[_VH, _P, _FH]): | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.errors import AMQTTError | ||||
| from amqtt.mqtt.packet import PINGRESP, MQTTFixedHeader, MQTTPacket | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,15 +1,16 @@ | |||
| import asyncio | ||||
| 
 | ||||
| try: | ||||
|     from asyncio import InvalidStateError, QueueFull, QueueShutDown | ||||
| except ImportError: | ||||
|     """Fallback for Python < 3.12""" | ||||
|     class InvalidStateError(Exception): | ||||
|     class InvalidStateError(Exception):  #  type: ignore[no-redef] | ||||
|         pass | ||||
| 
 | ||||
|     class QueueFull(Exception): | ||||
|     class QueueFull(Exception):  #  type: ignore[no-redef]  # noqa : N818 | ||||
|         pass | ||||
| 
 | ||||
|     class QueueShutDown(Exception): | ||||
|     class QueueShutDown(Exception):  #  type: ignore[no-redef]  # noqa : N818 | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.errors import AMQTTError | ||||
| from amqtt.mqtt.packet import PUBACK, MQTTFixedHeader, MQTTPacket, PacketIdVariableHeader | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.errors import AMQTTError | ||||
| from amqtt.mqtt.packet import PUBCOMP, MQTTFixedHeader, MQTTPacket, PacketIdVariableHeader | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| import asyncio | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter | ||||
| from amqtt.codecs_amqtt import decode_packet_id, decode_string, encode_string, int_to_bytes | ||||
| from amqtt.errors import AMQTTError, MQTTError | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.errors import AMQTTError | ||||
| from amqtt.mqtt.packet import PUBREC, MQTTFixedHeader, MQTTPacket, PacketIdVariableHeader | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.errors import AMQTTError | ||||
| from amqtt.mqtt.packet import PUBREL, MQTTFixedHeader, MQTTPacket, PacketIdVariableHeader | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| import asyncio | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter | ||||
| from amqtt.codecs_amqtt import bytes_to_int, int_to_bytes, read_or_raise | ||||
| from amqtt.errors import AMQTTError, NoDataError | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| import asyncio | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter | ||||
| from amqtt.codecs_amqtt import bytes_to_int, decode_string, encode_string, int_to_bytes, read_or_raise | ||||
| from amqtt.errors import AMQTTError, NoDataError | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.errors import AMQTTError | ||||
| from amqtt.mqtt.packet import UNSUBACK, MQTTFixedHeader, MQTTPacket, PacketIdVariableHeader | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| from asyncio import StreamReader | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| from amqtt.adapters import ReaderAdapter | ||||
| from amqtt.codecs_amqtt import decode_string, encode_string | ||||
| from amqtt.errors import AMQTTError, NoDataError | ||||
|  |  | |||
|  | @ -6,11 +6,13 @@ try: | |||
| except ImportError: | ||||
|     from typing import Protocol, runtime_checkable | ||||
|     @runtime_checkable | ||||
|     class Buffer(Protocol): | ||||
|         def __buffer__(self, flags: int = ...) -> memoryview: ... | ||||
|     class Buffer(Protocol):  #  type: ignore[no-redef] | ||||
|         def __buffer__(self, flags: int = ...) -> memoryview: | ||||
|             """Mimic the behavior of `collections.abc.Buffer` for python 3.10-3.12.""" | ||||
|             ... | ||||
| 
 | ||||
| try: | ||||
|     from datetime import datetime, UTC | ||||
|     from datetime import UTC, datetime | ||||
| except ImportError: | ||||
|     from datetime import datetime, timezone | ||||
|     UTC = timezone.utc | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| try: | ||||
|     from datetime import datetime, UTC | ||||
|     from datetime import UTC, datetime | ||||
| except ImportError: | ||||
|     from datetime import datetime, timezone | ||||
|     UTC = timezone.utc | ||||
|  |  | |||
|  | @ -89,6 +89,7 @@ line-length = 130 | |||
| fix = true | ||||
| extend-exclude = ["docs/", "samples/"] | ||||
| 
 | ||||
| 
 | ||||
| [tool.ruff.format] | ||||
| indent-style = "space" | ||||
| docstring-code-format = true | ||||
|  | @ -116,6 +117,7 @@ ignore = [ | |||
|   "TD003",  # TODO Missing issue link for this TODO. | ||||
|   "ANN401", # Dynamically typed expressions (typing.Any) are disallowed | ||||
|   "ARG002", # Unused method argument | ||||
|   "PERF203" # try-except penalty within loops (3.10 only) | ||||
| ] | ||||
| 
 | ||||
| [tool.ruff.lint.per-file-ignores] | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Andrew Mirsky
						Andrew Mirsky