diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2211ffd9..6d934b0bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,7 @@ jobs: - "3.11" - "3.12" - "3.13" + - "3.14" steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 diff --git a/DEVELOPMENT_GUIDE.md b/DEVELOPMENT_GUIDE.md index f79482602..5d2cf5831 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.10, 3.11, 3.12, 3.13 +Our officially supported Python versions are 3.10, 3.11, 3.12, 3.13, 3.14 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). diff --git a/pyproject.toml b/pyproject.toml index 2d61ea2ca..fa9f9ee0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 120 -target_version = ['py310', 'py311', 'py312', 'py313'] +target_version = ['py310', 'py311', 'py312', 'py313', 'py314'] exclude = ''' ( diff --git a/requirements/base.txt b/requirements/base.txt index 732e8aff4..052f39ad9 100755 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -3,4 +3,4 @@ jsonschema<5,>=4.23 typing_extensions>=4.4 # resource validation & schema generation -pydantic~=2.12.5 +pydantic~=2.13.3 diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index c1e35628f..c265fd870 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -2,10 +2,8 @@ import copy import re -import sys from collections.abc import Callable from contextlib import suppress -from types import ModuleType from typing import Any, Literal, Union, cast import samtranslator.model.eventsources @@ -37,19 +35,11 @@ SyncConfigType, UserPoolConfigType, ) - -# Pydantic 1 doesn't support Python 3.14 so these imports will fail until we migrate to v2 -try: - from samtranslator.internal.schema_source import ( - aws_serverless_capacity_provider, - aws_serverless_function, - aws_serverless_graphqlapi, - ) -except RuntimeError: # Pydantic fails when initializing the model classes with a RuntimeError in 3.14 - aws_serverless_capacity_provider = cast(ModuleType, None) - aws_serverless_function = cast(ModuleType, None) - aws_serverless_graphqlapi = cast(ModuleType, None) - +from samtranslator.internal.schema_source import ( + aws_serverless_capacity_provider, + aws_serverless_function, + aws_serverless_graphqlapi, +) from samtranslator.internal.schema_source.common import PermissionsType, SamIntrinsicable from samtranslator.internal.types import GetManagedPolicyMap from samtranslator.internal.utils.utils import passthrough_value, remove_none_values @@ -158,14 +148,6 @@ _CONDITION_CHAR_LIMIT = 255 -# Utility function to throw an error when using functionality that doesn't work in Python 3.14 (need migration to Pydantic v2) -def check_python_314_compatibility(module: ModuleType | None, functionality: str) -> None: - if sys.version_info >= (3, 14) and module is None: - raise RuntimeError( - f"{functionality} functionalities are temporarily not supported when running SAM in Python 3.14" - ) - - class SamFunction(SamResourceMacro): """SAM function macro.""" @@ -811,7 +793,6 @@ def _transform_capacity_provider_config(self) -> dict[str, Any]: # Validate CapacityProviderConfig using Pydantic model directly for comprehensive error collection try: - check_python_314_compatibility(aws_serverless_function, "Capacity Provider") validated_model = aws_serverless_function.CapacityProviderConfig.parse_obj(self.CapacityProviderConfig) except Exception as e: raise InvalidResourceException(self.logical_id, f"Invalid CapacityProviderConfig: {e!s}") from e @@ -1574,7 +1555,6 @@ def to_cloudformation(self, **kwargs: Any) -> list[Resource]: """ Transform the SAM CapacityProvider resource to CloudFormation """ - check_python_314_compatibility(aws_serverless_capacity_provider, "Capacity Provider") self.validate_before_transform( schema_class=aws_serverless_capacity_provider.Properties, collect_all_errors=True, @@ -2792,7 +2772,6 @@ def __init__( @cw_timer def to_cloudformation(self, **kwargs: Any) -> list[Resource]: - check_python_314_compatibility(aws_serverless_graphqlapi, "GraphQLApi") model = self.validate_properties_and_return_model(aws_serverless_graphqlapi.Properties) appsync_api, cloudwatch_role, auth_connectors = self._construct_appsync_api_resources(model)