diff --git a/.github/workflows/ci_decrypt-oracle.yaml b/.github/workflows/ci_decrypt-oracle.yaml index 7bced5ebf..e773bd98a 100644 --- a/.github/workflows/ci_decrypt-oracle.yaml +++ b/.github/workflows/ci_decrypt-oracle.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: # The oracle runs in a Python 3.6 Lamba python-version: 3.6 diff --git a/.github/workflows/ci_static-analysis.yaml b/.github/workflows/ci_static-analysis.yaml index 1b659fa5a..31705a5d3 100644 --- a/.github/workflows/ci_static-analysis.yaml +++ b/.github/workflows/ci_static-analysis.yaml @@ -28,7 +28,7 @@ jobs: - isort-check steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: python-version: 3.8 - run: | diff --git a/.github/workflows/ci_test-vector-handler.yaml b/.github/workflows/ci_test-vector-handler.yaml index 1b24390e4..1c33fecdb 100644 --- a/.github/workflows/ci_test-vector-handler.yaml +++ b/.github/workflows/ci_test-vector-handler.yaml @@ -22,7 +22,6 @@ jobs: - macos-latest python: - 2.7 - - 3.5 - 3.6 - 3.7 - 3.8 @@ -47,7 +46,7 @@ jobs: aws-secret-access-key: ${{ secrets.INTEG_AWS_SECRET_ACCESS_KEY }} aws-region: us-west-2 - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.architecture }} diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 0926e60ad..c562e167f 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -28,7 +28,6 @@ jobs: - windows-latest - macos-latest python: - - 3.5 - 3.6 - 3.7 - 3.8 @@ -52,7 +51,7 @@ jobs: architecture: x86 steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.architecture }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 190259b3d..362b53f49 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,25 @@ Changelog ********* +3.1.0 -- 2021-11-10 +=================== + +Deprecation +----------- +The AWS Encryption SDK for Python no longer supports Python 3.5 +as of version 3.1; only Python 3.6+ is supported. Customers using +Python 3.5 can still use the 2.x line of the AWS Encryption SDK for Python, +which will continue to receive security updates, in accordance +with our `Support Policy `__. + +Feature +----------- +* Warn on Deprecated Python usage + `#368 `_ +* Add Python 3.10 to CI +* Remove Python 3.5 from testing + + 3.0.0 -- 2021-07-01 =================== diff --git a/README.rst b/README.rst index b6feff4da..7f1b22824 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ Getting Started Required Prerequisites ====================== -* Python 3.5+ +* Python 3.6+ * cryptography >= 2.5.0 * boto3 >= 1.10.0 * attrs diff --git a/buildspec.yml b/buildspec.yml index 461d4e0d2..bb1e0cd97 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -3,13 +3,6 @@ version: 0.2 batch: fast-fail: false build-list: - - identifier: py35_integ - buildspec: codebuild/py35/integ.yml - - identifier: py35_examples - buildspec: codebuild/py35/examples.yml - - identifier: py35_awses_local - buildspec: codebuild/py35/awses_local.yml - - identifier: py36_integ buildspec: codebuild/py36/integ.yml - identifier: py36_examples @@ -37,6 +30,14 @@ batch: buildspec: codebuild/py39/examples.yml - identifier: py39_awses_latest + - identifier: py310_integ + buildspec: codebuild/py310/integ.yml + - identifier: py310_examples + buildspec: codebuild/py310/examples.yml + - identifier: py310_awses_latest + buildspec: codebuild/py310/awses_local.yml + + - identifier: code_coverage buildspec: codebuild/coverage/coverage.yml diff --git a/codebuild/py35/awses_local.yml b/codebuild/py310/awses_local.yml similarity index 91% rename from codebuild/py35/awses_local.yml rename to codebuild/py310/awses_local.yml index 71583417a..a60eba6d2 100644 --- a/codebuild/py35/awses_local.yml +++ b/codebuild/py310/awses_local.yml @@ -2,7 +2,7 @@ version: 0.2 env: variables: - TOXENV: "py35-awses_local" + TOXENV: "py310-awses_local" AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.5.9 - - pyenv local 3.5.9 + - pyenv install 3.10.0 + - pyenv local 3.10.0 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py35/examples.yml b/codebuild/py310/examples.yml similarity index 90% rename from codebuild/py35/examples.yml rename to codebuild/py310/examples.yml index 109f2764c..59bb42499 100644 --- a/codebuild/py35/examples.yml +++ b/codebuild/py310/examples.yml @@ -2,7 +2,7 @@ version: 0.2 env: variables: - TOXENV: "py35-examples" + TOXENV: "py310-examples" AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.5.9 - - pyenv local 3.5.9 + - pyenv install 3.10.0 + - pyenv local 3.10.0 - pip install tox tox-pyenv - tox diff --git a/codebuild/py35/integ.yml b/codebuild/py310/integ.yml similarity index 90% rename from codebuild/py35/integ.yml rename to codebuild/py310/integ.yml index 0014378ba..3346a06a2 100644 --- a/codebuild/py35/integ.yml +++ b/codebuild/py310/integ.yml @@ -2,7 +2,7 @@ version: 0.2 env: variables: - TOXENV: "py35-integ" + TOXENV: "py310-integ" AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.5.9 - - pyenv local 3.5.9 + - pyenv install 3.10.0 + - pyenv local 3.10.0 - pip install tox tox-pyenv - tox diff --git a/codebuild/py36/awses_local.yml b/codebuild/py36/awses_local.yml index dba6a28ba..b68a7e434 100644 --- a/codebuild/py36/awses_local.yml +++ b/codebuild/py36/awses_local.yml @@ -20,6 +20,8 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.6.15 + - pyenv local 3.6.15 + - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py36/examples.yml b/codebuild/py36/examples.yml index 1bd091d11..46af14902 100644 --- a/codebuild/py36/examples.yml +++ b/codebuild/py36/examples.yml @@ -18,5 +18,7 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.6.15 + - pyenv local 3.6.15 + - pip install tox tox-pyenv - tox diff --git a/codebuild/py36/integ.yml b/codebuild/py36/integ.yml index 35124c835..d55581c43 100644 --- a/codebuild/py36/integ.yml +++ b/codebuild/py36/integ.yml @@ -18,5 +18,7 @@ phases: python: latest build: commands: - - pip install tox + - pyenv install 3.6.15 + - pyenv local 3.6.15 + - pip install tox tox-pyenv - tox diff --git a/codebuild/py37/awses_local.yml b/codebuild/py37/awses_local.yml index 958823841..9e77d43f7 100644 --- a/codebuild/py37/awses_local.yml +++ b/codebuild/py37/awses_local.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.7.9 - - pyenv local 3.7.9 + - pyenv install 3.7.12 + - pyenv local 3.7.12 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py37/examples.yml b/codebuild/py37/examples.yml index cbe251cf0..57d1626df 100644 --- a/codebuild/py37/examples.yml +++ b/codebuild/py37/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.7.9 - - pyenv local 3.7.9 + - pyenv install 3.7.12 + - pyenv local 3.7.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py37/integ.yml b/codebuild/py37/integ.yml index 27ce515d0..04d24c26d 100644 --- a/codebuild/py37/integ.yml +++ b/codebuild/py37/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.7.9 - - pyenv local 3.7.9 + - pyenv install 3.7.12 + - pyenv local 3.7.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py38/awses_local.yml b/codebuild/py38/awses_local.yml index b221abe72..4e20973d4 100644 --- a/codebuild/py38/awses_local.yml +++ b/codebuild/py38/awses_local.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.8.6 - - pyenv local 3.8.6 + - pyenv install 3.8.12 + - pyenv local 3.8.12 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py38/examples.yml b/codebuild/py38/examples.yml index c9a9f9a7a..1a8f4f826 100644 --- a/codebuild/py38/examples.yml +++ b/codebuild/py38/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.8.6 - - pyenv local 3.8.6 + - pyenv install 3.8.12 + - pyenv local 3.8.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py38/integ.yml b/codebuild/py38/integ.yml index 31cbb7d43..28eae25fc 100644 --- a/codebuild/py38/integ.yml +++ b/codebuild/py38/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.8.6 - - pyenv local 3.8.6 + - pyenv install 3.8.12 + - pyenv local 3.8.12 - pip install tox tox-pyenv - tox diff --git a/codebuild/py39/awses_1.7.1.yml b/codebuild/py39/awses_1.7.1.yml index 4da84dfa5..e261b5e4d 100644 --- a/codebuild/py39/awses_1.7.1.yml +++ b/codebuild/py39/awses_1.7.1.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py39/awses_2.0.0.yml b/codebuild/py39/awses_2.0.0.yml index cf8f90b36..b4a6654d5 100644 --- a/codebuild/py39/awses_2.0.0.yml +++ b/codebuild/py39/awses_2.0.0.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py39/awses_latest.yml b/codebuild/py39/awses_latest.yml index 9a2b12190..ac70cede8 100644 --- a/codebuild/py39/awses_latest.yml +++ b/codebuild/py39/awses_latest.yml @@ -20,8 +20,8 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - cd test_vector_handlers - tox diff --git a/codebuild/py39/examples.yml b/codebuild/py39/examples.yml index 38b1f01c7..9b1911024 100644 --- a/codebuild/py39/examples.yml +++ b/codebuild/py39/examples.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - tox diff --git a/codebuild/py39/integ.yml b/codebuild/py39/integ.yml index 49e8f6d1c..c7452e37e 100644 --- a/codebuild/py39/integ.yml +++ b/codebuild/py39/integ.yml @@ -18,7 +18,7 @@ phases: python: latest build: commands: - - pyenv install 3.9.0 - - pyenv local 3.9.0 + - pyenv install 3.9.7 + - pyenv local 3.9.7 - pip install tox tox-pyenv - tox diff --git a/decrypt_oracle/src/pylintrc b/decrypt_oracle/src/pylintrc index 8dcba5d63..2e1e6336e 100644 --- a/decrypt_oracle/src/pylintrc +++ b/decrypt_oracle/src/pylintrc @@ -3,6 +3,7 @@ disable = bad-continuation, # we let black handle this ungrouped-imports, # we let isort handle this + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/decrypt_oracle/test/pylintrc b/decrypt_oracle/test/pylintrc index bb64faf87..3d4a895b2 100644 --- a/decrypt_oracle/test/pylintrc +++ b/decrypt_oracle/test/pylintrc @@ -5,6 +5,7 @@ disable = missing-docstring, # we don't write docstrings for tests bad-continuation, # we let black handle this ungrouped-imports, # we let isort handle this + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/decrypt_oracle/tox.ini b/decrypt_oracle/tox.ini index ef39c65d2..b90d9f527 100644 --- a/decrypt_oracle/tox.ini +++ b/decrypt_oracle/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{35,36,37,38,39}-{local,integ}, + py{36,37,38,39}-{local,integ}, bandit, doc8, readme, docs, {flake8,pylint}{,-tests}, # prone to false positives diff --git a/examples/src/pylintrc b/examples/src/pylintrc index dcb72e849..858fa4d96 100644 --- a/examples/src/pylintrc +++ b/examples/src/pylintrc @@ -14,6 +14,7 @@ disable = attribute-defined-outside-init, # breaks with attrs_post_init abstract-method, # throws false positives on io.BaseIO grandchildren redefined-outer-name, # we do this on purpose in multiple places + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [BASIC] # Allow function names up to 50 characters diff --git a/examples/test/pylintrc b/examples/test/pylintrc index b30a3e202..67090eedf 100644 --- a/examples/test/pylintrc +++ b/examples/test/pylintrc @@ -7,6 +7,7 @@ disable = # unknown modules as non-standard-library. flake8 tests for this as well # and does treat them properly duplicate-code, # tests for similar things tend to be similar + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [VARIABLES] additional-builtins = raw_input diff --git a/setup.py b/setup.py index bfe48b091..2db856d89 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,6 @@ def get_requirements(): "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/src/aws_encryption_sdk/__init__.py b/src/aws_encryption_sdk/__init__.py index 0525f332d..661d41ee6 100644 --- a/src/aws_encryption_sdk/__init__.py +++ b/src/aws_encryption_sdk/__init__.py @@ -12,13 +12,13 @@ # language governing permissions and limitations under the License. """High level AWS Encryption SDK client functions.""" # Below are imported for ease of use by implementors - import warnings import attr from aws_encryption_sdk.caches.local import LocalCryptoMaterialsCache # noqa from aws_encryption_sdk.caches.null import NullCryptoMaterialsCache # noqa +from aws_encryption_sdk.compatability import _warn_deprecated_python from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError # noqa from aws_encryption_sdk.identifiers import Algorithm, CommitmentPolicy, __version__ # noqa from aws_encryption_sdk.internal.utils.signature import SignaturePolicy # noqa @@ -36,6 +36,8 @@ StreamEncryptor, ) +_warn_deprecated_python() + @attr.s(hash=True) class EncryptionSDKClientConfig(object): diff --git a/src/aws_encryption_sdk/compatability.py b/src/aws_encryption_sdk/compatability.py new file mode 100644 index 000000000..4dbc022d0 --- /dev/null +++ b/src/aws_encryption_sdk/compatability.py @@ -0,0 +1,39 @@ +# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Contains logic for checking ESDK and Python Version""" +import sys +import warnings + +DEPRECATION_DATE_MAP = {"1.x": "2022-06-30", "2.x": "2022-07-01"} + + +def _warn_deprecated_python(): + """Template for deprecation of Python warning.""" + deprecated_versions = { + (2, 7): {"date": DEPRECATION_DATE_MAP["2.x"]}, + (3, 4): {"date": DEPRECATION_DATE_MAP["2.x"]}, + (3, 5): {"date": "2021-11-10"}, + } + py_version = (sys.version_info.major, sys.version_info.minor) + minimum_version = (3, 6) + + if py_version in deprecated_versions: + params = deprecated_versions[py_version] + warning = ( + "aws-encryption-sdk will no longer support Python {}.{} " + "starting {}. To continue receiving service updates, " + "bug fixes, and security updates please upgrade to Python {}.{} or " + "later. For more information, see SUPPORT_POLICY.rst: " + "https://github.com/aws/aws-encryption-sdk-python/blob/master/SUPPORT_POLICY.rst" + ).format(py_version[0], py_version[1], minimum_version[0], minimum_version[1], params["date"]) + warnings.warn(warning, DeprecationWarning) diff --git a/src/aws_encryption_sdk/streaming_client.py b/src/aws_encryption_sdk/streaming_client.py index ac215c259..54eb046d2 100644 --- a/src/aws_encryption_sdk/streaming_client.py +++ b/src/aws_encryption_sdk/streaming_client.py @@ -70,7 +70,7 @@ _LOGGER = logging.getLogger(__name__) -@attr.s(hash=True) +@attr.s(hash=True) # pylint: disable=too-many-instance-attributes @six.add_metaclass(abc.ABCMeta) class _ClientConfig(object): # pylint: disable=too-many-instance-attributes """Parent configuration object for StreamEncryptor and StreamDecryptor objects. diff --git a/src/pylintrc b/src/pylintrc index 1919d76e5..d187a5ea8 100644 --- a/src/pylintrc +++ b/src/pylintrc @@ -14,6 +14,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [BASIC] # Allow function names up to 50 characters diff --git a/test/pylintrc b/test/pylintrc index 599a9e182..ceff0ad13 100644 --- a/test/pylintrc +++ b/test/pylintrc @@ -5,6 +5,7 @@ disable = missing-docstring, # we don't write docstrings for tests bad-continuation, # we let black handle this ungrouped-imports, # we let isort handle this + wrong-import-order, # we let isort handle this abstract-class-instantiated, # we do this on purpose to test that they are enforced no-member, # raised on patched objects with mock checks no-self-use, # common pattern when using pytest classes: can be enabled once all tests are refactored to pytest functions @@ -22,6 +23,8 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation + [VARIABLES] additional-builtins = raw_input diff --git a/test/unit/test_compatability.py b/test/unit/test_compatability.py new file mode 100644 index 000000000..f5e068a5c --- /dev/null +++ b/test/unit/test_compatability.py @@ -0,0 +1,109 @@ +# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +"""Unit test suite for aws_encryption_sdk.compatability""" +import os +import re +import sys + +import mock +import pytest +from typing import Mapping, Optional + +from aws_encryption_sdk.compatability import DEPRECATION_DATE_MAP, _warn_deprecated_python + +pytestmark = [pytest.mark.unit, pytest.mark.local] + + +def _parse_support_policy() -> Mapping[str, str]: + """Parses SUPPORT_POLICY.rst for Major Version Dates + + The code here is strongly tied to the format of SUPPORT_POLICY.rst. + If the format changes, this logic will need to be refactored as well. + + :rtype Mapping[str, str] + :return Mapping of keys from DEPRECATION_DATE_MAP to parsed date + """ + here = os.path.abspath(os.path.dirname(__file__)) + mv_date_line_offset = 3 + + def read(*args): + """Reads complete file contents.""" + return open(os.path.join(here, *args), encoding="utf-8").read() # pylint: disable=consider-using-with + + def _major_version_re_frmt(mvstr: str) -> str: + mv_str_lst = mvstr.split(".") + mv_str_lst.insert(1, r"\.") + return "".join(mv_str_lst) + + reg_mv_base = r"[\s]*\* - " # In support table, major versions are entered as "\t * - \d.x" + reg_date = re.compile(r"[\d]{4}-[\d]{2}-[\d]{2}") + mv_regs = {mv: re.compile(reg_mv_base + _major_version_re_frmt(mv)) for mv in DEPRECATION_DATE_MAP} + + def _match_mv_reg( # pylint: disable=inconsistent-return-statements + a_line: str, reg_exp, mvstr: str + ) -> Optional[str]: + """Match a Major Version string in a row of the support version table + :return None or Major Version String + """ + if reg_exp.match(a_line): + return mvstr + + def _match_mv_regs(a_line: str) -> Optional[str]: # pylint: disable=inconsistent-return-statements + """Check for any Major Version string in a row + :return None or Major Version String + """ + for mv in DEPRECATION_DATE_MAP: + return_str = _match_mv_reg(a_line, mv_regs[mv], mv) + if return_str: + return return_str + + map_mvstr_date = {} + support_policy = read("../../SUPPORT_POLICY.rst").splitlines() + for line_number, line in enumerate(support_policy): + a_mv = _match_mv_regs(line) + if a_mv: + map_mvstr_date[a_mv] = reg_date.search(support_policy[line_number + mv_date_line_offset]).group() + return map_mvstr_date + + +@pytest.fixture(scope="module") +def parsed_deprecation_date_map(): + try: + return _parse_support_policy() + except Exception: + raise RuntimeError( + "The Format of SUPPORT_POLICY.rst has changed! " "The logic in test_compatability must be updated!" + ) + + +def test_deprecation_date_map_accurate(parsed_deprecation_date_map): + assert ( + parsed_deprecation_date_map == DEPRECATION_DATE_MAP + ), "The DEPRECATION_DATE_MAP in aws_encryption_sdk.compatability is not accurate!" + + +class TestWarnDeprecatedPython: + def test_happy_version(self): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = 3 + v_info.minor = 6 + with pytest.warns(None) as record: + _warn_deprecated_python() + assert len(record) == 0 + + def test_below_warn(self): + with mock.patch.object(sys, "version_info") as v_info: + v_info.major = 2 + v_info.minor = 7 + with pytest.warns(DeprecationWarning): + _warn_deprecated_python() diff --git a/test_vector_handlers/src/pylintrc b/test_vector_handlers/src/pylintrc index ebd2eb02e..c78fe416a 100644 --- a/test_vector_handlers/src/pylintrc +++ b/test_vector_handlers/src/pylintrc @@ -8,6 +8,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/test_vector_handlers/test/pylintrc b/test_vector_handlers/test/pylintrc index 5aa03d3ae..bc118f899 100644 --- a/test_vector_handlers/test/pylintrc +++ b/test_vector_handlers/test/pylintrc @@ -11,6 +11,7 @@ disable = useless-object-inheritance, raise-missing-from, super-with-arguments, + consider-using-f-string # disable until 2022-05-05; 6 months after 3.5 deprecation [FORMAT] max-line-length = 120 diff --git a/test_vector_handlers/tox.ini b/test_vector_handlers/tox.ini index 41920d76d..7418b2e98 100644 --- a/test_vector_handlers/tox.ini +++ b/test_vector_handlers/tox.ini @@ -2,7 +2,7 @@ envlist = # The test vectors depend on new features now, # so until release we can only effectively test the local version of the ESDK. - py{35,36,37,38,39}-awses_local, + py{35,36,37,38,39,310}-awses_local, # 1.2.0 and 1.2.max are being difficult because of attrs bandit, doc8, readme, docs, {flake8,pylint}{,-tests}, diff --git a/tox.ini b/tox.ini index 110ae7263..f6a293f0c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{35,36,37,38,39}-{local,integ,accept,examples}, nocmk, + py{36,37,38,39,310}-{local,integ,accept,examples}, nocmk, bandit, doc8, readme, docs, {flake8,pylint}{,-tests,-examples}, isort-check, black-check, @@ -318,7 +318,7 @@ commands = # Release tooling [testenv:park] -basepython = python3.6 +basepython = python3.7 skip_install = true deps = pypi-parker