From cc3fe150ef878b5f7ec8b15a377f76e8862912f0 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Mon, 4 Aug 2025 10:01:24 -0700 Subject: [PATCH 01/11] deprecation placeholder tags to connection builder functions --- awsiot/mqtt_connection_builder.py | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index 1790098a..e5e868c7 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -125,6 +125,27 @@ import awscrt.mqtt import urllib.parse +# TYPE_CHECKING is used to exclusively execute code by static analysers. Never at runtime. +from typing import TYPE_CHECKING +if TYPE_CHECKING: + # Static analysers will always attempt to import deprecated from typing_extensions and + # fall back to known interpretation of `deprecated` if it fails and appropriately handle + # the `@deprecated` tags. + from typing_extensions import deprecated +else: + try: + # preferred import of deprecated + from typing_extensions import deprecated + except ModuleNotFoundError: + try: + # Python 3.12+ + from typing import deprecated + except ImportError: + # shim if both are unavailable that turn `deprecated` into a no-op + def deprecated(msg=None, *, since=None): + def wrapper(obj): return obj + return wrapper + def _check_required_kwargs(**kwargs): for required in ['endpoint', 'client_id']: @@ -258,6 +279,14 @@ def _builder( ) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Connection: """ This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT. @@ -276,6 +305,14 @@ def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Con return _builder(tls_ctx_options, **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connection: """ This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT. @@ -294,6 +331,14 @@ def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connecti return _builder(tls_ctx_options, **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def mtls_with_pkcs11(*, pkcs11_lib: awscrt.io.Pkcs11Lib, user_pin: str, @@ -350,6 +395,15 @@ def mtls_with_pkcs11(*, return _builder(tls_ctx_options, **kwargs) + +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def mtls_with_pkcs12(*, pkcs12_filepath: str, pkcs12_password: str, @@ -376,6 +430,14 @@ def mtls_with_pkcs12(*, return _builder(tls_ctx_options, **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def mtls_with_windows_cert_store_path(*, cert_store_path: str, **kwargs) -> awscrt.mqtt.Connection: @@ -400,6 +462,14 @@ def mtls_with_windows_cert_store_path(*, return _builder(tls_ctx_options, **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def websockets_with_default_aws_signing( region, credentials_provider, @@ -444,6 +514,14 @@ def _sign_websocket_handshake_request(transform_args, **kwargs): return websockets_with_custom_handshake(_sign_websocket_handshake_request, websocket_proxy_options, **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def websockets_with_custom_handshake( websocket_handshake_transform, websocket_proxy_options=None, @@ -498,6 +576,14 @@ def _add_to_username_parameter(input_string, parameter_value, parameter_pretext) return return_string + parameter_pretext + parameter_value +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def direct_with_custom_authorizer( auth_username=None, auth_authorizer_name=None, @@ -552,6 +638,15 @@ def direct_with_custom_authorizer( use_websockets=False, **kwargs) + +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def websockets_with_custom_authorizer( region=None, credentials_provider=None, @@ -615,6 +710,14 @@ def websockets_with_custom_authorizer( **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def _with_custom_authorizer(auth_username=None, auth_authorizer_name=None, auth_authorizer_signature=None, @@ -675,6 +778,14 @@ def _sign_websocket_handshake_request(transform_args, **kwargs): **kwargs) +@deprecated( + """ + Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to + fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate + to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime + management. More details can be found here: + """, + since="9.9.9") def new_default_builder(**kwargs) -> awscrt.mqtt.Connection: """ This builder creates an :class:`awscrt.mqtt.Connection`, without any configuration besides the default TLS context options. From f97244b63c2f026d22ba4e70ea1a65b0ed038e29 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 7 Aug 2025 14:12:59 -0700 Subject: [PATCH 02/11] merge main and handle different versions of typing_extension deprecated --- awsiot/mqtt_connection_builder.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index e5e868c7..319ea741 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -133,18 +133,26 @@ # the `@deprecated` tags. from typing_extensions import deprecated else: + _impl = None try: # preferred import of deprecated - from typing_extensions import deprecated - except ModuleNotFoundError: + from typing_extensions import deprecated as _impl + except Exception: try: - # Python 3.12+ - from typing import deprecated - except ImportError: - # shim if both are unavailable that turn `deprecated` into a no-op - def deprecated(msg=None, *, since=None): - def wrapper(obj): return obj - return wrapper + from typing import deprecated as _impl # Python 3.13+ + except Exception: + _impl = None + + def deprecated(msg=None, *, since=None): + if _impl is None: + def _noop(obj): return obj + return _noop + if since is not None: + try: + return _impl(msg, since=since) + except TypeError: + pass # older typing_extensions: no 'since' keyword + return _impl(msg) def _check_required_kwargs(**kwargs): From 82636f506edf35e082e06fd11e76a29a41aee7b8 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 13 Aug 2025 08:07:26 -0700 Subject: [PATCH 03/11] deprecation text --- awsiot/mqtt_connection_builder.py | 88 +++++++++++++++---------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index 319ea741..469641ea 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -289,10 +289,10 @@ def _builder( @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Connection: @@ -315,10 +315,10 @@ def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Con @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connection: @@ -341,10 +341,10 @@ def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connecti @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def mtls_with_pkcs11(*, @@ -406,10 +406,10 @@ def mtls_with_pkcs11(*, @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def mtls_with_pkcs12(*, @@ -440,10 +440,10 @@ def mtls_with_pkcs12(*, @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def mtls_with_windows_cert_store_path(*, @@ -472,10 +472,10 @@ def mtls_with_windows_cert_store_path(*, @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def websockets_with_default_aws_signing( @@ -524,10 +524,10 @@ def _sign_websocket_handshake_request(transform_args, **kwargs): @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def websockets_with_custom_handshake( @@ -586,10 +586,10 @@ def _add_to_username_parameter(input_string, parameter_value, parameter_pretext) @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def direct_with_custom_authorizer( @@ -649,10 +649,10 @@ def direct_with_custom_authorizer( @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def websockets_with_custom_authorizer( @@ -720,10 +720,10 @@ def websockets_with_custom_authorizer( @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def _with_custom_authorizer(auth_username=None, @@ -788,10 +788,10 @@ def _sign_websocket_handshake_request(transform_args, **kwargs): @deprecated( """ - Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to - fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate - to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime - management. More details can be found here: + We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access + a more robust feature set, clearer error handling, and lifetime management. More details can be found + in the GitHub Repo FAQ """, since="9.9.9") def new_default_builder(**kwargs) -> awscrt.mqtt.Connection: From 235e65b953bd89ade9d9b35b216709db10a53bbe Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 13 Aug 2025 08:47:37 -0700 Subject: [PATCH 04/11] point to the builder --- awsiot/mqtt_connection_builder.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index 469641ea..a4d4968d 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -289,7 +289,7 @@ def _builder( @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -315,7 +315,7 @@ def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Con @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -341,7 +341,7 @@ def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connecti @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -406,7 +406,7 @@ def mtls_with_pkcs11(*, @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -440,7 +440,7 @@ def mtls_with_pkcs12(*, @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -472,7 +472,7 @@ def mtls_with_windows_cert_store_path(*, @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -524,7 +524,7 @@ def _sign_websocket_handshake_request(transform_args, **kwargs): @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -586,7 +586,7 @@ def _add_to_username_parameter(input_string, parameter_value, parameter_pretext) @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -649,7 +649,7 @@ def direct_with_custom_authorizer( @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -720,7 +720,7 @@ def websockets_with_custom_authorizer( @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ @@ -788,7 +788,7 @@ def _sign_websocket_handshake_request(transform_args, **kwargs): @deprecated( """ - We strongly recommend using mqtt5.Client. There are no current plans to fully deprecate + We strongly recommend using mqtt5_client_builder. There are no current plans to fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate to the MQTT5 client to access a more robust feature set, clearer error handling, and lifetime management. More details can be found in the GitHub Repo FAQ From 982adff1eddee6f015e8c18a8fd2e1679f62d910 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 14:01:34 -0700 Subject: [PATCH 05/11] use awscrt.common import deprecated --- awsiot/mqtt_connection_builder.py | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index a4d4968d..c62fb372 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -124,35 +124,7 @@ import awscrt.io import awscrt.mqtt import urllib.parse - -# TYPE_CHECKING is used to exclusively execute code by static analysers. Never at runtime. -from typing import TYPE_CHECKING -if TYPE_CHECKING: - # Static analysers will always attempt to import deprecated from typing_extensions and - # fall back to known interpretation of `deprecated` if it fails and appropriately handle - # the `@deprecated` tags. - from typing_extensions import deprecated -else: - _impl = None - try: - # preferred import of deprecated - from typing_extensions import deprecated as _impl - except Exception: - try: - from typing import deprecated as _impl # Python 3.13+ - except Exception: - _impl = None - - def deprecated(msg=None, *, since=None): - if _impl is None: - def _noop(obj): return obj - return _noop - if since is not None: - try: - return _impl(msg, since=since) - except TypeError: - pass # older typing_extensions: no 'since' keyword - return _impl(msg) +from awscrt.common import deprecated def _check_required_kwargs(**kwargs): From ebfa152b963797ee04dd1c522f01bf8a2b895d86 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 14:06:32 -0700 Subject: [PATCH 06/11] updated service clients --- awsiot/iotidentity.py | 11 +++++++++++ awsiot/iotjobs.py | 11 +++++++++++ awsiot/iotshadow.py | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/awsiot/iotidentity.py b/awsiot/iotidentity.py index 3b7f669b..94000ed8 100644 --- a/awsiot/iotidentity.py +++ b/awsiot/iotidentity.py @@ -9,8 +9,19 @@ import json import typing +from awscrt.common import deprecated + +@deprecated( + """ + We strongly recommend using IotIdentityClientV2. There are no current plans to + fully deprecate IotIdentityClient but it is highly recommended customers migrate to IotIdentityClientV2. + More details can be found in the GitHub Repo FAQ + """) class IotIdentityClient(awsiot.MqttServiceClient): """ + Deprecated: We strongly recommend using IotIdentityClientV2. There are no current plans to + fully deprecate IotIdentityClient but it is highly recommended customers migrate to IotIdentityClientV2. + More details can be found in the GitHub Repo FAQ An AWS IoT service that assists with provisioning a device and installing unique client certificates on it diff --git a/awsiot/iotjobs.py b/awsiot/iotjobs.py index 69a441de..e0a0b8ac 100644 --- a/awsiot/iotjobs.py +++ b/awsiot/iotjobs.py @@ -11,8 +11,19 @@ import typing import uuid +from awscrt.common import deprecated + +@deprecated( + """ + We strongly recommend using IotJobsClientV2. There are no current plans to + fully deprecate IotJobsClient but it is highly recommended customers migrate to IotJobsClientV2. + More details can be found in the GitHub Repo FAQ + """) class IotJobsClient(awsiot.MqttServiceClient): """ + Deprecated: We strongly recommend using IotJobsClientV2. There are no current plans to + fully deprecate IotJobsClient but it is highly recommended customers migrate to IotJobsClientV2. + More details can be found in the GitHub Repo FAQ The AWS IoT jobs service can be used to define a set of remote operations that are sent to and executed on one or more devices connected to AWS IoT. diff --git a/awsiot/iotshadow.py b/awsiot/iotshadow.py index 6721028c..22ca5e54 100644 --- a/awsiot/iotshadow.py +++ b/awsiot/iotshadow.py @@ -11,8 +11,19 @@ import typing import uuid +from awscrt.common import deprecated + +@deprecated( + """ + We strongly recommend using IotShadowClientV2. There are no current plans to + fully deprecate IotShadowClient but it is highly recommended customers migrate to IotShadowClientV2. + More details can be found in the GitHub Repo FAQ + """) class IotShadowClient(awsiot.MqttServiceClient): """ + Deprecated: We strongly recommend using IotShadowClientV2. There are no current plans to + fully deprecate IotShadowClient but it is highly recommended customers migrate to IotShadowClientV2. + More details can be found in the GitHub Repo FAQ The AWS IoT Device Shadow service adds shadows to AWS IoT thing objects. Shadows are a simple data store for device properties and state. Shadows can make a device’s state available to apps and other services whether the device is connected to AWS IoT or not. From fa06088e483a0e5ccb6c9eff88c6a0aa01b26b99 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Fri, 15 Aug 2025 09:30:36 -0700 Subject: [PATCH 07/11] temp deprecated replacement file for tests --- awsiot/iotidentity.py | 3 +- awsiot/iotjobs.py | 3 +- awsiot/iotshadow.py | 3 +- awsiot/mqtt_connection_builder.py | 3 +- awsiot/remove_me.py | 78 +++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 awsiot/remove_me.py diff --git a/awsiot/iotidentity.py b/awsiot/iotidentity.py index 94000ed8..2bb82599 100644 --- a/awsiot/iotidentity.py +++ b/awsiot/iotidentity.py @@ -9,7 +9,8 @@ import json import typing -from awscrt.common import deprecated +from awsiot.remove_me import deprecated +# from awscrt.common import deprecated @deprecated( """ diff --git a/awsiot/iotjobs.py b/awsiot/iotjobs.py index e0a0b8ac..4c065510 100644 --- a/awsiot/iotjobs.py +++ b/awsiot/iotjobs.py @@ -11,7 +11,8 @@ import typing import uuid -from awscrt.common import deprecated +from awsiot.remove_me import deprecated +# from awscrt.common import deprecated @deprecated( """ diff --git a/awsiot/iotshadow.py b/awsiot/iotshadow.py index 22ca5e54..16c26dd6 100644 --- a/awsiot/iotshadow.py +++ b/awsiot/iotshadow.py @@ -11,7 +11,8 @@ import typing import uuid -from awscrt.common import deprecated +from awsiot.remove_me import deprecated +# from awscrt.common import deprecated @deprecated( """ diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index c62fb372..1f429e90 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -124,7 +124,8 @@ import awscrt.io import awscrt.mqtt import urllib.parse -from awscrt.common import deprecated +# from awscrt.common import deprecated +from remove_me import deprecated def _check_required_kwargs(**kwargs): diff --git a/awsiot/remove_me.py b/awsiot/remove_me.py new file mode 100644 index 00000000..dd4d2932 --- /dev/null +++ b/awsiot/remove_me.py @@ -0,0 +1,78 @@ +# TEMPORARY WIP FILE TO USE IN PLACE OF NON-ACCESSIBLE common.py from awscrt until a version is cut. +# DELETE THIS FILE and point to the correct location after crt has released a version with soft deprecation + +""" +Cross-platform library for `awscrt`. +""" +from typing import TYPE_CHECKING +import _awscrt + +__all__ = [ + "get_cpu_group_count", + "get_cpu_count_for_group", + "join_all_native_threads", + "deprecated", +] + +# At type-check time, expose a real symbol so linters/IDEs understand it. +# At runtime, prefer typing_extensions; fall back to typing (Py3.13+); else no-op. +if TYPE_CHECKING: + # Static analysers will always attempt to import deprecated from typing_extensions and + # fall back to known interpretation of `deprecated` if it fails and appropriately handle + # the `@deprecated` tags. + from typing_extensions import deprecated as deprecated +else: + _deprecated_impl = None + try: + # preferred import of deprecated + from typing_extensions import deprecated as _deprecated_impl + except Exception: + try: + from typing import deprecated as _deprecated_impl # Python 3.13+ + except Exception: + _deprecated_impl = None + + def deprecated(msg=None, *, since=None): + if _deprecated_impl is None: + def _noop(obj): return obj + return _noop + if since is not None: + try: + return _deprecated_impl(msg, since=since) + except TypeError: + # older typing_extensions doesn't support the 'since' kwarg + pass + return _deprecated_impl(msg) + + +def get_cpu_group_count() -> int: + """ + Returns number of processor groups on the system. + + Useful for working with non-uniform memory access (NUMA) nodes. + """ + return _awscrt.get_cpu_group_count() + + +def get_cpu_count_for_group(group_idx: int) -> int: + """ + Returns number of processors in a given group. + """ + return _awscrt.get_cpu_count_for_group(group_idx) + + +def join_all_native_threads(*, timeout_sec: float = -1.0) -> bool: + """ + Waits for all native threads to complete their join call. + + This can only be safely called from the main thread. + This call may be required for native memory usage to reach zero. + + Args: + timeout_sec (float): Number of seconds to wait before a timeout exception is raised. + By default the wait is unbounded. + + Returns: + bool: Returns whether threads could be joined before the timeout. + """ + return _awscrt.thread_join_all_managed(timeout_sec) From b20d409f2b301b156570682a35c07fd8f48d9692 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Fri, 15 Aug 2025 09:43:45 -0700 Subject: [PATCH 08/11] fix remove_me --- awsiot/remove_me.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/awsiot/remove_me.py b/awsiot/remove_me.py index dd4d2932..3abdd618 100644 --- a/awsiot/remove_me.py +++ b/awsiot/remove_me.py @@ -5,12 +5,8 @@ Cross-platform library for `awscrt`. """ from typing import TYPE_CHECKING -import _awscrt __all__ = [ - "get_cpu_group_count", - "get_cpu_count_for_group", - "join_all_native_threads", "deprecated", ] @@ -43,36 +39,3 @@ def _noop(obj): return obj # older typing_extensions doesn't support the 'since' kwarg pass return _deprecated_impl(msg) - - -def get_cpu_group_count() -> int: - """ - Returns number of processor groups on the system. - - Useful for working with non-uniform memory access (NUMA) nodes. - """ - return _awscrt.get_cpu_group_count() - - -def get_cpu_count_for_group(group_idx: int) -> int: - """ - Returns number of processors in a given group. - """ - return _awscrt.get_cpu_count_for_group(group_idx) - - -def join_all_native_threads(*, timeout_sec: float = -1.0) -> bool: - """ - Waits for all native threads to complete their join call. - - This can only be safely called from the main thread. - This call may be required for native memory usage to reach zero. - - Args: - timeout_sec (float): Number of seconds to wait before a timeout exception is raised. - By default the wait is unbounded. - - Returns: - bool: Returns whether threads could be joined before the timeout. - """ - return _awscrt.thread_join_all_managed(timeout_sec) From c2af3a9251ef65075298f0916957ecd22ee639e9 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Fri, 15 Aug 2025 09:46:14 -0700 Subject: [PATCH 09/11] import --- awsiot/iotidentity.py | 2 +- awsiot/iotjobs.py | 2 +- awsiot/iotshadow.py | 2 +- awsiot/mqtt_connection_builder.py | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/awsiot/iotidentity.py b/awsiot/iotidentity.py index 2bb82599..7d16edc8 100644 --- a/awsiot/iotidentity.py +++ b/awsiot/iotidentity.py @@ -9,7 +9,7 @@ import json import typing -from awsiot.remove_me import deprecated +from .remove_me import deprecated # from awscrt.common import deprecated @deprecated( diff --git a/awsiot/iotjobs.py b/awsiot/iotjobs.py index 4c065510..d097855f 100644 --- a/awsiot/iotjobs.py +++ b/awsiot/iotjobs.py @@ -11,7 +11,7 @@ import typing import uuid -from awsiot.remove_me import deprecated +from .remove_me import deprecated # from awscrt.common import deprecated @deprecated( diff --git a/awsiot/iotshadow.py b/awsiot/iotshadow.py index 16c26dd6..248d12b3 100644 --- a/awsiot/iotshadow.py +++ b/awsiot/iotshadow.py @@ -11,7 +11,7 @@ import typing import uuid -from awsiot.remove_me import deprecated +from .remove_me import deprecated # from awscrt.common import deprecated @deprecated( diff --git a/awsiot/mqtt_connection_builder.py b/awsiot/mqtt_connection_builder.py index 1f429e90..dc65f3d1 100644 --- a/awsiot/mqtt_connection_builder.py +++ b/awsiot/mqtt_connection_builder.py @@ -124,8 +124,9 @@ import awscrt.io import awscrt.mqtt import urllib.parse +from .remove_me import deprecated # from awscrt.common import deprecated -from remove_me import deprecated + def _check_required_kwargs(**kwargs): From 1a120b8c8fa24b908b42496a94d403419e4728c4 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 30 Sep 2025 09:02:15 -0700 Subject: [PATCH 10/11] ci.yml builder version updated to 0.9.87 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79aef03f..b0217c4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: - 'docs' env: - BUILDER_VERSION: v0.9.75 + BUILDER_VERSION: v0.9.87 BUILDER_SOURCE: releases BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net PACKAGE_NAME: aws-iot-device-sdk-python-v2 From 99c2c8ebc8e44934695f1f0c2021261e4562e204 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 30 Sep 2025 09:04:51 -0700 Subject: [PATCH 11/11] commit change to ci --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4624c8d1..2174cf0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,7 @@ on: - 'docs' env: -<<<<<<< HEAD BUILDER_VERSION: v0.9.87 -======= - BUILDER_VERSION: v0.9.84 ->>>>>>> main BUILDER_SOURCE: releases BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net PACKAGE_NAME: aws-iot-device-sdk-python-v2