diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b21c39d89..b1f82c63f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,6 @@ jobs: os: - ubuntu-latest python: - - "3.7" - "3.8" - "3.9" - "3.10" diff --git a/DEVELOPMENT_GUIDE.md b/DEVELOPMENT_GUIDE.md index 6d3ecac38..2a89debf6 100644 --- a/DEVELOPMENT_GUIDE.md +++ b/DEVELOPMENT_GUIDE.md @@ -26,7 +26,7 @@ Environment setup ----------------- ### 1. Install Python versions -Our officially supported Python versions are 3.7, 3.8, 3.9 and 3.10. +Our officially supported Python versions are 3.8, 3.9 and 3.10. Our CI/CD pipeline is setup to run unit tests against Python 3 versions. Make sure you test it before sending a Pull Request. See [Unit testing with multiple Python versions](#unit-testing-with-multiple-python-versions). @@ -40,12 +40,11 @@ easily setup multiple Python versions. For 1. Install PyEnv - `curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash` 1. Restart shell so the path changes take effect - `exec $SHELL` -1. `pyenv install 3.7.16` 1. `pyenv install 3.8.16` 1. `pyenv install 3.9.16` 1. `pyenv install 3.10.9` 3. Make Python versions available in the project: - `pyenv local 3.7.16 3.8.16 3.9.16 3.10.9` + `pyenv local 3.8.16 3.9.16 3.10.9` Note: also make sure the following lines were written into your `.bashrc` (or `.zshrc`, depending on which shell you are using): ``` @@ -66,7 +65,7 @@ can be found [here](https://black.readthedocs.io/en/stable/editor_integration.ht Since black is installed in virtualenv, when you follow [this instruction](https://black.readthedocs.io/en/stable/editor_integration.html), `which black` might give you this ```bash -(sam37) $ where black +(sam38) $ where black /Users//.pyenv/shims/black ``` @@ -77,11 +76,11 @@ and this will happen: pyenv: black: command not found The `black' command exists in these Python versions: - 3.7.9/envs/sam37 - sam37 + 3.8.16/envs/sam38 + sam38 ``` -A simple workaround is to use `/Users//.pyenv/versions/sam37/bin/black` +A simple workaround is to use `/Users//.pyenv/versions/sam38/bin/black` instead of `/Users//.pyenv/shims/black`. #### Pre-commit @@ -99,15 +98,15 @@ handy plugin that can create virtualenv. Depending on the python version, the following commands would change to be the appropriate python version. -1. Create Virtualenv `sam37` for Python3.7: `pyenv virtualenv 3.7.9 sam37` -1. Activate Virtualenv: `pyenv activate sam37` +1. Create Virtualenv `sam38` for Python3.8: `pyenv virtualenv 3.8.16 sam38` +1. Activate Virtualenv: `pyenv activate sam38` ### 4. Install dev version of SAM transform We will install a development version of SAM transform from source into the virtualenv. -1. Activate Virtualenv: `pyenv activate sam37` +1. Activate Virtualenv: `pyenv activate sam38` 1. Install dev version of SAM transform: `make init` Running tests @@ -121,8 +120,8 @@ Run `make test` or `make test-fast`. Once all tests pass make sure to run ### Unit testing with multiple Python versions -Currently, our officially supported Python versions are 3.7, 3.8, 3.9 and 3.10. For the most -part, code that works in Python3.7 will work in Pythons 3.8, 3.9 and 3.10. You only run into problems if you are +Currently, our officially supported Python versions are 3.8, 3.9 and 3.10. For the most +part, code that works in Python3.8 will work in Pythons 3.9 and 3.10. You only run into problems if you are trying to use features released in a higher version (for example features introduced into Python3.10 will not work in Python3.9). If you want to test in many versions, you can create a virtualenv for each version and flip between them (sourcing the activate script). Typically, we run all tests in diff --git a/HOWTO.md b/HOWTO.md index 44bc1c32b..f4162e905 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -21,7 +21,7 @@ Check out the [latest specification](versions/2016-10-31.md) for details on how You could also use the [aws-sam-cli](https://github.com/awslabs/aws-sam-cli) to get started ```shell -$ sam init --runtime python3.7 +$ sam init --runtime python3.8 ``` ## Packing Artifacts Before you can deploy a SAM template, you should first upload your Lambda diff --git a/README.md b/README.md index 26cc8f8f8..d2372075a 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ For a more thorough introduction, see the [this tutorial](https://docs.aws.amazo ### Setting up development environment -You'll need to have Python 3.7+ installed. +You'll need to have Python 3.8+ installed. Create a [virtual environment](https://docs.python.org/3/library/venv.html): diff --git a/bin/transform-test-error-json-format.py b/bin/transform-test-error-json-format.py index 6eb9335b0..998fa2bf6 100755 --- a/bin/transform-test-error-json-format.py +++ b/bin/transform-test-error-json-format.py @@ -8,13 +8,11 @@ import sys from pathlib import Path -from typing_extensions import Final - # To allow this script to be executed from other directories sys.path.insert(0, str(Path(__file__).absolute().parent.parent)) import json -from typing import Type +from typing import Final, Type from bin._file_formatter import FileFormatter diff --git a/integration/helpers/deployer/utils/colors.py b/integration/helpers/deployer/utils/colors.py index 792cb4996..3e1f90d0e 100644 --- a/integration/helpers/deployer/utils/colors.py +++ b/integration/helpers/deployer/utils/colors.py @@ -2,9 +2,7 @@ Wrapper to generated colored messages for printing in Terminal This was ported over from the sam-cli repo """ -from typing import Dict - -from typing_extensions import Literal +from typing import Dict, Literal SupportedColor = Literal["red", "green", "yellow"] diff --git a/integration/ruff.toml b/integration/ruff.toml index 620f9a8a9..f295c2fe8 100644 --- a/integration/ruff.toml +++ b/integration/ruff.toml @@ -15,8 +15,8 @@ select = [ "UP", # pyupgrade ] -# Mininal python version we support is 3.7 -target-version = "py37" +# Mininal python version we support is 3.8 +target-version = "py38" [per-file-ignores] diff --git a/pyproject.toml b/pyproject.toml index 327062a14..bb5eabbf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 120 -target_version = ['py37', 'py38', 'py39', 'py310'] +target_version = ['py38', 'py39', 'py310'] exclude = ''' ( diff --git a/pytest.ini b/pytest.ini index c130f7c2a..cd1ec10a7 100644 --- a/pytest.ini +++ b/pytest.ini @@ -14,8 +14,6 @@ filterwarnings = # From our own tests ignore:__init__ is deprecated and will be removed in a future release:DeprecationWarning ignore:deprecated_function is deprecated and will be removed in a future release, please use replacement_function:DeprecationWarning - # Python 3.7 deprecation - ignore::boto3.exceptions.PythonDeprecationWarning # https://github.com/pytest-dev/pytest-xdist/issues/825#issuecomment-1292450429 ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning # Pytest warnings diff --git a/requirements/base.txt b/requirements/base.txt index 92cc18dba..44387bcb1 100755 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,6 +1,6 @@ boto3>=1.19.5,==1.* jsonschema<5,>=3.2 # TODO: evaluate risk of removing jsonschema 3.x support -typing_extensions>=4.4,<5 # 3.7 doesn't have Literal +typing_extensions>=4.4 # 3.8 doesn't have Required, TypeGuard and ParamSpec # resource validation & schema generation pydantic>=1.8,<3 diff --git a/requirements/dev.txt b/requirements/dev.txt index 08e09c746..15caa7fa6 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -19,7 +19,7 @@ tenacity~=8.0 requests~=2.28 # formatter -black==23.3.0 # 23.3.0 is the last version supporting python 3.7 +black==23.10.1 ruamel.yaml==0.17.21 # It can parse yaml while perserving comments # type check @@ -29,7 +29,3 @@ mypy~=1.3.0 boto3-stubs[appconfig,serverlessrepo]>=1.19.5,==1.* types-PyYAML~=6.0 types-jsonschema~=3.2 - -# Check package version (backport importlib.metadata for python 3.7) -# https://docs.python.org/3/library/importlib.metadata.html -importlib_metadata; python_version < '3.8' diff --git a/ruff.toml b/ruff.toml index 65497d23e..48bf5e4eb 100644 --- a/ruff.toml +++ b/ruff.toml @@ -37,8 +37,8 @@ ignore = [ "G004", ] -# Mininal python version we support is 3.7 -target-version = "py37" +# Mininal python version we support is 3.8 +target-version = "py38" [per-file-ignores] # python scripts in bin/ needs some python path configurations before import diff --git a/samtranslator/internal/model/appsync.py b/samtranslator/internal/model/appsync.py index afd3a8eb2..5182db1a7 100644 --- a/samtranslator/internal/model/appsync.py +++ b/samtranslator/internal/model/appsync.py @@ -1,6 +1,6 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TypedDict, Union -from typing_extensions import Required, TypedDict +from typing_extensions import Required from samtranslator.model import GeneratedProperty, Resource from samtranslator.model.intrinsics import fnGetAtt, ref diff --git a/samtranslator/internal/schema_source/aws_serverless_api.py b/samtranslator/internal/schema_source/aws_serverless_api.py index 0baaca700..f94cc0b08 100644 --- a/samtranslator/internal/schema_source/aws_serverless_api.py +++ b/samtranslator/internal/schema_source/aws_serverless_api.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Dict, List, Optional, Union - -from typing_extensions import Literal +from typing import Dict, List, Literal, Optional, Union from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector from samtranslator.internal.schema_source.common import ( diff --git a/samtranslator/internal/schema_source/aws_serverless_application.py b/samtranslator/internal/schema_source/aws_serverless_application.py index 0c6e486ca..7079ca17c 100644 --- a/samtranslator/internal/schema_source/aws_serverless_application.py +++ b/samtranslator/internal/schema_source/aws_serverless_application.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Any, Dict, Optional, Union - -from typing_extensions import Literal +from typing import Any, Dict, Literal, Optional, Union from samtranslator.internal.schema_source.common import ( BaseModel, diff --git a/samtranslator/internal/schema_source/aws_serverless_connector.py b/samtranslator/internal/schema_source/aws_serverless_connector.py index 4142378a6..76b596cb9 100644 --- a/samtranslator/internal/schema_source/aws_serverless_connector.py +++ b/samtranslator/internal/schema_source/aws_serverless_connector.py @@ -1,6 +1,4 @@ -from typing import List, Optional, Union - -from typing_extensions import Literal +from typing import List, Literal, Optional, Union from samtranslator.internal.schema_source.common import ( BaseModel, diff --git a/samtranslator/internal/schema_source/aws_serverless_function.py b/samtranslator/internal/schema_source/aws_serverless_function.py index 1fd65b153..4f5731223 100644 --- a/samtranslator/internal/schema_source/aws_serverless_function.py +++ b/samtranslator/internal/schema_source/aws_serverless_function.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Dict, List, Optional, Union - -from typing_extensions import Literal +from typing import Dict, List, Literal, Optional, Union from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector from samtranslator.internal.schema_source.common import ( diff --git a/samtranslator/internal/schema_source/aws_serverless_graphqlapi.py b/samtranslator/internal/schema_source/aws_serverless_graphqlapi.py index 03da4e187..541e4a7e3 100644 --- a/samtranslator/internal/schema_source/aws_serverless_graphqlapi.py +++ b/samtranslator/internal/schema_source/aws_serverless_graphqlapi.py @@ -1,6 +1,4 @@ -from typing import Dict, List, Optional, Union - -from typing_extensions import Literal +from typing import Dict, List, Literal, Optional, Union from samtranslator.internal.schema_source.common import ( BaseModel, diff --git a/samtranslator/internal/schema_source/aws_serverless_httpapi.py b/samtranslator/internal/schema_source/aws_serverless_httpapi.py index 57605eba1..c658527eb 100644 --- a/samtranslator/internal/schema_source/aws_serverless_httpapi.py +++ b/samtranslator/internal/schema_source/aws_serverless_httpapi.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Dict, List, Optional, Union - -from typing_extensions import Literal +from typing import Dict, List, Literal, Optional, Union from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector from samtranslator.internal.schema_source.common import ( diff --git a/samtranslator/internal/schema_source/aws_serverless_layerversion.py b/samtranslator/internal/schema_source/aws_serverless_layerversion.py index 162a6f562..96523fd56 100644 --- a/samtranslator/internal/schema_source/aws_serverless_layerversion.py +++ b/samtranslator/internal/schema_source/aws_serverless_layerversion.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Optional, Union - -from typing_extensions import Literal +from typing import Literal, Optional, Union from samtranslator.internal.schema_source.common import ( BaseModel, diff --git a/samtranslator/internal/schema_source/aws_serverless_simpletable.py b/samtranslator/internal/schema_source/aws_serverless_simpletable.py index f046199de..c21f9b9d7 100644 --- a/samtranslator/internal/schema_source/aws_serverless_simpletable.py +++ b/samtranslator/internal/schema_source/aws_serverless_simpletable.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Any, Dict, Optional - -from typing_extensions import Literal +from typing import Any, Dict, Literal, Optional from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector from samtranslator.internal.schema_source.common import ( diff --git a/samtranslator/internal/schema_source/aws_serverless_statemachine.py b/samtranslator/internal/schema_source/aws_serverless_statemachine.py index 041392b93..9e6a549e9 100644 --- a/samtranslator/internal/schema_source/aws_serverless_statemachine.py +++ b/samtranslator/internal/schema_source/aws_serverless_statemachine.py @@ -1,8 +1,6 @@ from __future__ import annotations -from typing import Dict, List, Optional, Union - -from typing_extensions import Literal +from typing import Dict, List, Literal, Optional, Union from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector from samtranslator.internal.schema_source.common import ( diff --git a/samtranslator/internal/schema_source/common.py b/samtranslator/internal/schema_source/common.py index b74e3877c..617f8f414 100644 --- a/samtranslator/internal/schema_source/common.py +++ b/samtranslator/internal/schema_source/common.py @@ -1,9 +1,7 @@ import json from functools import partial from pathlib import Path -from typing import Any, Dict, List, Optional, TypeVar, Union - -from typing_extensions import Literal +from typing import Any, Dict, List, Literal, Optional, TypeVar, Union from samtranslator.compat import pydantic from samtranslator.model.types import PassThrough diff --git a/samtranslator/metrics/metrics.py b/samtranslator/metrics/metrics.py index cb9600f45..d026e9c13 100644 --- a/samtranslator/metrics/metrics.py +++ b/samtranslator/metrics/metrics.py @@ -4,9 +4,7 @@ import logging from abc import ABC, abstractmethod from datetime import datetime -from typing import Any, Dict, List, Optional, Union - -from typing_extensions import TypedDict +from typing import Any, Dict, List, Optional, TypedDict, Union from samtranslator.internal.deprecation_control import deprecated diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index 68d9a9e4d..8aac0c484 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -1,9 +1,7 @@ """ SAM macro definitions """ import copy from contextlib import suppress -from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast - -from typing_extensions import Literal +from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, cast import samtranslator.model.eventsources import samtranslator.model.eventsources.cloudwatchlogs diff --git a/setup.py b/setup.py index 4eb35022d..69a68d14d 100755 --- a/setup.py +++ b/setup.py @@ -78,7 +78,7 @@ def read_requirements(req="base.txt"): "NOTICE", "THIRD_PARTY_LICENSES", ), - python_requires=">=3.7, <=4.0, !=4.0", + python_requires=">=3.8, <=4.0, !=4.0", install_requires=read_requirements("base.txt"), include_package_data=True, extras_require={"dev": read_requirements("dev.txt")}, @@ -93,7 +93,6 @@ def read_requirements(req="base.txt"): "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/tests/ruff.toml b/tests/ruff.toml index 68c1f4b3c..b9c75dbf3 100644 --- a/tests/ruff.toml +++ b/tests/ruff.toml @@ -15,8 +15,8 @@ select = [ "UP", # pyupgrade ] -# Mininal python version we support is 3.7 -target-version = "py37" +# Mininal python version we support is 3.8 +target-version = "py38" [per-file-ignores]