Remove Py3.6 support (#5818)

This commit is contained in:
Bert Blommers 2023-01-06 12:07:20 +00:00 committed by GitHub
parent bf962f7f44
commit 89fdf9dbcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 14 additions and 84 deletions

View File

@ -5,11 +5,10 @@ on: [push, pull_request]
jobs: jobs:
cache: cache:
name: Caching name: Caching
# Change to ubuntu-latest after dropping Py3.6 runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9, "3.10", "3.11" ] python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11" ]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -42,7 +41,7 @@ jobs:
needs: cache needs: cache
strategy: strategy:
matrix: matrix:
python-version: [3.7] python-version: [3.9]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
@ -73,12 +72,12 @@ jobs:
test: test:
name: Unit test name: Unit test
runs-on: ubuntu-20.04 runs-on: ubuntu-latest
needs: lint needs: lint
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"] python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -117,12 +116,12 @@ jobs:
testserver: testserver:
name: Unit tests in Server Mode name: Unit tests in Server Mode
runs-on: ubuntu-20.04 runs-on: ubuntu-latest
needs: lint needs: lint
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"] python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View File

@ -1,7 +1,7 @@
codecov: codecov:
notify: notify:
# Leave a GitHub comment after all builds have passed # Leave a GitHub comment after all builds have passed
after_n_builds: 12 after_n_builds: 10
coverage: coverage:
status: status:
project: project:

View File

@ -99,7 +99,7 @@ class BaseMockAWS:
try: try:
self.default_session_mock.stop() self.default_session_mock.stop()
except RuntimeError: except RuntimeError:
# We only need to check for this exception in Python 3.6 and 3.7 # We only need to check for this exception in Python 3.7
# https://bugs.python.org/issue36366 # https://bugs.python.org/issue36366
pass pass
self.unmock_env_variables() self.unmock_env_variables()

View File

@ -1351,8 +1351,6 @@ class DynamoDBBackend(BaseBackend):
gsi_to_create, table.table_key_attrs gsi_to_create, table.table_key_attrs
) )
# in python 3.6, dict.values() returns a dict_values object, but we expect it to be a list in other
# parts of the codebase
table.global_indexes = list(gsis_by_name.values()) table.global_indexes = list(gsis_by_name.values())
return table return table

View File

@ -1,7 +1,6 @@
import base64 import base64
import os import os
import string import string
import sys
from datetime import datetime from datetime import datetime
import json import json
import re import re
@ -2399,10 +2398,7 @@ class IAMBackend(BaseBackend):
# Validate the signing cert: # Validate the signing cert:
try: try:
if sys.version_info < (3, 0): data = bytes(body, "utf8")
data = bytes(body)
else:
data = bytes(body, "utf8")
x509.load_pem_x509_certificate(data, default_backend()) x509.load_pem_x509_certificate(data, default_backend())

View File

