File tree Expand file tree Collapse file tree 4 files changed +54
-2
lines changed Expand file tree Collapse file tree 4 files changed +54
-2
lines changed Original file line number Diff line number Diff line change 22
22
import shlex
23
23
import re
24
24
import os
25
+ import warnings
25
26
from collections import OrderedDict
26
27
from collections .abc import MutableMapping
27
28
from math import floor
28
29
29
- from botocore .vendored import six
30
30
from botocore .exceptions import MD5UnavailableError
31
31
from dateutil .tz import tzlocal
32
32
from urllib3 import exceptions
@@ -360,3 +360,20 @@ def has_minimum_crt_version(minimum_version):
360
360
HAS_GZIP = True
361
361
except ImportError :
362
362
HAS_GZIP = False
363
+
364
+
365
+ def __getattr__ (name ):
366
+ """
367
+ Module override to raise warnings when deprecated libraries
368
+ are imported in external code.
369
+ """
370
+ if name == "six" :
371
+ warnstr = (
372
+ "The botocore.compat.six module is deprecated and will be removed "
373
+ "in a future version. Please use six as a direct dependency."
374
+ )
375
+ warnings .warn (warnstr , DeprecationWarning , stacklevel = 2 )
376
+ from botocore .vendored import six
377
+ return six
378
+
379
+ raise AttributeError (f"Module { __name__ } has no attribute { name } ." )
Original file line number Diff line number Diff line change 27
27
import operator
28
28
import sys
29
29
import types
30
+ import warnings
31
+
32
+ warnstr = (
33
+ "The botocore.vendored.six module is deprecated and will be removed "
34
+ "in a future version. Please use six as a direct dependency."
35
+ )
36
+ warnings .warn (warnstr , DeprecationWarning , stacklevel = 2 )
30
37
31
38
__author__ = "Benjamin Peterson <[email protected] >"
32
39
__version__ = "1.16.0"
Original file line number Diff line number Diff line change 5
5
import sys
6
6
import threading
7
7
import time
8
+ import warnings
8
9
9
- from botocore .vendored import six
10
10
from tests import mock
11
11
12
+ with warnings .catch_warnings ():
13
+ from botocore .vendored import six
14
+
12
15
_original_setattr = six .moves .__class__ .__setattr__
13
16
14
17
Original file line number Diff line number Diff line change 11
11
# ANY KIND, either express or implied. See the License for the specific
12
12
# language governing permissions and limitations under the License.
13
13
import datetime
14
+ import warnings
14
15
15
16
import pytest
16
17
@@ -225,3 +226,27 @@ def test_has_crt_global(self):
225
226
assert HAS_CRT
226
227
except ImportError :
227
228
assert not HAS_CRT
229
+
230
+
231
+ @pytest .mark .filterwarnings ("always::DeprecationWarning" )
232
+ def test_six_deprecation_warning ():
233
+ vendored_msg = "The botocore.vendored.six module is deprecated"
234
+ compat_msg = "The botocore.compat.six module is deprecated"
235
+
236
+ # Verify import from compat raises a warning
237
+ with pytest .warns (DeprecationWarning , match = vendored_msg ):
238
+ import botocore .vendored .six # noqa: F401
239
+
240
+ # Verify import from compat raises a warning
241
+ with pytest .warns (DeprecationWarning , match = compat_msg ):
242
+ from botocore .compat import six # noqa: F401
243
+
244
+ # Verify other imports don't raise a warning
245
+ with warnings .catch_warnings ():
246
+ warnings .simplefilter ("error" )
247
+ from botocore .compat import urlparse # noqa: F401
248
+
249
+ # Verify direct import of the module doesn't raise a warning
250
+ with warnings .catch_warnings ():
251
+ warnings .simplefilter ("error" )
252
+ import botocore .compat # noqa: F401
You can’t perform that action at this time.
0 commit comments