Skip to content

Commit

Permalink
Remove Py3.6 support (#5818)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Jan 6, 2023
1 parent bf962f7 commit 89fdf9d
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 84 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ on: [push, pull_request]
jobs:
cache:
name: Caching
# Change to ubuntu-latest after dropping Py3.6
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
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:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -42,7 +41,7 @@ jobs:
needs: cache
strategy:
matrix:
python-version: [3.7]
python-version: [3.9]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -73,12 +72,12 @@ jobs:

test:
name: Unit test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
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:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -117,12 +116,12 @@ jobs:

testserver:
name: Unit tests in Server Mode
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
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:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
codecov:
notify:
# Leave a GitHub comment after all builds have passed
after_n_builds: 12
after_n_builds: 10
coverage:
status:
project:
Expand Down
2 changes: 1 addition & 1 deletion moto/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def stop(self) -> None:
try:
self.default_session_mock.stop()
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
pass
self.unmock_env_variables()
Expand Down
2 changes: 0 additions & 2 deletions moto/dynamodb/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,6 @@ def update_table_global_indexes(self, name, global_index_updates):
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())
return table

Expand Down
6 changes: 1 addition & 5 deletions moto/iam/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import base64
import os
import string
import sys
from datetime import datetime
import json
import re
Expand Down Expand Up @@ -2399,10 +2398,7 @@ def upload_signing_certificate(self, user_name, body):

# Validate the signing cert:
try:
if sys.version_info < (3, 0):
data = bytes(body)
else:
data = bytes(body, "utf8")
data = bytes(body, "utf8")

x509.load_pem_x509_certificate(data, default_backend())

Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def get_version():
_dep_python_jose_ecdsa_pin = (
"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_graphql = "graphql-core"
_dep_jsondiff = "jsondiff>=1.1.2"
Expand Down Expand Up @@ -96,7 +95,7 @@ def get_version():
"ses": [],
"sns": [],
"sqs": [],
"ssm": [_dep_PyYAML, _dep_dataclasses],
"ssm": [_dep_PyYAML],
# XRay module uses pkg_resources, but doesn't have an explicit
# dependency listed. This should be fixed in the next version:
# https://github.com/aws/aws-xray-sdk-python/issues/305
Expand Down Expand Up @@ -137,15 +136,14 @@ def get_version():
url="https://github.com/spulec/moto",
entry_points={"console_scripts": ["moto_server = moto.server:main"]},
packages=find_packages(exclude=("tests", "tests.*")),
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=install_requires,
extras_require=extras_require,
include_package_data=True,
license="Apache License 2.0",
test_suite="tests",
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
5 changes: 0 additions & 5 deletions tests/test_amp/test_amp_logging_config.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import boto3
import sys
import unittest
from moto import mock_amp


@mock_amp
class TestAmpLoggingConfig(unittest.TestCase):
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")

workspace = self.client.create_workspace(alias="test", tags={"t": "v"})
Expand Down
7 changes: 0 additions & 7 deletions tests/test_ec2/test_customer_gateways.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import boto3
import pytest
import sure # noqa # pylint: disable=unused-import
import sys

from botocore.exceptions import ClientError
from moto import mock_ec2
from unittest import SkipTest


@mock_ec2
Expand All @@ -21,11 +19,6 @@ def test_create_customer_gateways():

@mock_ec2
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")

# The PublicIp-argument is deprecated, but should still be supported by Moto
Expand Down
13 changes: 0 additions & 13 deletions tests/test_ec2/test_vpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import sure # noqa # pylint: disable=unused-import
import random
import sys

from moto import mock_ec2, settings
from unittest import SkipTest
Expand Down Expand Up @@ -361,10 +360,6 @@ def test_vpc_get_by_tag_value_subset():

@mock_ec2
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")

# Create the default VPC
Expand Down Expand Up @@ -392,10 +387,6 @@ def test_default_vpc():

@mock_ec2
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")

# Create the default VPC - this already exists when backend instantiated!
Expand Down Expand Up @@ -512,10 +503,6 @@ def test_vpc_modify_enable_dns_hostnames():

@mock_ec2
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")

# Create the default VPC
Expand Down
30 changes: 2 additions & 28 deletions tests/test_efs/test_mount_target.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import sys
from ipaddress import IPv4Network

import pytest
Expand All @@ -10,31 +9,6 @@
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")
def fixture_file_system(efs):
create_fs_resp = efs.create_file_system(CreationToken="foobarbaz")
Expand Down Expand Up @@ -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["VpcId"] == subnet["VpcId"]
assert create_mt_resp["SubnetId"] == subnet_id
assert is_subnet_of(
IPv4Network(create_mt_resp["IpAddress"]), IPv4Network(subnet["CidrBlock"])
assert IPv4Network(create_mt_resp["IpAddress"]).subnet_of(
IPv4Network(subnet["CidrBlock"])
)
assert create_mt_resp["FileSystemId"] == file_system_id
assert create_mt_resp["OwnerId"] == ACCOUNT_ID
Expand Down
10 changes: 0 additions & 10 deletions tests/test_iam/test_iam.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import sys

import boto3
import csv
Expand All @@ -16,7 +15,6 @@
from datetime import datetime
from uuid import uuid4
from urllib import parse
from unittest import SkipTest

from moto.s3.responses import DEFAULT_REGION_NAME

Expand Down Expand Up @@ -3782,10 +3780,6 @@ def test_role_config_dict():
@mock_iam
@mock_config
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

CONFIG_REGIONS = boto3.Session().get_available_regions("config")
Expand Down Expand Up @@ -4230,10 +4224,6 @@ def test_policy_config_dict():
@mock_iam
@mock_config
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

CONFIG_REGIONS = boto3.Session().get_available_regions("config")
Expand Down

0 comments on commit 89fdf9d

Please sign in to comment.