From 1a275c77fa4b97f5083dd7f82b857c3dd57d49db Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Mon, 10 Oct 2022 22:12:03 +0200 Subject: [PATCH 1/7] Fix paho-mqtt typing errors --- stubs/paho-mqtt/paho/mqtt/client.pyi | 38 +++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/stubs/paho-mqtt/paho/mqtt/client.pyi b/stubs/paho-mqtt/paho/mqtt/client.pyi index 306b43a33564..d0e9de5a9370 100644 --- a/stubs/paho-mqtt/paho/mqtt/client.pyi +++ b/stubs/paho-mqtt/paho/mqtt/client.pyi @@ -4,7 +4,7 @@ import ssl as _ssl import time import types from collections.abc import Callable, Iterable -from typing import Any, TypeVar +from typing import Any, Optional from typing_extensions import TypeAlias from .matcher import MQTTMatcher as MQTTMatcher @@ -90,28 +90,24 @@ _Socket: TypeAlias = _socket.socket | _ssl.SSLSocket | Any _Payload: TypeAlias = str | bytes | bytearray | float _ExtraHeader: TypeAlias = dict[str, str] | Callable[[dict[str, str]], dict[str, str]] _OnLog: TypeAlias = Callable[[Client, _UserData, int, str], object] -_OnConnect = TypeVar( - "_OnConnect", - Callable[[Client, _UserData, dict[str, int], int], object], - Callable[[Client, _UserData, dict[str, int], ReasonCodes, Properties | None], object], +_OnConnect: TypeAlias = ( + Callable[[Client, _UserData, dict[str, int], int], object] + | Callable[[Client, _UserData, dict[str, int], ReasonCodes, Optional[Properties]], object] ) _OnConnectFail: TypeAlias = Callable[[Client, _UserData], object] -_OnSubscribe = TypeVar( - "_OnSubscribe", - Callable[[Client, _UserData, int, Iterable[int]], object], - Callable[[Client, _UserData, Iterable[ReasonCodes], Iterable[Properties]], object], +_OnSubscribe: TypeAlias = ( + Callable[[Client, _UserData, int, Iterable[int]], object] + | Callable[[Client, _UserData, int, Iterable[ReasonCodes], Iterable[Properties]], object] ) _OnMessage: TypeAlias = Callable[[Client, _UserData, MQTTMessage], object] _OnPublish: TypeAlias = Callable[[Client, _UserData, int], object] -_OnUnsubscribe = TypeVar( - "_OnUnsubscribe", - Callable[[Client, _UserData, int], object], - Callable[[Client, _UserData, int, Iterable[Properties], Iterable[ReasonCodes]], object], +_OnUnsubscribe: TypeAlias = ( + Callable[[Client, _UserData, int], object] + | Callable[[Client, _UserData, int, Iterable[Properties], Iterable[ReasonCodes]], object] ) -_OnDisconnect = TypeVar( - "_OnDisconnect", - Callable[[Client, _UserData, int], object], - Callable[[Client, _UserData, int, ReasonCodes | None, Properties | None], object], +_OnDisconnect: TypeAlias = ( + Callable[[Client, _UserData, int], object] + | Callable[[Client, _UserData, int, Optional[ReasonCodes], Optional[Properties]], object] ) _OnSocket: TypeAlias = Callable[[Client, _UserData, _Socket | WebsocketWrapper | None], object] @@ -155,7 +151,7 @@ class Client: suppress_exceptions: bool def __init__( self, - client_id: str = ..., + client_id: str | None = ..., clean_session: bool | None = ..., userdata: _UserData | None = ..., protocol: int = ..., @@ -177,7 +173,7 @@ class Client: keyfile_password: _ssl._PasswordType | None = ..., ) -> None: ... def tls_insecure_set(self, value: bool) -> None: ... - def proxy_set(self, **proxy_args: str | int) -> None: ... + def proxy_set(self, **proxy_args: Any) -> None: ... def enable_logger(self, logger: logging.Logger | None = ...) -> None: ... def disable_logger(self) -> None: ... def connect( @@ -314,7 +310,9 @@ class WebsocketWrapper: OPCODE_PING: int OPCODE_PONG: int connected: bool - def __init__(self, socket: _Socket, host: str, port: int, is_ssl: bool, path: str, extra_headers: _ExtraHeader) -> None: ... + def __init__( + self, socket: _Socket, host: str, port: int, is_ssl: bool, path: str, extra_headers: _ExtraHeader | None + ) -> None: ... def __del__(self) -> None: ... def recv(self, length: int) -> bytes | bytearray | None: ... def read(self, length: int) -> bytes | bytearray | None: ... From 586aad3abcc1eb919d3e4f66031cee0766725026 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Tue, 11 Oct 2022 08:24:00 +0200 Subject: [PATCH 2/7] Use TypeVar instead of Union with the decorators --- stubs/paho-mqtt/paho/mqtt/client.pyi | 62 +++++++++++++--------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/stubs/paho-mqtt/paho/mqtt/client.pyi b/stubs/paho-mqtt/paho/mqtt/client.pyi index d0e9de5a9370..bbd20ea157e9 100644 --- a/stubs/paho-mqtt/paho/mqtt/client.pyi +++ b/stubs/paho-mqtt/paho/mqtt/client.pyi @@ -4,7 +4,7 @@ import ssl as _ssl import time import types from collections.abc import Callable, Iterable -from typing import Any, Optional +from typing import Any, Optional, TypeVar from typing_extensions import TypeAlias from .matcher import MQTTMatcher as MQTTMatcher @@ -90,25 +90,21 @@ _Socket: TypeAlias = _socket.socket | _ssl.SSLSocket | Any _Payload: TypeAlias = str | bytes | bytearray | float _ExtraHeader: TypeAlias = dict[str, str] | Callable[[dict[str, str]], dict[str, str]] _OnLog: TypeAlias = Callable[[Client, _UserData, int, str], object] -_OnConnect: TypeAlias = ( - Callable[[Client, _UserData, dict[str, int], int], object] - | Callable[[Client, _UserData, dict[str, int], ReasonCodes, Optional[Properties]], object] -) +_OnConnect: TypeAlias = Callable[[Client, _UserData, dict[str, int], int], object] +_OnConnectV5: TypeAlias = Callable[[Client, _UserData, dict[str, int], ReasonCodes, Optional[Properties]], object] +_TOnConnect = TypeVar("_TOnConnect", _OnConnect, _OnConnectV5) _OnConnectFail: TypeAlias = Callable[[Client, _UserData], object] -_OnSubscribe: TypeAlias = ( - Callable[[Client, _UserData, int, Iterable[int]], object] - | Callable[[Client, _UserData, int, Iterable[ReasonCodes], Iterable[Properties]], object] -) +_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, Iterable[int]], object] +_OnSubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Iterable[ReasonCodes], Iterable[Properties]], object] +_TOnSubscribe = TypeVar("_TOnSubscribe", _OnSubscribe, _OnSubscribeV5) _OnMessage: TypeAlias = Callable[[Client, _UserData, MQTTMessage], object] _OnPublish: TypeAlias = Callable[[Client, _UserData, int], object] -_OnUnsubscribe: TypeAlias = ( - Callable[[Client, _UserData, int], object] - | Callable[[Client, _UserData, int, Iterable[Properties], Iterable[ReasonCodes]], object] -) -_OnDisconnect: TypeAlias = ( - Callable[[Client, _UserData, int], object] - | Callable[[Client, _UserData, int, Optional[ReasonCodes], Optional[Properties]], object] -) +_OnUnsubscribe: TypeAlias = Callable[[Client, _UserData, int], object] +_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Iterable[Properties], Iterable[ReasonCodes]], object] +_TOnUnsubscribe = TypeVar("_TOnUnsubscribe", _OnUnsubscribe, _OnUnsubscribeV5) +_OnDisconnect: TypeAlias = Callable[[Client, _UserData, int], object] +_OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, int, Optional[ReasonCodes], Optional[Properties]], object] +_TOnDisconnect = TypeVar("_TOnDisconnect", _OnDisconnect, _OnDisconnectV5) _OnSocket: TypeAlias = Callable[[Client, _UserData, _Socket | WebsocketWrapper | None], object] class WebsocketConnectionError(ValueError): ... @@ -244,20 +240,20 @@ class Client: def on_log(self, func: _OnLog) -> None: ... def log_callback(self) -> Callable[[_OnLog], _OnLog]: ... @property - def on_connect(self) -> _OnConnect | None: ... + def on_connect(self) -> _OnConnect | _OnConnectV5 | None: ... @on_connect.setter - def on_connect(self, func: _OnConnect) -> None: ... - def connect_callback(self) -> Callable[[_OnConnect], _OnConnect]: ... + def on_connect(self, func: _OnConnect | _OnConnectV5) -> None: ... + def connect_callback(self) -> Callable[[_TOnConnect], _TOnConnect]: ... @property def on_connect_fail(self) -> _OnConnectFail | None: ... @on_connect_fail.setter def on_connect_fail(self, func: _OnConnectFail) -> None: ... def connect_fail_callback(self) -> Callable[[_OnConnectFail], _OnConnectFail]: ... @property - def on_subscribe(self) -> _OnSubscribe | None: ... + def on_subscribe(self) -> _OnSubscribe | _OnSubscribeV5 | None: ... @on_subscribe.setter - def on_subscribe(self, func: _OnSubscribe) -> None: ... - def subscribe_callback(self) -> Callable[[_OnSubscribe], _OnSubscribe]: ... + def on_subscribe(self, func: _OnSubscribe | _OnSubscribeV5) -> None: ... + def subscribe_callback(self) -> Callable[[_TOnSubscribe], _TOnSubscribe]: ... @property def on_message(self) -> _OnMessage | None: ... @on_message.setter @@ -269,32 +265,32 @@ class Client: def on_publish(self, func: _OnPublish) -> None: ... def publish_callback(self) -> Callable[[_OnPublish], _OnPublish]: ... @property - def on_unsubscribe(self) -> _OnUnsubscribe | None: ... + def on_unsubscribe(self) -> _OnUnsubscribe | _OnUnsubscribeV5 | None: ... @on_unsubscribe.setter - def on_unsubscribe(self, func: _OnUnsubscribe) -> None: ... - def unsubscribe_callback(self) -> Callable[[_OnUnsubscribe], _OnUnsubscribe]: ... + def on_unsubscribe(self, func: _OnUnsubscribe | _OnUnsubscribeV5) -> None: ... + def unsubscribe_callback(self) -> Callable[[_TOnUnsubscribe], _TOnUnsubscribe]: ... @property - def on_disconnect(self) -> _OnDisconnect: ... + def on_disconnect(self) -> _OnDisconnect | _OnDisconnectV5 | None: ... @on_disconnect.setter - def on_disconnect(self, func: _OnDisconnect) -> None: ... - def disconnect_callback(self) -> Callable[[_OnDisconnect], _OnDisconnect]: ... + def on_disconnect(self, func: _OnDisconnect | _OnDisconnectV5) -> None: ... + def disconnect_callback(self) -> Callable[[_TOnDisconnect], _TOnDisconnect]: ... @property - def on_socket_open(self) -> _OnSocket: ... + def on_socket_open(self) -> _OnSocket | None: ... @on_socket_open.setter def on_socket_open(self, func: _OnSocket) -> None: ... def socket_open_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... @property - def on_socket_close(self) -> _OnSocket: ... + def on_socket_close(self) -> _OnSocket | None: ... @on_socket_close.setter def on_socket_close(self, func: _OnSocket) -> None: ... def socket_close_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... @property - def on_socket_register_write(self) -> _OnSocket: ... + def on_socket_register_write(self) -> _OnSocket | None: ... @on_socket_register_write.setter def on_socket_register_write(self, func: _OnSocket) -> None: ... def socket_register_write_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... @property - def on_socket_unregister_write(self) -> _OnSocket: ... + def on_socket_unregister_write(self) -> _OnSocket | None: ... @on_socket_unregister_write.setter def on_socket_unregister_write(self, func: _OnSocket) -> None: ... def socket_unregister_write_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... From 9d3e42ac885e33ad7f9240cf24907efd0c59980a Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Tue, 11 Oct 2022 08:45:23 +0200 Subject: [PATCH 3/7] Add None to handler setter --- stubs/paho-mqtt/paho/mqtt/client.pyi | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/stubs/paho-mqtt/paho/mqtt/client.pyi b/stubs/paho-mqtt/paho/mqtt/client.pyi index bbd20ea157e9..e097fee89678 100644 --- a/stubs/paho-mqtt/paho/mqtt/client.pyi +++ b/stubs/paho-mqtt/paho/mqtt/client.pyi @@ -237,62 +237,62 @@ class Client: @property def on_log(self) -> _OnLog | None: ... @on_log.setter - def on_log(self, func: _OnLog) -> None: ... + def on_log(self, func: _OnLog | None) -> None: ... def log_callback(self) -> Callable[[_OnLog], _OnLog]: ... @property def on_connect(self) -> _OnConnect | _OnConnectV5 | None: ... @on_connect.setter - def on_connect(self, func: _OnConnect | _OnConnectV5) -> None: ... + def on_connect(self, func: _OnConnect | _OnConnectV5 | None) -> None: ... def connect_callback(self) -> Callable[[_TOnConnect], _TOnConnect]: ... @property def on_connect_fail(self) -> _OnConnectFail | None: ... @on_connect_fail.setter - def on_connect_fail(self, func: _OnConnectFail) -> None: ... + def on_connect_fail(self, func: _OnConnectFail | None) -> None: ... def connect_fail_callback(self) -> Callable[[_OnConnectFail], _OnConnectFail]: ... @property def on_subscribe(self) -> _OnSubscribe | _OnSubscribeV5 | None: ... @on_subscribe.setter - def on_subscribe(self, func: _OnSubscribe | _OnSubscribeV5) -> None: ... + def on_subscribe(self, func: _OnSubscribe | _OnSubscribeV5 | None) -> None: ... def subscribe_callback(self) -> Callable[[_TOnSubscribe], _TOnSubscribe]: ... @property def on_message(self) -> _OnMessage | None: ... @on_message.setter - def on_message(self, func: _OnMessage) -> None: ... + def on_message(self, func: _OnMessage | None) -> None: ... def message_callback(self) -> Callable[[_OnMessage], _OnMessage]: ... @property def on_publish(self) -> _OnPublish | None: ... @on_publish.setter - def on_publish(self, func: _OnPublish) -> None: ... + def on_publish(self, func: _OnPublish | None) -> None: ... def publish_callback(self) -> Callable[[_OnPublish], _OnPublish]: ... @property def on_unsubscribe(self) -> _OnUnsubscribe | _OnUnsubscribeV5 | None: ... @on_unsubscribe.setter - def on_unsubscribe(self, func: _OnUnsubscribe | _OnUnsubscribeV5) -> None: ... + def on_unsubscribe(self, func: _OnUnsubscribe | _OnUnsubscribeV5 | None) -> None: ... def unsubscribe_callback(self) -> Callable[[_TOnUnsubscribe], _TOnUnsubscribe]: ... @property def on_disconnect(self) -> _OnDisconnect | _OnDisconnectV5 | None: ... @on_disconnect.setter - def on_disconnect(self, func: _OnDisconnect | _OnDisconnectV5) -> None: ... + def on_disconnect(self, func: _OnDisconnect | _OnDisconnectV5 | None) -> None: ... def disconnect_callback(self) -> Callable[[_TOnDisconnect], _TOnDisconnect]: ... @property def on_socket_open(self) -> _OnSocket | None: ... @on_socket_open.setter - def on_socket_open(self, func: _OnSocket) -> None: ... + def on_socket_open(self, func: _OnSocket | None) -> None: ... def socket_open_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... @property def on_socket_close(self) -> _OnSocket | None: ... @on_socket_close.setter - def on_socket_close(self, func: _OnSocket) -> None: ... + def on_socket_close(self, func: _OnSocket | None) -> None: ... def socket_close_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... @property def on_socket_register_write(self) -> _OnSocket | None: ... @on_socket_register_write.setter - def on_socket_register_write(self, func: _OnSocket) -> None: ... + def on_socket_register_write(self, func: _OnSocket | None) -> None: ... def socket_register_write_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... @property def on_socket_unregister_write(self) -> _OnSocket | None: ... @on_socket_unregister_write.setter - def on_socket_unregister_write(self, func: _OnSocket) -> None: ... + def on_socket_unregister_write(self, func: _OnSocket | None) -> None: ... def socket_unregister_write_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... def message_callback_add(self, sub: str, callback: _OnMessage) -> None: ... def topic_callback(self, sub: str) -> Callable[[_OnMessage], _OnMessage]: ... From e07cf4e714b0c865a1e8295d0c72d910e7197579 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Tue, 11 Oct 2022 09:26:03 +0200 Subject: [PATCH 4/7] Fix _OndisconnectV5 --- stubs/paho-mqtt/paho/mqtt/client.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/paho-mqtt/paho/mqtt/client.pyi b/stubs/paho-mqtt/paho/mqtt/client.pyi index e097fee89678..2337054e48e2 100644 --- a/stubs/paho-mqtt/paho/mqtt/client.pyi +++ b/stubs/paho-mqtt/paho/mqtt/client.pyi @@ -103,7 +103,7 @@ _OnUnsubscribe: TypeAlias = Callable[[Client, _UserData, int], object] _OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Iterable[Properties], Iterable[ReasonCodes]], object] _TOnUnsubscribe = TypeVar("_TOnUnsubscribe", _OnUnsubscribe, _OnUnsubscribeV5) _OnDisconnect: TypeAlias = Callable[[Client, _UserData, int], object] -_OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, int, Optional[ReasonCodes], Optional[Properties]], object] +_OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, Optional[ReasonCodes], Optional[Properties]], object] _TOnDisconnect = TypeVar("_TOnDisconnect", _OnDisconnect, _OnDisconnectV5) _OnSocket: TypeAlias = Callable[[Client, _UserData, _Socket | WebsocketWrapper | None], object] From 6b1c967cfec9cbb78d622968e6f37ab452b6f3b9 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Tue, 11 Oct 2022 10:25:53 +0200 Subject: [PATCH 5/7] Use Tuple and List instead of Iterable --- stubs/paho-mqtt/paho/mqtt/client.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stubs/paho-mqtt/paho/mqtt/client.pyi b/stubs/paho-mqtt/paho/mqtt/client.pyi index 2337054e48e2..e1bea28b65a1 100644 --- a/stubs/paho-mqtt/paho/mqtt/client.pyi +++ b/stubs/paho-mqtt/paho/mqtt/client.pyi @@ -3,8 +3,8 @@ import socket as _socket import ssl as _ssl import time import types -from collections.abc import Callable, Iterable -from typing import Any, Optional, TypeVar +from collections.abc import Callable +from typing import Any, List, Optional, Tuple, TypeVar from typing_extensions import TypeAlias from .matcher import MQTTMatcher as MQTTMatcher @@ -94,13 +94,13 @@ _OnConnect: TypeAlias = Callable[[Client, _UserData, dict[str, int], int], objec _OnConnectV5: TypeAlias = Callable[[Client, _UserData, dict[str, int], ReasonCodes, Optional[Properties]], object] _TOnConnect = TypeVar("_TOnConnect", _OnConnect, _OnConnectV5) _OnConnectFail: TypeAlias = Callable[[Client, _UserData], object] -_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, Iterable[int]], object] -_OnSubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Iterable[ReasonCodes], Iterable[Properties]], object] +_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, Tuple[int]], object] +_OnSubscribeV5: TypeAlias = Callable[[Client, _UserData, int, List[ReasonCodes], Properties], object] _TOnSubscribe = TypeVar("_TOnSubscribe", _OnSubscribe, _OnSubscribeV5) _OnMessage: TypeAlias = Callable[[Client, _UserData, MQTTMessage], object] _OnPublish: TypeAlias = Callable[[Client, _UserData, int], object] _OnUnsubscribe: TypeAlias = Callable[[Client, _UserData, int], object] -_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Iterable[Properties], Iterable[ReasonCodes]], object] +_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Properties, List[ReasonCodes] | ReasonCodes], object] _TOnUnsubscribe = TypeVar("_TOnUnsubscribe", _OnUnsubscribe, _OnUnsubscribeV5) _OnDisconnect: TypeAlias = Callable[[Client, _UserData, int], object] _OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, Optional[ReasonCodes], Optional[Properties]], object] From 72006613728ab9af3fd7527dd58e314d83d5b5df Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Tue, 11 Oct 2022 10:33:14 +0200 Subject: [PATCH 6/7] Replace Tuple and List with tuple and list --- stubs/paho-mqtt/paho/mqtt/client.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/paho-mqtt/paho/mqtt/client.pyi b/stubs/paho-mqtt/paho/mqtt/client.pyi index e1bea28b65a1..e2b0a82375a4 100644 --- a/stubs/paho-mqtt/paho/mqtt/client.pyi +++ b/stubs/paho-mqtt/paho/mqtt/client.pyi @@ -4,7 +4,7 @@ import ssl as _ssl import time import types from collections.abc import Callable -from typing import Any, List, Optional, Tuple, TypeVar +from typing import Any, Optional, TypeVar from typing_extensions import TypeAlias from .matcher import MQTTMatcher as MQTTMatcher @@ -94,13 +94,13 @@ _OnConnect: TypeAlias = Callable[[Client, _UserData, dict[str, int], int], objec _OnConnectV5: TypeAlias = Callable[[Client, _UserData, dict[str, int], ReasonCodes, Optional[Properties]], object] _TOnConnect = TypeVar("_TOnConnect", _OnConnect, _OnConnectV5) _OnConnectFail: TypeAlias = Callable[[Client, _UserData], object] -_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, Tuple[int]], object] -_OnSubscribeV5: TypeAlias = Callable[[Client, _UserData, int, List[ReasonCodes], Properties], object] +_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, tuple[int]], object] +_OnSubscribeV5: TypeAlias = Callable[[Client, _UserData, int, list[ReasonCodes], Properties], object] _TOnSubscribe = TypeVar("_TOnSubscribe", _OnSubscribe, _OnSubscribeV5) _OnMessage: TypeAlias = Callable[[Client, _UserData, MQTTMessage], object] _OnPublish: TypeAlias = Callable[[Client, _UserData, int], object] _OnUnsubscribe: TypeAlias = Callable[[Client, _UserData, int], object] -_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Properties, List[ReasonCodes] | ReasonCodes], object] +_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Properties, list[ReasonCodes] | ReasonCodes], object] _TOnUnsubscribe = TypeVar("_TOnUnsubscribe", _OnUnsubscribe, _OnUnsubscribeV5) _OnDisconnect: TypeAlias = Callable[[Client, _UserData, int], object] _OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, Optional[ReasonCodes], Optional[Properties]], object] From 2cebfee0f00265b3bae9c8b102ef9184bd0e4532 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:50:47 +0200 Subject: [PATCH 7/7] Fix typing of _TLS and _Proxy --- stubs/paho-mqtt/paho/mqtt/publish.pyi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stubs/paho-mqtt/paho/mqtt/publish.pyi b/stubs/paho-mqtt/paho/mqtt/publish.pyi index b23fb63ebeaa..af1402336669 100644 --- a/stubs/paho-mqtt/paho/mqtt/publish.pyi +++ b/stubs/paho-mqtt/paho/mqtt/publish.pyi @@ -1,3 +1,4 @@ +import ssl from collections.abc import Iterable from typing_extensions import NotRequired, TypeAlias, TypedDict @@ -17,14 +18,16 @@ class _TLS(TypedDict): ca_certs: str certfile: NotRequired[str] keyfile: NotRequired[str] - tls_version: NotRequired[str] + tls_version: NotRequired[ssl._SSLMethod] ciphers: NotRequired[str] insecure: NotRequired[str] + cert_reqs: NotRequired[ssl.VerifyMode] + keyfile_password: NotRequired[ssl._PasswordType] class _Proxy(TypedDict): proxy_type: int proxy_addr: str - proxy_rdns: NotRequired[str] + proxy_rdns: NotRequired[bool] proxy_username: NotRequired[str] proxy_passwor: NotRequired[str]