From 3977fee06321a7bc4c879e45dd32ec3cecc50326 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Thu, 2 Jun 2022 11:25:29 -0700 Subject: [PATCH] Suppress warning from cryptography 37 about deprecated Python 3.6 support Version 37 still works on Python 3.6 but the deprecation causes loud, user-visible warnings when running any command. Version 38 will likely drop support, leaving 37 as the highest available version on 3.6. This is more reason to drop 3.6 ourselves eventually as we'll not want to be using an older and older cryptography release. In the meantime, however, squash the warning since it does no good for end users. Frustratingly, cryptography appears to have intentionally made this a UserWarning instead of a DeprecationWarning because they wanted to force its visibility. --- nextstrain/cli/aws/cognito/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nextstrain/cli/aws/cognito/__init__.py b/nextstrain/cli/aws/cognito/__init__.py index 18ee27ef..5eb77930 100644 --- a/nextstrain/cli/aws/cognito/__init__.py +++ b/nextstrain/cli/aws/cognito/__init__.py @@ -2,8 +2,17 @@ AWS Cognito helpers. """ import boto3 -import jwt -import jwt.exceptions +import warnings + +# Ignore noisy warning from cryptography 37.0.0 about deprecated support for Python 3.6. +with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + message = "Python 3\\.6 is no longer supported by the Python core team\\. Therefore, support for it is deprecated in cryptography and will be removed in a future release\\.", + category = UserWarning) + + import jwt + import jwt.exceptions from .srp import CognitoSRP, NewPasswordRequiredError