From 36a05983b40b45a55ba0b5345a1e387dd8cb1162 Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Tue, 1 Jul 2025 14:56:30 -0600 Subject: [PATCH] Add warning for direct usage of six from awscli.compat --- awscli/compat.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/awscli/compat.py b/awscli/compat.py index 1881c0c7ebe2..0b77eafa6679 100644 --- a/awscli/compat.py +++ b/awscli/compat.py @@ -26,7 +26,7 @@ from urllib.error import URLError from urllib.request import urlopen -from botocore.compat import six, OrderedDict +from botocore.compat import OrderedDict import sys import zipfile @@ -502,3 +502,20 @@ def _linux_distribution( if _id: id = _id return distname, version, id + + +def __getattr__(name): + """ + Module override to raise warnings when deprecated libraries + are imported in external code. + """ + if name == "six": + warnstr = ( + "The awscli.compat.six module is deprecated and will be removed " + "in a future version. Please use six as a direct dependency." + ) + warnings.warn(warnstr, DeprecationWarning, stacklevel=2) + from botocore.compat import six + return six + + raise AttributeError(f"Module {__name__} has no attribute {name}.")