|
2 | 2 |
|
3 | 3 | import copy |
4 | 4 | import re |
5 | | -import sys |
6 | 5 | from collections.abc import Callable |
7 | 6 | from contextlib import suppress |
8 | | -from types import ModuleType |
9 | 7 | from typing import Any, Literal, Union, cast |
10 | 8 |
|
11 | 9 | import samtranslator.model.eventsources |
|
37 | 35 | SyncConfigType, |
38 | 36 | UserPoolConfigType, |
39 | 37 | ) |
40 | | - |
41 | | -# Pydantic 1 doesn't support Python 3.14 so these imports will fail until we migrate to v2 |
42 | | -try: |
43 | | - from samtranslator.internal.schema_source import ( |
44 | | - aws_serverless_capacity_provider, |
45 | | - aws_serverless_function, |
46 | | - aws_serverless_graphqlapi, |
47 | | - ) |
48 | | -except RuntimeError: # Pydantic fails when initializing the model classes with a RuntimeError in 3.14 |
49 | | - aws_serverless_capacity_provider = cast(ModuleType, None) |
50 | | - aws_serverless_function = cast(ModuleType, None) |
51 | | - aws_serverless_graphqlapi = cast(ModuleType, None) |
52 | | - |
| 38 | +from samtranslator.internal.schema_source import ( |
| 39 | + aws_serverless_capacity_provider, |
| 40 | + aws_serverless_function, |
| 41 | + aws_serverless_graphqlapi, |
| 42 | +) |
53 | 43 | from samtranslator.internal.schema_source.common import PermissionsType, SamIntrinsicable |
54 | 44 | from samtranslator.internal.types import GetManagedPolicyMap |
55 | 45 | from samtranslator.internal.utils.utils import passthrough_value, remove_none_values |
|
158 | 148 | _CONDITION_CHAR_LIMIT = 255 |
159 | 149 |
|
160 | 150 |
|
161 | | -# Utility function to throw an error when using functionality that doesn't work in Python 3.14 (need migration to Pydantic v2) |
162 | | -def check_python_314_compatibility(module: ModuleType | None, functionality: str) -> None: |
163 | | - if sys.version_info >= (3, 14) and module is None: |
164 | | - raise RuntimeError( |
165 | | - f"{functionality} functionalities are temporarily not supported when running SAM in Python 3.14" |
166 | | - ) |
167 | | - |
168 | | - |
169 | 151 | class SamFunction(SamResourceMacro): |
170 | 152 | """SAM function macro.""" |
171 | 153 |
|
@@ -811,7 +793,6 @@ def _transform_capacity_provider_config(self) -> dict[str, Any]: |
811 | 793 |
|
812 | 794 | # Validate CapacityProviderConfig using Pydantic model directly for comprehensive error collection |
813 | 795 | try: |
814 | | - check_python_314_compatibility(aws_serverless_function, "Capacity Provider") |
815 | 796 | validated_model = aws_serverless_function.CapacityProviderConfig.parse_obj(self.CapacityProviderConfig) |
816 | 797 | except Exception as e: |
817 | 798 | raise InvalidResourceException(self.logical_id, f"Invalid CapacityProviderConfig: {e!s}") from e |
@@ -1574,7 +1555,6 @@ def to_cloudformation(self, **kwargs: Any) -> list[Resource]: |
1574 | 1555 | """ |
1575 | 1556 | Transform the SAM CapacityProvider resource to CloudFormation |
1576 | 1557 | """ |
1577 | | - check_python_314_compatibility(aws_serverless_capacity_provider, "Capacity Provider") |
1578 | 1558 | self.validate_before_transform( |
1579 | 1559 | schema_class=aws_serverless_capacity_provider.Properties, |
1580 | 1560 | collect_all_errors=True, |
@@ -2792,7 +2772,6 @@ def __init__( |
2792 | 2772 |
|
2793 | 2773 | @cw_timer |
2794 | 2774 | def to_cloudformation(self, **kwargs: Any) -> list[Resource]: |
2795 | | - check_python_314_compatibility(aws_serverless_graphqlapi, "GraphQLApi") |
2796 | 2775 | model = self.validate_properties_and_return_model(aws_serverless_graphqlapi.Properties) |
2797 | 2776 |
|
2798 | 2777 | appsync_api, cloudwatch_role, auth_connectors = self._construct_appsync_api_resources(model) |
|
0 commit comments