From 1d59b467e4d888b77dcdc4347e8eceeabd875732 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 30 Jul 2025 14:14:20 -0700 Subject: [PATCH 01/16] placeholder deprecation tags for mqtt client --- awscrt/mqtt.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 7529168ea..996e17918 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -16,6 +16,7 @@ from awscrt.io import ClientBootstrap, ClientTlsContext, SocketOptions from dataclasses import dataclass from awscrt.mqtt5 import Client as Mqtt5Client +from typing_extensions import deprecated class QoS(IntEnum): @@ -167,9 +168,20 @@ class OnConnectionClosedData: """ pass - +@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") class Client(NativeResource): - """MQTT client. + """ + Deprecated Definition. 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: + + MQTT client. Args: bootstrap (Optional [ClientBootstrap]): Client bootstrap to use when initiating new socket connections. From c93972cb3b5bf3564e759e6e1f2e17568604eea8 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Wed, 30 Jul 2025 14:26:29 -0700 Subject: [PATCH 02/16] import deprecated across older and newer python --- awscrt/mqtt.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 996e17918..a7c233c9c 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -16,7 +16,10 @@ from awscrt.io import ClientBootstrap, ClientTlsContext, SocketOptions from dataclasses import dataclass from awscrt.mqtt5 import Client as Mqtt5Client -from typing_extensions import deprecated +try: + from typing import deprecated # Python 3.12+ +except ImportError: + from typing_extensions import deprecated # Python 3.11 or earlier class QoS(IntEnum): From dfbce8305b7ef925e5b210edcfbb0328b065a1ae Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 31 Jul 2025 08:43:54 -0700 Subject: [PATCH 03/16] manually define deprecated if not present --- awscrt/mqtt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index a7c233c9c..19c69c86b 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -19,7 +19,12 @@ try: from typing import deprecated # Python 3.12+ except ImportError: - from typing_extensions import deprecated # Python 3.11 or earlier + try: + from typing_extensions import deprecated # Python 3.11 or earlier + except ModuleNotFoundError: + def deprecated(msg=None, *, since=None): + def wrapper(obj): return obj + return wrapper class QoS(IntEnum): From a67a131d9504caf6142d47a994e43e2028194819 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 31 Jul 2025 09:44:08 -0700 Subject: [PATCH 04/16] cover all bases and appropriately strike-through the client in IDEs --- awscrt/mqtt.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 19c69c86b..1e095a25a 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -16,15 +16,27 @@ from awscrt.io import ClientBootstrap, ClientTlsContext, SocketOptions from dataclasses import dataclass from awscrt.mqtt5 import Client as Mqtt5Client -try: - from typing import deprecated # Python 3.12+ -except ImportError: + +# 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: - from typing_extensions import deprecated # Python 3.11 or earlier + # preferred import of deprecated + from typing_extensions import deprecated except ModuleNotFoundError: - def deprecated(msg=None, *, since=None): - def wrapper(obj): return obj - return wrapper + 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 class QoS(IntEnum): From c659f8930a08680e82b7fef7f59287d816c9eb93 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 31 Jul 2025 09:48:06 -0700 Subject: [PATCH 05/16] lint --- awscrt/mqtt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 1e095a25a..0a679486a 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -188,12 +188,14 @@ class OnConnectionClosedData: """ pass -@deprecated(""" +@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") + """, + since="9.9.9") class Client(NativeResource): """ Deprecated Definition. Please use MQTT5 Client for new code. There are no current plans to From 41c9e3b9a95046f9200771d78ac502a20a5efb1b Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 31 Jul 2025 09:50:45 -0700 Subject: [PATCH 06/16] added extra line for lint --- awscrt/mqtt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 0a679486a..47dccf234 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -188,6 +188,7 @@ class OnConnectionClosedData: """ pass + @deprecated( """ Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to From b5d3c4da6e5b89f10907f14aea92116521e3568d Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Mon, 4 Aug 2025 09:43:51 -0700 Subject: [PATCH 07/16] deprecate Connection --- awscrt/mqtt.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 47dccf234..4dbc38109 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -243,8 +243,22 @@ class OperationStatisticsData: unacked_operation_size: int = 0 +@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") class Connection(NativeResource): - """MQTT client connection. + """ + Deprecated Definition. 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: + + MQTT client connection. Args: client (Client): MQTT client to spawn connection from. From 0d7819e75d11de9613cadf515ebd012c2f1da506 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Fri, 8 Aug 2025 09:08:24 -0700 Subject: [PATCH 08/16] modify deprecated and deprecation import to handle different versions --- awscrt/mqtt.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 4dbc38109..e98788ec5 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -25,18 +25,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) class QoS(IntEnum): From 1c7155bd26fb260f592afb94b91bf1eb3661d31f Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 12 Aug 2025 13:35:44 -0700 Subject: [PATCH 09/16] updated deprecation annotation --- awscrt/mqtt.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index e98788ec5..066f423f3 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -31,10 +31,10 @@ from typing_extensions import deprecated as _impl except Exception: try: - from typing import deprecated as _impl # Python 3.13+ + 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 @@ -43,7 +43,7 @@ def _noop(obj): return obj try: return _impl(msg, since=since) except TypeError: - pass # older typing_extensions: no 'since' keyword + pass # older typing_extensions: no 'since' keyword return _impl(msg) @@ -199,18 +199,18 @@ class OnConnectionClosedData: @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") class Client(NativeResource): """ - Deprecated Definition. 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: + Deprecated: 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 MQTT client. @@ -253,18 +253,18 @@ class OperationStatisticsData: @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") class Connection(NativeResource): """ - Deprecated Definition. 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: + Deprecated: 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 MQTT client connection. From 379cb38010b43940abfff8b94a5e151068fab837 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 12 Aug 2025 13:41:21 -0700 Subject: [PATCH 10/16] lint --- awscrt/mqtt.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 066f423f3..c69076cd6 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -199,17 +199,17 @@ class OnConnectionClosedData: @deprecated( """ - 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 + 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") class Client(NativeResource): """ - Deprecated: 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 + Deprecated: 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 MQTT client. @@ -253,17 +253,17 @@ class OperationStatisticsData: @deprecated( """ - 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 + 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") class Connection(NativeResource): """ - Deprecated: 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 + Deprecated: 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 MQTT client connection. From 5378dc9fa809f6e3d2a7fb9009a61361cb866be9 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Tue, 12 Aug 2025 13:42:53 -0700 Subject: [PATCH 11/16] LINT --- awscrt/mqtt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index c69076cd6..d4dd79ec1 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -265,7 +265,7 @@ class Connection(NativeResource): 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 - + MQTT client connection. Args: From 778065d43242155732a72bf98e386f1831817577 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 10:56:15 -0700 Subject: [PATCH 12/16] try moving deprecated into its own file to be imported from other files --- awscrt/deprecation.py | 34 +++++++++++++++++++++++++ awscrt/mqtt.py | 59 ++++++++++++++++++++++--------------------- 2 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 awscrt/deprecation.py diff --git a/awscrt/deprecation.py b/awscrt/deprecation.py new file mode 100644 index 000000000..291d840cc --- /dev/null +++ b/awscrt/deprecation.py @@ -0,0 +1,34 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. + +from typing import TYPE_CHECKING + +__all__ = ["deprecated"] + +if TYPE_CHECKING: + # Make type checkers happy with a real symbol + from typing_extensions import deprecated as deprecated # type: ignore[assignment] +else: + _impl = None + try: + # prefer typing_extensions for widest runtime support + from typing_extensions import deprecated as _impl + except Exception: + try: + # Python 3.13+ + from typing import deprecated as _impl # type: ignore[attr-defined] + except Exception: + _impl = None + + def deprecated(msg=None, *, since=None): + """Decorator recognized by type checkers; a no-op at runtime if unsupported.""" + if _impl is None: + def _noop(obj): return obj + return _noop + if since is not None: + try: + return _impl(msg, since=since) + except TypeError: + # older typing_extensions doesn't support the 'since' kwarg + pass + return _impl(msg) \ No newline at end of file diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index d4dd79ec1..0a874eeff 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -16,35 +16,36 @@ from awscrt.io import ClientBootstrap, ClientTlsContext, SocketOptions from dataclasses import dataclass from awscrt.mqtt5 import Client as Mqtt5Client - -# 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.deprecation import deprecated + +# # 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) class QoS(IntEnum): From fc9e2326bdb520e024c30ed9a4662d9a9190d833 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 10:57:29 -0700 Subject: [PATCH 13/16] lint --- awscrt/deprecation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awscrt/deprecation.py b/awscrt/deprecation.py index 291d840cc..43a0d6cdf 100644 --- a/awscrt/deprecation.py +++ b/awscrt/deprecation.py @@ -31,4 +31,5 @@ def _noop(obj): return obj except TypeError: # older typing_extensions doesn't support the 'since' kwarg pass - return _impl(msg) \ No newline at end of file + return _impl(msg) + \ No newline at end of file From e49b6cfc9c6db4f5428f26893aa5aa3efa6cb42f Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 10:58:38 -0700 Subject: [PATCH 14/16] lint --- awscrt/deprecation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/awscrt/deprecation.py b/awscrt/deprecation.py index 43a0d6cdf..698fb79f2 100644 --- a/awscrt/deprecation.py +++ b/awscrt/deprecation.py @@ -32,4 +32,3 @@ def _noop(obj): return obj # older typing_extensions doesn't support the 'since' kwarg pass return _impl(msg) - \ No newline at end of file From b4b53df3d26c08065d6ed146bc51382f4da597a2 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 13:12:33 -0700 Subject: [PATCH 15/16] move deprecated into existing common.py to reduce noise --- awscrt/common.py | 39 +++++++++++++++++++++++++++++++++++++++ awscrt/deprecation.py | 34 ---------------------------------- awscrt/mqtt.py | 32 +------------------------------- 3 files changed, 40 insertions(+), 65 deletions(-) delete mode 100644 awscrt/deprecation.py diff --git a/awscrt/common.py b/awscrt/common.py index 0ae2f778d..a0cacf9d7 100644 --- a/awscrt/common.py +++ b/awscrt/common.py @@ -1,8 +1,47 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. """ 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: """ diff --git a/awscrt/deprecation.py b/awscrt/deprecation.py deleted file mode 100644 index 698fb79f2..000000000 --- a/awscrt/deprecation.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0. - -from typing import TYPE_CHECKING - -__all__ = ["deprecated"] - -if TYPE_CHECKING: - # Make type checkers happy with a real symbol - from typing_extensions import deprecated as deprecated # type: ignore[assignment] -else: - _impl = None - try: - # prefer typing_extensions for widest runtime support - from typing_extensions import deprecated as _impl - except Exception: - try: - # Python 3.13+ - from typing import deprecated as _impl # type: ignore[attr-defined] - except Exception: - _impl = None - - def deprecated(msg=None, *, since=None): - """Decorator recognized by type checkers; a no-op at runtime if unsupported.""" - if _impl is None: - def _noop(obj): return obj - return _noop - if since is not None: - try: - return _impl(msg, since=since) - except TypeError: - # older typing_extensions doesn't support the 'since' kwarg - pass - return _impl(msg) diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 0a874eeff..496c082e9 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -16,37 +16,7 @@ from awscrt.io import ClientBootstrap, ClientTlsContext, SocketOptions from dataclasses import dataclass from awscrt.mqtt5 import Client as Mqtt5Client -from awscrt.deprecation import deprecated - -# # 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 class QoS(IntEnum): """Quality of Service enumeration From d0c1d3a38ffe869dfd3f5aca7a1a8c4cb75a1f82 Mon Sep 17 00:00:00 2001 From: Steve Kim Date: Thu, 14 Aug 2025 13:13:56 -0700 Subject: [PATCH 16/16] lint --- awscrt/common.py | 1 + awscrt/mqtt.py | 1 + 2 files changed, 2 insertions(+) diff --git a/awscrt/common.py b/awscrt/common.py index a0cacf9d7..89d810106 100644 --- a/awscrt/common.py +++ b/awscrt/common.py @@ -43,6 +43,7 @@ def _noop(obj): return obj pass return _deprecated_impl(msg) + def get_cpu_group_count() -> int: """ Returns number of processor groups on the system. diff --git a/awscrt/mqtt.py b/awscrt/mqtt.py index 496c082e9..1cbd9e6b7 100644 --- a/awscrt/mqtt.py +++ b/awscrt/mqtt.py @@ -18,6 +18,7 @@ from awscrt.mqtt5 import Client as Mqtt5Client from awscrt.common import deprecated + class QoS(IntEnum): """Quality of Service enumeration