@ -45,7 +45,6 @@ _dep_python_jose = "python-jose[cryptography]>=3.1.0,<4.0.0"
_dep_python_jose_ecdsa_pin = ( _dep_python_jose_ecdsa_pin = (
"ecdsa!=0.15" # https://github.com/spulec/moto/pull/3263#discussion_r477404984 "ecdsa!=0.15" # https://github.com/spulec/moto/pull/3263#discussion_r477404984
) )
_dep_dataclasses = "dataclasses; python_version < '3.7'"
_dep_docker = "docker>=2.5.1" _dep_docker = "docker>=2.5.1"
_dep_graphql = "graphql-core" _dep_graphql = "graphql-core"
_dep_jsondiff = "jsondiff>=1.1.2" _dep_jsondiff = "jsondiff>=1.1.2"
@ -96,7 +95,7 @@ extras_per_service.update(
"ses": [], "ses": [],
"sns": [], "sns": [],
"sqs": [], "sqs": [],
"ssm": [_dep_PyYAML, _dep_dataclasses], "ssm": [_dep_PyYAML],
# XRay module uses pkg_resources, but doesn't have an explicit # XRay module uses pkg_resources, but doesn't have an explicit
# dependency listed. This should be fixed in the next version: # dependency listed. This should be fixed in the next version:
# https://github.com/aws/aws-xray-sdk-python/issues/305 # https://github.com/aws/aws-xray-sdk-python/issues/305
@ -137,7 +136,7 @@ setup(
url="https://github.com/spulec/moto", url="https://github.com/spulec/moto",
entry_points={"console_scripts": ["moto_server = moto.server:main"]}, entry_points={"console_scripts": ["moto_server = moto.server:main"]},
packages=find_packages(exclude=("tests", "tests.*")), packages=find_packages(exclude=("tests", "tests.*")),
python_requires=">=3.6", python_requires=">=3.7",
install_requires=install_requires, install_requires=install_requires,
extras_require=extras_require, extras_require=extras_require,
include_package_data=True, include_package_data=True,
@ -145,7 +144,6 @@ setup(
test_suite="tests", test_suite="tests",
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",

View File

@ -1,5 +1,4 @@
import boto3 import boto3
import sys
import unittest import unittest
from moto import mock_amp from moto import mock_amp
@ -7,10 +6,6 @@ from moto import mock_amp
@mock_amp @mock_amp
class TestAmpLoggingConfig(unittest.TestCase): class TestAmpLoggingConfig(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:
if sys.version_info < (3, 7):
raise unittest.SkipTest(
"Cannot test this in Py3.6; outdated botocore dependencies do not yet support this feature"
)
self.client = boto3.client("amp", region_name="us-east-2") self.client = boto3.client("amp", region_name="us-east-2")
workspace = self.client.create_workspace(alias="test", tags={"t": "v"}) workspace = self.client.create_workspace(alias="test", tags={"t": "v"})

View File

@ -1,11 +1,9 @@
import boto3 import boto3
import pytest import pytest
import sure # noqa # pylint: disable=unused-import import sure # noqa # pylint: disable=unused-import
import sys
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
from moto import mock_ec2 from moto import mock_ec2
from unittest import SkipTest
@mock_ec2 @mock_ec2
@ -21,11 +19,6 @@ def test_create_customer_gateways():
@mock_ec2 @mock_ec2
def test_create_customer_gateways_using_publicip_argument(): def test_create_customer_gateways_using_publicip_argument():
version_info = sys.version_info
if version_info.major == 3 and version_info.minor <= 6:
raise SkipTest(
"Py 3.6 has an older versions of botocore, and does not support the IpAddress-argument"
)
ec2 = boto3.client("ec2", region_name="us-east-1") ec2 = boto3.client("ec2", region_name="us-east-1")
# The PublicIp-argument is deprecated, but should still be supported by Moto # The PublicIp-argument is deprecated, but should still be supported by Moto

View File

@ -5,7 +5,6 @@ import boto3
import sure # noqa # pylint: disable=unused-import import sure # noqa # pylint: disable=unused-import
import random import random
import sys
from moto import mock_ec2, settings from moto import mock_ec2, settings
from unittest import SkipTest from unittest import SkipTest
@ -361,10 +360,6 @@ def test_vpc_get_by_tag_value_subset():
@mock_ec2 @mock_ec2
def test_default_vpc(): def test_default_vpc():
if sys.version_info < (3, 7):
raise SkipTest(
"Cannot test this in Py3.6; outdated botocore dependencies do not have all regions"
)
ec2 = boto3.resource("ec2", region_name="us-west-1") ec2 = boto3.resource("ec2", region_name="us-west-1")
# Create the default VPC # Create the default VPC
@ -392,10 +387,6 @@ def test_default_vpc():
@mock_ec2 @mock_ec2
def test_non_default_vpc(): def test_non_default_vpc():
if sys.version_info < (3, 7):
raise SkipTest(
"Cannot test this in Py3.6; outdated botocore dependencies do not have all regions"
)
ec2 = boto3.resource("ec2", region_name="us-west-1") ec2 = boto3.resource("ec2", region_name="us-west-1")
# Create the default VPC - this already exists when backend instantiated! # Create the default VPC - this already exists when backend instantiated!
@ -512,10 +503,6 @@ def test_vpc_modify_enable_dns_hostnames():
@mock_ec2 @mock_ec2
def test_vpc_modify_enable_network_address_usage_metrics(): def test_vpc_modify_enable_network_address_usage_metrics():
if sys.version_info < (3, 7):
raise SkipTest(
"Cannot test this in Py3.6; outdated botocore dependencies do not have all regions"
)
ec2 = boto3.resource("ec2", region_name="us-west-1") ec2 = boto3.resource("ec2", region_name="us-west-1")
# Create the default VPC # Create the default VPC

View File

@ -1,5 +1,4 @@
import re import re
import sys
from ipaddress import IPv4Network from ipaddress import IPv4Network
import pytest import pytest
@ -10,31 +9,6 @@ from tests.test_efs.junk_drawer import has_status_code
from . import fixture_ec2, fixture_efs # noqa # pylint: disable=unused-import from . import fixture_ec2, fixture_efs # noqa # pylint: disable=unused-import
# Handle the fact that `subnet_of` is not a feature before 3.7.
# Source for alternative version: https://github.com/python/cpython/blob/v3.7.0/Lib/ipaddress.py#L976
# Discovered via: https://stackoverflow.com/questions/35115138/how-do-i-check-if-a-network-is-contained-in-another-network-in-python
if sys.version_info.major >= 3 and sys.version_info.minor >= 7:
def is_subnet_of(a, b):
return a.subnet_of(b)
else:
def is_subnet_of(a, b):
try:
# Always false if one is v4 and the other is v6.
if a._version != b._version:
raise TypeError(f"{a} and {b} are not of the same version")
return (
b.network_address <= a.network_address
and b.broadcast_address >= a.broadcast_address
)
except AttributeError:
raise TypeError(
f"Unable to test subnet containment " f"between {a} and {b}"
)
@pytest.fixture(scope="function", name="file_system") @pytest.fixture(scope="function", name="file_system")
def fixture_file_system(efs): def fixture_file_system(efs):
create_fs_resp = efs.create_file_system(CreationToken="foobarbaz") create_fs_resp = efs.create_file_system(CreationToken="foobarbaz")
@ -69,8 +43,8 @@ def test_create_mount_target_minimal_correct_use(efs, file_system, subnet):
assert create_mt_resp["AvailabilityZoneName"] == subnet["AvailabilityZone"] assert create_mt_resp["AvailabilityZoneName"] == subnet["AvailabilityZone"]
assert create_mt_resp["VpcId"] == subnet["VpcId"] assert create_mt_resp["VpcId"] == subnet["VpcId"]
assert create_mt_resp["SubnetId"] == subnet_id assert create_mt_resp["SubnetId"] == subnet_id
assert is_subnet_of( assert IPv4Network(create_mt_resp["IpAddress"]).subnet_of(
IPv4Network(create_mt_resp["IpAddress"]), IPv4Network(subnet["CidrBlock"]) IPv4Network(subnet["CidrBlock"])
) )
assert create_mt_resp["FileSystemId"] == file_system_id assert create_mt_resp["FileSystemId"] == file_system_id
assert create_mt_resp["OwnerId"] == ACCOUNT_ID assert create_mt_resp["OwnerId"] == ACCOUNT_ID

View File

@ -1,5 +1,4 @@
import json import json
import sys
import boto3 import boto3
import csv import csv
@ -16,7 +15,6 @@ import pytest
from datetime import datetime from datetime import datetime
from uuid import uuid4 from uuid import uuid4
from urllib import parse from urllib import parse
from unittest import SkipTest
from moto.s3.responses import DEFAULT_REGION_NAME from moto.s3.responses import DEFAULT_REGION_NAME
@ -3782,10 +3780,6 @@ def test_role_config_dict():
@mock_iam @mock_iam
@mock_config @mock_config
def test_role_config_client(): def test_role_config_client():
if sys.version_info < (3, 7):
raise SkipTest(
"Cannot test this in Py3.6; outdated botocore dependencies do not have all regions"
)
from moto.iam.utils import random_role_id from moto.iam.utils import random_role_id
CONFIG_REGIONS = boto3.Session().get_available_regions("config") CONFIG_REGIONS = boto3.Session().get_available_regions("config")
@ -4230,10 +4224,6 @@ def test_policy_config_dict():
@mock_iam @mock_iam
@mock_config @mock_config
def test_policy_config_client(): def test_policy_config_client():
if sys.version_info < (3, 7):
raise SkipTest(
"Cannot test this in Py3.6; outdated botocore dependencies do not have all regions"
)
from moto.iam.utils import random_policy_id from moto.iam.utils import random_policy_id
CONFIG_REGIONS = boto3.Session().get_available_regions("config") CONFIG_REGIONS = boto3.Session().get_available_regions("config")