From 4b1bb0601418ece9eca1bb35fefcfa91d1d7e1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Sat, 9 Nov 2024 09:43:39 +0000 Subject: [PATCH] ireally drop python<=3.7 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Filter all code over `pyupgracde --py38-plus`. Signed-off-by: Tomasz Kłoczko --- .../test_function_with_all_event_types.py | 2 +- integration/helpers/request_utils.py | 2 +- integration/single/__init__.py | 1 - .../schema_source/aws_serverless_api.py | 250 ++++---- .../aws_serverless_application.py | 10 +- .../schema_source/aws_serverless_function.py | 548 +++++++++--------- .../schema_source/aws_serverless_httpapi.py | 140 ++--- .../aws_serverless_layerversion.py | 20 +- .../aws_serverless_simpletable.py | 18 +- .../aws_serverless_statemachine.py | 176 +++--- .../internal/schema_source/schema.py | 38 +- setup.py | 3 +- .../test_processor.py | 2 +- tests/utils/test_py27hash_fix.py | 2 +- 14 files changed, 605 insertions(+), 607 deletions(-) diff --git a/integration/combination/test_function_with_all_event_types.py b/integration/combination/test_function_with_all_event_types.py index f593579aa..a23018371 100644 --- a/integration/combination/test_function_with_all_event_types.py +++ b/integration/combination/test_function_with_all_event_types.py @@ -66,7 +66,7 @@ def test_function_with_all_event_types(self): # assert LambdaEventSourceMappings event_source_mappings = lambda_client.list_event_source_mappings()["EventSourceMappings"] event_source_mapping_configurations = [x for x in event_source_mappings if x["FunctionArn"] == alias_arn] - event_source_mapping_arns = set([x["EventSourceArn"] for x in event_source_mapping_configurations]) + event_source_mapping_arns = {x["EventSourceArn"] for x in event_source_mapping_configurations} kinesis_client = self.client_provider.kinesis_client kinesis_stream_name = self.get_physical_id_by_type("AWS::Kinesis::Stream") diff --git a/integration/helpers/request_utils.py b/integration/helpers/request_utils.py index 655d7ae8a..54e1ec878 100644 --- a/integration/helpers/request_utils.py +++ b/integration/helpers/request_utils.py @@ -34,4 +34,4 @@ def _normalize_response_headers(self): # Need to check for response is None here since the __bool__ method checks 200 <= status < 400 return {} - return dict((k.lower(), v) for k, v in self.response.headers.items()) + return {k.lower(): v for k, v in self.response.headers.items()} diff --git a/integration/single/__init__.py b/integration/single/__init__.py index 8b1378917..e69de29bb 100644 --- a/integration/single/__init__.py +++ b/integration/single/__init__.py @@ -1 +0,0 @@ - diff --git a/samtranslator/internal/schema_source/aws_serverless_api.py b/samtranslator/internal/schema_source/aws_serverless_api.py index f94cc0b08..4992362dc 100644 --- a/samtranslator/internal/schema_source/aws_serverless_api.py +++ b/samtranslator/internal/schema_source/aws_serverless_api.py @@ -37,149 +37,149 @@ class ResourcePolicy(BaseModel): - AwsAccountBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("AwsAccountBlacklist") - AwsAccountWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("AwsAccountWhitelist") - CustomStatements: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("CustomStatements") - IntrinsicVpcBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpcBlacklist") - IntrinsicVpcWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpcWhitelist") - IntrinsicVpceBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpceBlacklist") - IntrinsicVpceWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpceWhitelist") - IpRangeBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IpRangeBlacklist") - IpRangeWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IpRangeWhitelist") - SourceVpcBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("SourceVpcBlacklist") - SourceVpcWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("SourceVpcWhitelist") + AwsAccountBlacklist: list[str | DictStrAny] | None = resourcepolicy("AwsAccountBlacklist") + AwsAccountWhitelist: list[str | DictStrAny] | None = resourcepolicy("AwsAccountWhitelist") + CustomStatements: list[str | DictStrAny] | None = resourcepolicy("CustomStatements") + IntrinsicVpcBlacklist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpcBlacklist") + IntrinsicVpcWhitelist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpcWhitelist") + IntrinsicVpceBlacklist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpceBlacklist") + IntrinsicVpceWhitelist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpceWhitelist") + IpRangeBlacklist: list[str | DictStrAny] | None = resourcepolicy("IpRangeBlacklist") + IpRangeWhitelist: list[str | DictStrAny] | None = resourcepolicy("IpRangeWhitelist") + SourceVpcBlacklist: list[str | DictStrAny] | None = resourcepolicy("SourceVpcBlacklist") + SourceVpcWhitelist: list[str | DictStrAny] | None = resourcepolicy("SourceVpcWhitelist") class CognitoAuthorizerIdentity(BaseModel): - Header: Optional[str] = cognitoauthorizeridentity("Header") - ReauthorizeEvery: Optional[SamIntrinsicable[int]] = cognitoauthorizeridentity("ReauthorizeEvery") - ValidationExpression: Optional[str] = cognitoauthorizeridentity("ValidationExpression") + Header: str | None = cognitoauthorizeridentity("Header") + ReauthorizeEvery: SamIntrinsicable[int] | None = cognitoauthorizeridentity("ReauthorizeEvery") + ValidationExpression: str | None = cognitoauthorizeridentity("ValidationExpression") class CognitoAuthorizer(BaseModel): - AuthorizationScopes: Optional[List[str]] = cognitoauthorizer("AuthorizationScopes") - Identity: Optional[CognitoAuthorizerIdentity] = cognitoauthorizer("Identity") + AuthorizationScopes: list[str] | None = cognitoauthorizer("AuthorizationScopes") + Identity: CognitoAuthorizerIdentity | None = cognitoauthorizer("Identity") UserPoolArn: SamIntrinsicable[str] = cognitoauthorizer("UserPoolArn") class LambdaTokenAuthorizerIdentity(BaseModel): - ReauthorizeEvery: Optional[SamIntrinsicable[int]] = lambdatokenauthorizeridentity("ReauthorizeEvery") - ValidationExpression: Optional[str] = lambdatokenauthorizeridentity("ValidationExpression") - Header: Optional[str] = lambdatokenauthorizeridentity("Header") + ReauthorizeEvery: SamIntrinsicable[int] | None = lambdatokenauthorizeridentity("ReauthorizeEvery") + ValidationExpression: str | None = lambdatokenauthorizeridentity("ValidationExpression") + Header: str | None = lambdatokenauthorizeridentity("Header") class LambdaRequestAuthorizerIdentity(BaseModel): - Context: Optional[List[str]] = lambdarequestauthorizeridentity("Context") - Headers: Optional[List[str]] = lambdarequestauthorizeridentity("Headers") - QueryStrings: Optional[List[str]] = lambdarequestauthorizeridentity("QueryStrings") - ReauthorizeEvery: Optional[SamIntrinsicable[int]] = lambdarequestauthorizeridentity("ReauthorizeEvery") - StageVariables: Optional[List[str]] = lambdarequestauthorizeridentity("StageVariables") + Context: list[str] | None = lambdarequestauthorizeridentity("Context") + Headers: list[str] | None = lambdarequestauthorizeridentity("Headers") + QueryStrings: list[str] | None = lambdarequestauthorizeridentity("QueryStrings") + ReauthorizeEvery: SamIntrinsicable[int] | None = lambdarequestauthorizeridentity("ReauthorizeEvery") + StageVariables: list[str] | None = lambdarequestauthorizeridentity("StageVariables") class LambdaTokenAuthorizer(BaseModel): - AuthorizationScopes: Optional[List[str]] = lambdatokenauthorizer("AuthorizationScopes") + AuthorizationScopes: list[str] | None = lambdatokenauthorizer("AuthorizationScopes") FunctionArn: SamIntrinsicable[str] = lambdatokenauthorizer("FunctionArn") - FunctionInvokeRole: Optional[str] = lambdatokenauthorizer("FunctionInvokeRole") - FunctionPayloadType: Optional[Literal["TOKEN"]] = lambdatokenauthorizer("FunctionPayloadType") - Identity: Optional[LambdaTokenAuthorizerIdentity] = lambdatokenauthorizer("Identity") - DisableFunctionDefaultPermissions: Optional[bool] = lambdatokenauthorizer("DisableFunctionDefaultPermissions") + FunctionInvokeRole: str | None = lambdatokenauthorizer("FunctionInvokeRole") + FunctionPayloadType: Literal["TOKEN"] | None = lambdatokenauthorizer("FunctionPayloadType") + Identity: LambdaTokenAuthorizerIdentity | None = lambdatokenauthorizer("Identity") + DisableFunctionDefaultPermissions: bool | None = lambdatokenauthorizer("DisableFunctionDefaultPermissions") class LambdaRequestAuthorizer(BaseModel): - AuthorizationScopes: Optional[List[str]] = lambdarequestauthorizer("AuthorizationScopes") + AuthorizationScopes: list[str] | None = lambdarequestauthorizer("AuthorizationScopes") FunctionArn: SamIntrinsicable[str] = lambdarequestauthorizer("FunctionArn") - FunctionInvokeRole: Optional[str] = lambdarequestauthorizer("FunctionInvokeRole") - FunctionPayloadType: Optional[Literal["REQUEST"]] = lambdarequestauthorizer("FunctionPayloadType") - Identity: Optional[LambdaRequestAuthorizerIdentity] = lambdarequestauthorizer("Identity") - DisableFunctionDefaultPermissions: Optional[bool] = lambdarequestauthorizer("DisableFunctionDefaultPermissions") + FunctionInvokeRole: str | None = lambdarequestauthorizer("FunctionInvokeRole") + FunctionPayloadType: Literal["REQUEST"] | None = lambdarequestauthorizer("FunctionPayloadType") + Identity: LambdaRequestAuthorizerIdentity | None = lambdarequestauthorizer("Identity") + DisableFunctionDefaultPermissions: bool | None = lambdarequestauthorizer("DisableFunctionDefaultPermissions") class UsagePlan(BaseModel): CreateUsagePlan: SamIntrinsicable[Literal["PER_API", "SHARED", "NONE"]] = usageplan("CreateUsagePlan") - Description: Optional[PassThroughProp] = usageplan("Description") - Quota: Optional[PassThroughProp] = usageplan("Quota") - Tags: Optional[PassThroughProp] = usageplan("Tags") - Throttle: Optional[PassThroughProp] = usageplan("Throttle") - UsagePlanName: Optional[PassThroughProp] = usageplan("UsagePlanName") + Description: PassThroughProp | None = usageplan("Description") + Quota: PassThroughProp | None = usageplan("Quota") + Tags: PassThroughProp | None = usageplan("Tags") + Throttle: PassThroughProp | None = usageplan("Throttle") + UsagePlanName: PassThroughProp | None = usageplan("UsagePlanName") class Auth(BaseModel): - AddDefaultAuthorizerToCorsPreflight: Optional[bool] = auth("AddDefaultAuthorizerToCorsPreflight") - AddApiKeyRequiredToCorsPreflight: Optional[bool] # TODO Add Docs - ApiKeyRequired: Optional[bool] = auth("ApiKeyRequired") - Authorizers: Optional[ - Dict[ + AddDefaultAuthorizerToCorsPreflight: bool | None = auth("AddDefaultAuthorizerToCorsPreflight") + AddApiKeyRequiredToCorsPreflight: bool | None # TODO Add Docs + ApiKeyRequired: bool | None = auth("ApiKeyRequired") + Authorizers: None | ( + dict[ str, - Union[ - CognitoAuthorizer, - LambdaTokenAuthorizer, - LambdaRequestAuthorizer, - ], + ( + CognitoAuthorizer | + LambdaTokenAuthorizer | + LambdaRequestAuthorizer + ), ] - ] = auth("Authorizers") - DefaultAuthorizer: Optional[str] = auth("DefaultAuthorizer") - InvokeRole: Optional[str] = auth("InvokeRole") - ResourcePolicy: Optional[ResourcePolicy] = auth("ResourcePolicy") - UsagePlan: Optional[UsagePlan] = auth("UsagePlan") + ) = auth("Authorizers") + DefaultAuthorizer: str | None = auth("DefaultAuthorizer") + InvokeRole: str | None = auth("InvokeRole") + ResourcePolicy: ResourcePolicy | None = auth("ResourcePolicy") + UsagePlan: UsagePlan | None = auth("UsagePlan") class Cors(BaseModel): - AllowCredentials: Optional[bool] = cors("AllowCredentials") - AllowHeaders: Optional[str] = cors("AllowHeaders") - AllowMethods: Optional[str] = cors("AllowMethods") + AllowCredentials: bool | None = cors("AllowCredentials") + AllowHeaders: str | None = cors("AllowHeaders") + AllowMethods: str | None = cors("AllowMethods") AllowOrigin: str = cors("AllowOrigin") - MaxAge: Optional[str] = cors("MaxAge") + MaxAge: str | None = cors("MaxAge") class Route53(BaseModel): - DistributionDomainName: Optional[PassThroughProp] = passthrough_prop( + DistributionDomainName: PassThroughProp | None = passthrough_prop( ROUTE53_STEM, "DistributionDomainName", ["AWS::Route53::RecordSetGroup.AliasTarget", "DNSName"], ) - EvaluateTargetHealth: Optional[PassThroughProp] = passthrough_prop( + EvaluateTargetHealth: PassThroughProp | None = passthrough_prop( ROUTE53_STEM, "EvaluateTargetHealth", ["AWS::Route53::RecordSetGroup.AliasTarget", "EvaluateTargetHealth"], ) - HostedZoneId: Optional[PassThroughProp] = passthrough_prop( + HostedZoneId: PassThroughProp | None = passthrough_prop( ROUTE53_STEM, "HostedZoneId", ["AWS::Route53::RecordSetGroup.RecordSet", "HostedZoneId"], ) - HostedZoneName: Optional[PassThroughProp] = passthrough_prop( + HostedZoneName: PassThroughProp | None = passthrough_prop( ROUTE53_STEM, "HostedZoneName", ["AWS::Route53::RecordSetGroup.RecordSet", "HostedZoneName"], ) - IpV6: Optional[bool] = route53("IpV6") - SetIdentifier: Optional[PassThroughProp] # TODO: add docs - Region: Optional[PassThroughProp] # TODO: add docs - SeparateRecordSetGroup: Optional[bool] # TODO: add docs + IpV6: bool | None = route53("IpV6") + SetIdentifier: PassThroughProp | None # TODO: add docs + Region: PassThroughProp | None # TODO: add docs + SeparateRecordSetGroup: bool | None # TODO: add docs class Domain(BaseModel): - BasePath: Optional[PassThroughProp] = domain("BasePath") - NormalizeBasePath: Optional[bool] = domain("NormalizeBasePath") + BasePath: PassThroughProp | None = domain("BasePath") + NormalizeBasePath: bool | None = domain("NormalizeBasePath") CertificateArn: PassThroughProp = domain("CertificateArn") DomainName: PassThroughProp = passthrough_prop( DOMAIN_STEM, "DomainName", ["AWS::ApiGateway::DomainName", "Properties", "DomainName"], ) - EndpointConfiguration: Optional[SamIntrinsicable[Literal["REGIONAL", "EDGE"]]] = domain("EndpointConfiguration") - MutualTlsAuthentication: Optional[PassThroughProp] = passthrough_prop( + EndpointConfiguration: SamIntrinsicable[Literal["REGIONAL", "EDGE"]] | None = domain("EndpointConfiguration") + MutualTlsAuthentication: PassThroughProp | None = passthrough_prop( DOMAIN_STEM, "MutualTlsAuthentication", ["AWS::ApiGateway::DomainName", "Properties", "MutualTlsAuthentication"], ) - OwnershipVerificationCertificateArn: Optional[PassThroughProp] = passthrough_prop( + OwnershipVerificationCertificateArn: PassThroughProp | None = passthrough_prop( DOMAIN_STEM, "OwnershipVerificationCertificateArn", ["AWS::ApiGateway::DomainName", "Properties", "OwnershipVerificationCertificateArn"], ) - Route53: Optional[Route53] = domain("Route53") - SecurityPolicy: Optional[PassThroughProp] = passthrough_prop( + Route53: Route53 | None = domain("Route53") + SecurityPolicy: PassThroughProp | None = passthrough_prop( DOMAIN_STEM, "SecurityPolicy", ["AWS::ApiGateway::DomainName", "Properties", "SecurityPolicy"], @@ -197,7 +197,7 @@ class DefinitionUri(BaseModel): "Key", ["AWS::ApiGateway::RestApi.S3Location", "Key"], ) - Version: Optional[PassThroughProp] = passthrough_prop( + Version: PassThroughProp | None = passthrough_prop( DEFINITION_URI_STEM, "Version", ["AWS::ApiGateway::RestApi.S3Location", "Version"], @@ -205,12 +205,12 @@ class DefinitionUri(BaseModel): class EndpointConfiguration(BaseModel): - Type: Optional[PassThroughProp] = passthrough_prop( + Type: PassThroughProp | None = passthrough_prop( ENDPOINT_CONFIGURATION_STEM, "Type", ["AWS::ApiGateway::RestApi.EndpointConfiguration", "Types"], ) - VPCEndpointIds: Optional[PassThroughProp] = passthrough_prop( + VPCEndpointIds: PassThroughProp | None = passthrough_prop( ENDPOINT_CONFIGURATION_STEM, "VPCEndpointIds", ["AWS::ApiGateway::RestApi.EndpointConfiguration", "VpcEndpointIds"], @@ -237,145 +237,145 @@ class EndpointConfiguration(BaseModel): class Properties(BaseModel): - AccessLogSetting: Optional[AccessLogSetting] = passthrough_prop( + AccessLogSetting: AccessLogSetting | None = passthrough_prop( PROPERTIES_STEM, "AccessLogSetting", ["AWS::ApiGateway::Stage", "Properties", "AccessLogSetting"], ) - ApiKeySourceType: Optional[PassThroughProp] = passthrough_prop( + ApiKeySourceType: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "ApiKeySourceType", ["AWS::ApiGateway::RestApi", "Properties", "ApiKeySourceType"], ) - Auth: Optional[Auth] = properties("Auth") - BinaryMediaTypes: Optional[BinaryMediaTypes] = properties("BinaryMediaTypes") - CacheClusterEnabled: Optional[CacheClusterEnabled] = passthrough_prop( + Auth: Auth | None = properties("Auth") + BinaryMediaTypes: BinaryMediaTypes | None = properties("BinaryMediaTypes") + CacheClusterEnabled: CacheClusterEnabled | None = passthrough_prop( PROPERTIES_STEM, "CacheClusterEnabled", ["AWS::ApiGateway::Stage", "Properties", "CacheClusterEnabled"], ) - CacheClusterSize: Optional[CacheClusterSize] = passthrough_prop( + CacheClusterSize: CacheClusterSize | None = passthrough_prop( PROPERTIES_STEM, "CacheClusterSize", ["AWS::ApiGateway::Stage", "Properties", "CacheClusterSize"], ) - CanarySetting: Optional[CanarySetting] = passthrough_prop( + CanarySetting: CanarySetting | None = passthrough_prop( PROPERTIES_STEM, "CanarySetting", ["AWS::ApiGateway::Stage", "Properties", "CanarySetting"], ) - Cors: Optional[CorsType] = properties("Cors") - DefinitionBody: Optional[DictStrAny] = properties("DefinitionBody") - DefinitionUri: Optional[DefinitionUriType] = properties("DefinitionUri") - MergeDefinitions: Optional[MergeDefinitions] = properties("MergeDefinitions") - Description: Optional[PassThroughProp] = passthrough_prop( + Cors: CorsType | None = properties("Cors") + DefinitionBody: DictStrAny | None = properties("DefinitionBody") + DefinitionUri: DefinitionUriType | None = properties("DefinitionUri") + MergeDefinitions: MergeDefinitions | None = properties("MergeDefinitions") + Description: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "Description", ["AWS::ApiGateway::Stage", "Properties", "Description"], ) - DisableExecuteApiEndpoint: Optional[PassThroughProp] = properties("DisableExecuteApiEndpoint") - Domain: Optional[Domain] = properties("Domain") - EndpointConfiguration: Optional[EndpointConfigurationType] = properties("EndpointConfiguration") - FailOnWarnings: Optional[PassThroughProp] = passthrough_prop( + DisableExecuteApiEndpoint: PassThroughProp | None = properties("DisableExecuteApiEndpoint") + Domain: Domain | None = properties("Domain") + EndpointConfiguration: EndpointConfigurationType | None = properties("EndpointConfiguration") + FailOnWarnings: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "FailOnWarnings", ["AWS::ApiGateway::RestApi", "Properties", "FailOnWarnings"], ) - GatewayResponses: Optional[GatewayResponses] = properties("GatewayResponses") - MethodSettings: Optional[MethodSettings] = passthrough_prop( + GatewayResponses: GatewayResponses | None = properties("GatewayResponses") + MethodSettings: MethodSettings | None = passthrough_prop( PROPERTIES_STEM, "MethodSettings", ["AWS::ApiGateway::Stage", "Properties", "MethodSettings"], ) - MinimumCompressionSize: Optional[MinimumCompressionSize] = passthrough_prop( + MinimumCompressionSize: MinimumCompressionSize | None = passthrough_prop( PROPERTIES_STEM, "MinimumCompressionSize", ["AWS::ApiGateway::RestApi", "Properties", "MinimumCompressionSize"], ) - Mode: Optional[PassThroughProp] = passthrough_prop( + Mode: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "Mode", ["AWS::ApiGateway::RestApi", "Properties", "Mode"], ) - Models: Optional[DictStrAny] = properties("Models") - Name: Optional[Name] = passthrough_prop( + Models: DictStrAny | None = properties("Models") + Name: Name | None = passthrough_prop( PROPERTIES_STEM, "Name", ["AWS::ApiGateway::RestApi", "Properties", "Name"], ) - OpenApiVersion: Optional[OpenApiVersion] = properties("OpenApiVersion") + OpenApiVersion: OpenApiVersion | None = properties("OpenApiVersion") StageName: SamIntrinsicable[str] = properties("StageName") - Tags: Optional[DictStrAny] = properties("Tags") - PropagateTags: Optional[bool] # TODO: add docs - TracingEnabled: Optional[TracingEnabled] = passthrough_prop( + Tags: DictStrAny | None = properties("Tags") + PropagateTags: bool | None # TODO: add docs + TracingEnabled: TracingEnabled | None = passthrough_prop( PROPERTIES_STEM, "TracingEnabled", ["AWS::ApiGateway::Stage", "Properties", "TracingEnabled"], ) - Variables: Optional[Variables] = passthrough_prop( + Variables: Variables | None = passthrough_prop( PROPERTIES_STEM, "Variables", ["AWS::ApiGateway::Stage", "Properties", "Variables"], ) - AlwaysDeploy: Optional[AlwaysDeploy] = properties("AlwaysDeploy") + AlwaysDeploy: AlwaysDeploy | None = properties("AlwaysDeploy") class Globals(BaseModel): - Auth: Optional[Auth] = properties("Auth") - Name: Optional[Name] = passthrough_prop( + Auth: Auth | None = properties("Auth") + Name: Name | None = passthrough_prop( PROPERTIES_STEM, "Name", ["AWS::ApiGateway::RestApi", "Properties", "Name"], ) - DefinitionUri: Optional[PassThroughProp] = properties("DefinitionUri") - CacheClusterEnabled: Optional[CacheClusterEnabled] = passthrough_prop( + DefinitionUri: PassThroughProp | None = properties("DefinitionUri") + CacheClusterEnabled: CacheClusterEnabled | None = passthrough_prop( PROPERTIES_STEM, "CacheClusterEnabled", ["AWS::ApiGateway::Stage", "Properties", "CacheClusterEnabled"], ) - CacheClusterSize: Optional[CacheClusterSize] = passthrough_prop( + CacheClusterSize: CacheClusterSize | None = passthrough_prop( PROPERTIES_STEM, "CacheClusterSize", ["AWS::ApiGateway::Stage", "Properties", "CacheClusterSize"], ) - MergeDefinitions: Optional[MergeDefinitions] = properties("MergeDefinitions") - Variables: Optional[Variables] = passthrough_prop( + MergeDefinitions: MergeDefinitions | None = properties("MergeDefinitions") + Variables: Variables | None = passthrough_prop( PROPERTIES_STEM, "Variables", ["AWS::ApiGateway::Stage", "Properties", "Variables"], ) - EndpointConfiguration: Optional[PassThroughProp] = properties("EndpointConfiguration") - MethodSettings: Optional[MethodSettings] = properties("MethodSettings") - BinaryMediaTypes: Optional[BinaryMediaTypes] = properties("BinaryMediaTypes") - MinimumCompressionSize: Optional[MinimumCompressionSize] = passthrough_prop( + EndpointConfiguration: PassThroughProp | None = properties("EndpointConfiguration") + MethodSettings: MethodSettings | None = properties("MethodSettings") + BinaryMediaTypes: BinaryMediaTypes | None = properties("BinaryMediaTypes") + MinimumCompressionSize: MinimumCompressionSize | None = passthrough_prop( PROPERTIES_STEM, "MinimumCompressionSize", ["AWS::ApiGateway::RestApi", "Properties", "MinimumCompressionSize"], ) - Cors: Optional[CorsType] = properties("Cors") - GatewayResponses: Optional[GatewayResponses] = properties("GatewayResponses") - AccessLogSetting: Optional[AccessLogSetting] = passthrough_prop( + Cors: CorsType | None = properties("Cors") + GatewayResponses: GatewayResponses | None = properties("GatewayResponses") + AccessLogSetting: AccessLogSetting | None = passthrough_prop( PROPERTIES_STEM, "AccessLogSetting", ["AWS::ApiGateway::Stage", "Properties", "AccessLogSetting"], ) - CanarySetting: Optional[CanarySetting] = passthrough_prop( + CanarySetting: CanarySetting | None = passthrough_prop( PROPERTIES_STEM, "CanarySetting", ["AWS::ApiGateway::Stage", "Properties", "CanarySetting"], ) - TracingEnabled: Optional[TracingEnabled] = passthrough_prop( + TracingEnabled: TracingEnabled | None = passthrough_prop( PROPERTIES_STEM, "TracingEnabled", ["AWS::ApiGateway::Stage", "Properties", "TracingEnabled"], ) - OpenApiVersion: Optional[OpenApiVersion] = properties("OpenApiVersion") - Domain: Optional[Domain] = properties("Domain") - AlwaysDeploy: Optional[AlwaysDeploy] = properties("AlwaysDeploy") - PropagateTags: Optional[bool] # TODO: add docs + OpenApiVersion: OpenApiVersion | None = properties("OpenApiVersion") + Domain: Domain | None = properties("Domain") + AlwaysDeploy: AlwaysDeploy | None = properties("AlwaysDeploy") + PropagateTags: bool | None # TODO: add docs class Resource(ResourceAttributes): Type: Literal["AWS::Serverless::Api"] Properties: Properties - Connectors: Optional[Dict[str, EmbeddedConnector]] + Connectors: dict[str, EmbeddedConnector] | None diff --git a/samtranslator/internal/schema_source/aws_serverless_application.py b/samtranslator/internal/schema_source/aws_serverless_application.py index 7079ca17c..745c84c8c 100644 --- a/samtranslator/internal/schema_source/aws_serverless_application.py +++ b/samtranslator/internal/schema_source/aws_serverless_application.py @@ -23,19 +23,19 @@ class Location(BaseModel): class Properties(BaseModel): - Location: Union[str, Location] = properties("Location") - NotificationARNs: Optional[PassThroughProp] = passthrough_prop( + Location: str | Location = properties("Location") + NotificationARNs: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "NotificationARNs", ["AWS::CloudFormation::Stack", "Properties", "NotificationARNs"], ) - Parameters: Optional[PassThroughProp] = passthrough_prop( + Parameters: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "Parameters", ["AWS::CloudFormation::Stack", "Properties", "Parameters"], ) - Tags: Optional[Dict[str, Any]] = properties("Tags") - TimeoutInMinutes: Optional[PassThroughProp] = passthrough_prop( + Tags: dict[str, Any] | None = properties("Tags") + TimeoutInMinutes: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "TimeoutInMinutes", ["AWS::CloudFormation::Stack", "Properties", "TimeoutInMinutes"], diff --git a/samtranslator/internal/schema_source/aws_serverless_function.py b/samtranslator/internal/schema_source/aws_serverless_function.py index bd0740e55..c65bcfed7 100644 --- a/samtranslator/internal/schema_source/aws_serverless_function.py +++ b/samtranslator/internal/schema_source/aws_serverless_function.py @@ -58,42 +58,42 @@ class ResourcePolicy(BaseModel): - AwsAccountBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("AwsAccountBlacklist") - AwsAccountWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("AwsAccountWhitelist") - CustomStatements: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("CustomStatements") - IntrinsicVpcBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpcBlacklist") - IntrinsicVpcWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpcWhitelist") - IntrinsicVpceBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpceBlacklist") - IntrinsicVpceWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpceWhitelist") - IpRangeBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IpRangeBlacklist") - IpRangeWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IpRangeWhitelist") - SourceVpcBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("SourceVpcBlacklist") - SourceVpcWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("SourceVpcWhitelist") + AwsAccountBlacklist: list[str | DictStrAny] | None = resourcepolicy("AwsAccountBlacklist") + AwsAccountWhitelist: list[str | DictStrAny] | None = resourcepolicy("AwsAccountWhitelist") + CustomStatements: list[str | DictStrAny] | None = resourcepolicy("CustomStatements") + IntrinsicVpcBlacklist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpcBlacklist") + IntrinsicVpcWhitelist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpcWhitelist") + IntrinsicVpceBlacklist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpceBlacklist") + IntrinsicVpceWhitelist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpceWhitelist") + IpRangeBlacklist: list[str | DictStrAny] | None = resourcepolicy("IpRangeBlacklist") + IpRangeWhitelist: list[str | DictStrAny] | None = resourcepolicy("IpRangeWhitelist") + SourceVpcBlacklist: list[str | DictStrAny] | None = resourcepolicy("SourceVpcBlacklist") + SourceVpcWhitelist: list[str | DictStrAny] | None = resourcepolicy("SourceVpcWhitelist") class CodeUri(BaseModel): Bucket: SamIntrinsicable[str] = codeuri("Bucket") Key: SamIntrinsicable[str] = codeuri("Key") - Version: Optional[SamIntrinsicable[str]] = codeuri("Version") + Version: SamIntrinsicable[str] | None = codeuri("Version") class Hooks(BaseModel): - PostTraffic: Optional[SamIntrinsicable[str]] = hooks("PostTraffic") - PreTraffic: Optional[SamIntrinsicable[str]] = hooks("PreTraffic") + PostTraffic: SamIntrinsicable[str] | None = hooks("PostTraffic") + PreTraffic: SamIntrinsicable[str] | None = hooks("PreTraffic") class DeploymentPreference(BaseModel): - Alarms: Optional[SamIntrinsicable[List[DictStrAny]]] = deploymentpreference("Alarms") - Enabled: Optional[SamIntrinsicable[bool]] = deploymentpreference("Enabled") - Hooks: Optional[Hooks] = deploymentpreference("Hooks") - PassthroughCondition: Optional[SamIntrinsicable[bool]] = deploymentpreference("PassthroughCondition") - Role: Optional[SamIntrinsicable[str]] = deploymentpreference("Role") - TriggerConfigurations: Optional[PassThroughProp] = passthrough_prop( + Alarms: SamIntrinsicable[list[DictStrAny]] | None = deploymentpreference("Alarms") + Enabled: SamIntrinsicable[bool] | None = deploymentpreference("Enabled") + Hooks: Hooks | None = deploymentpreference("Hooks") + PassthroughCondition: SamIntrinsicable[bool] | None = deploymentpreference("PassthroughCondition") + Role: SamIntrinsicable[str] | None = deploymentpreference("Role") + TriggerConfigurations: PassThroughProp | None = passthrough_prop( DEPLOYMENT_PREFERENCE_STEM, "TriggerConfigurations", ["AWS::CodeDeploy::DeploymentGroup", "Properties", "TriggerConfigurations"], ) - Type: Optional[SamIntrinsicable[str]] = deploymentpreference( + Type: SamIntrinsicable[str] | None = deploymentpreference( "Type" ) # TODO: Should investigate whether this is a required field. This is a required field on documentation. However, we don't seem to use this field. @@ -104,30 +104,30 @@ class DeadLetterQueue(BaseModel): class EventInvokeOnFailure(BaseModel): - Destination: Optional[SamIntrinsicable[str]] = eventinvokeonfailure("Destination") - Type: Optional[Literal["SQS", "SNS", "Lambda", "EventBridge"]] = eventinvokeonfailure("Type") + Destination: SamIntrinsicable[str] | None = eventinvokeonfailure("Destination") + Type: Literal["SQS", "SNS", "Lambda", "EventBridge"] | None = eventinvokeonfailure("Type") class EventInvokeOnSuccess(BaseModel): - Destination: Optional[SamIntrinsicable[str]] = eventinvokeonsuccess("Destination") - Type: Optional[Literal["SQS", "SNS", "Lambda", "EventBridge"]] = eventinvokeonsuccess("Type") + Destination: SamIntrinsicable[str] | None = eventinvokeonsuccess("Destination") + Type: Literal["SQS", "SNS", "Lambda", "EventBridge"] | None = eventinvokeonsuccess("Type") class EventInvokeDestinationConfig(BaseModel): - OnFailure: Optional[EventInvokeOnFailure] = eventinvokedestinationconfig("OnFailure") - OnSuccess: Optional[EventInvokeOnSuccess] = eventinvokedestinationconfig("OnSuccess") + OnFailure: EventInvokeOnFailure | None = eventinvokedestinationconfig("OnFailure") + OnSuccess: EventInvokeOnSuccess | None = eventinvokedestinationconfig("OnSuccess") class EventInvokeConfig(BaseModel): - DestinationConfig: Optional[EventInvokeDestinationConfig] = eventinvokeconfig("DestinationConfig") - MaximumEventAgeInSeconds: Optional[int] = eventinvokeconfig("MaximumEventAgeInSeconds") - MaximumRetryAttempts: Optional[int] = eventinvokeconfig("MaximumRetryAttempts") + DestinationConfig: EventInvokeDestinationConfig | None = eventinvokeconfig("DestinationConfig") + MaximumEventAgeInSeconds: int | None = eventinvokeconfig("MaximumEventAgeInSeconds") + MaximumRetryAttempts: int | None = eventinvokeconfig("MaximumRetryAttempts") class S3EventProperties(BaseModel): Bucket: SamIntrinsicable[str] = s3eventproperties("Bucket") Events: PassThroughProp = s3eventproperties("Events") - Filter: Optional[PassThroughProp] = s3eventproperties("Filter") + Filter: PassThroughProp | None = s3eventproperties("Filter") class S3Event(BaseModel): @@ -136,18 +136,18 @@ class S3Event(BaseModel): class SqsSubscription(BaseModel): - BatchSize: Optional[SamIntrinsicable[str]] = sqssubscription("BatchSize") - Enabled: Optional[bool] = sqssubscription("Enabled") + BatchSize: SamIntrinsicable[str] | None = sqssubscription("BatchSize") + Enabled: bool | None = sqssubscription("Enabled") QueueArn: SamIntrinsicable[str] = sqssubscription("QueueArn") - QueuePolicyLogicalId: Optional[str] = sqssubscription("QueuePolicyLogicalId") + QueuePolicyLogicalId: str | None = sqssubscription("QueuePolicyLogicalId") QueueUrl: SamIntrinsicable[str] = sqssubscription("QueueUrl") class SNSEventProperties(BaseModel): - FilterPolicy: Optional[PassThroughProp] = snseventproperties("FilterPolicy") - FilterPolicyScope: Optional[PassThroughProp] # TODO: add documentation - Region: Optional[PassThroughProp] = snseventproperties("Region") - SqsSubscription: Optional[Union[bool, SqsSubscription]] = snseventproperties("SqsSubscription") + FilterPolicy: PassThroughProp | None = snseventproperties("FilterPolicy") + FilterPolicyScope: PassThroughProp | None # TODO: add documentation + Region: PassThroughProp | None = snseventproperties("Region") + SqsSubscription: bool | SqsSubscription | None = snseventproperties("SqsSubscription") Topic: PassThroughProp = snseventproperties("Topic") @@ -158,26 +158,26 @@ class SNSEvent(BaseModel): class FunctionUrlConfig(BaseModel): AuthType: SamIntrinsicable[str] = functionurlconfig("AuthType") - Cors: Optional[PassThroughProp] = functionurlconfig("Cors") - InvokeMode: Optional[PassThroughProp] # TODO: add to doc + Cors: PassThroughProp | None = functionurlconfig("Cors") + InvokeMode: PassThroughProp | None # TODO: add to doc class KinesisEventProperties(BaseModel): - BatchSize: Optional[PassThroughProp] = kinesiseventproperties("BatchSize") - BisectBatchOnFunctionError: Optional[PassThroughProp] = kinesiseventproperties("BisectBatchOnFunctionError") - DestinationConfig: Optional[PassThroughProp] = kinesiseventproperties("DestinationConfig") - Enabled: Optional[PassThroughProp] = kinesiseventproperties("Enabled") - FilterCriteria: Optional[PassThroughProp] = kinesiseventproperties("FilterCriteria") - FunctionResponseTypes: Optional[PassThroughProp] = kinesiseventproperties("FunctionResponseTypes") - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation - MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = kinesiseventproperties("MaximumBatchingWindowInSeconds") - MaximumRecordAgeInSeconds: Optional[PassThroughProp] = kinesiseventproperties("MaximumRecordAgeInSeconds") - MaximumRetryAttempts: Optional[PassThroughProp] = kinesiseventproperties("MaximumRetryAttempts") - ParallelizationFactor: Optional[PassThroughProp] = kinesiseventproperties("ParallelizationFactor") - StartingPosition: Optional[PassThroughProp] = kinesiseventproperties("StartingPosition") - StartingPositionTimestamp: Optional[PassThroughProp] = kinesiseventproperties("StartingPositionTimestamp") + BatchSize: PassThroughProp | None = kinesiseventproperties("BatchSize") + BisectBatchOnFunctionError: PassThroughProp | None = kinesiseventproperties("BisectBatchOnFunctionError") + DestinationConfig: PassThroughProp | None = kinesiseventproperties("DestinationConfig") + Enabled: PassThroughProp | None = kinesiseventproperties("Enabled") + FilterCriteria: PassThroughProp | None = kinesiseventproperties("FilterCriteria") + FunctionResponseTypes: PassThroughProp | None = kinesiseventproperties("FunctionResponseTypes") + KmsKeyArn: PassThroughProp | None # TODO: add documentation + MaximumBatchingWindowInSeconds: PassThroughProp | None = kinesiseventproperties("MaximumBatchingWindowInSeconds") + MaximumRecordAgeInSeconds: PassThroughProp | None = kinesiseventproperties("MaximumRecordAgeInSeconds") + MaximumRetryAttempts: PassThroughProp | None = kinesiseventproperties("MaximumRetryAttempts") + ParallelizationFactor: PassThroughProp | None = kinesiseventproperties("ParallelizationFactor") + StartingPosition: PassThroughProp | None = kinesiseventproperties("StartingPosition") + StartingPositionTimestamp: PassThroughProp | None = kinesiseventproperties("StartingPositionTimestamp") Stream: PassThroughProp = kinesiseventproperties("Stream") - TumblingWindowInSeconds: Optional[PassThroughProp] = kinesiseventproperties("TumblingWindowInSeconds") + TumblingWindowInSeconds: PassThroughProp | None = kinesiseventproperties("TumblingWindowInSeconds") class KinesisEvent(BaseModel): @@ -186,23 +186,23 @@ class KinesisEvent(BaseModel): class DynamoDBEventProperties(BaseModel): - BatchSize: Optional[PassThroughProp] = dynamodbeventproperties("BatchSize") - BisectBatchOnFunctionError: Optional[PassThroughProp] = dynamodbeventproperties("BisectBatchOnFunctionError") - DestinationConfig: Optional[PassThroughProp] = dynamodbeventproperties("DestinationConfig") - Enabled: Optional[PassThroughProp] = dynamodbeventproperties("Enabled") - FilterCriteria: Optional[PassThroughProp] = dynamodbeventproperties("FilterCriteria") - FunctionResponseTypes: Optional[PassThroughProp] = dynamodbeventproperties("FunctionResponseTypes") - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation - MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = dynamodbeventproperties( + BatchSize: PassThroughProp | None = dynamodbeventproperties("BatchSize") + BisectBatchOnFunctionError: PassThroughProp | None = dynamodbeventproperties("BisectBatchOnFunctionError") + DestinationConfig: PassThroughProp | None = dynamodbeventproperties("DestinationConfig") + Enabled: PassThroughProp | None = dynamodbeventproperties("Enabled") + FilterCriteria: PassThroughProp | None = dynamodbeventproperties("FilterCriteria") + FunctionResponseTypes: PassThroughProp | None = dynamodbeventproperties("FunctionResponseTypes") + KmsKeyArn: PassThroughProp | None # TODO: add documentation + MaximumBatchingWindowInSeconds: PassThroughProp | None = dynamodbeventproperties( "MaximumBatchingWindowInSeconds" ) - MaximumRecordAgeInSeconds: Optional[PassThroughProp] = dynamodbeventproperties("MaximumRecordAgeInSeconds") - MaximumRetryAttempts: Optional[PassThroughProp] = dynamodbeventproperties("MaximumRetryAttempts") - ParallelizationFactor: Optional[PassThroughProp] = dynamodbeventproperties("ParallelizationFactor") - StartingPosition: Optional[PassThroughProp] = dynamodbeventproperties("StartingPosition") - StartingPositionTimestamp: Optional[PassThroughProp] = dynamodbeventproperties("StartingPositionTimestamp") + MaximumRecordAgeInSeconds: PassThroughProp | None = dynamodbeventproperties("MaximumRecordAgeInSeconds") + MaximumRetryAttempts: PassThroughProp | None = dynamodbeventproperties("MaximumRetryAttempts") + ParallelizationFactor: PassThroughProp | None = dynamodbeventproperties("ParallelizationFactor") + StartingPosition: PassThroughProp | None = dynamodbeventproperties("StartingPosition") + StartingPositionTimestamp: PassThroughProp | None = dynamodbeventproperties("StartingPositionTimestamp") Stream: PassThroughProp = dynamodbeventproperties("Stream") - TumblingWindowInSeconds: Optional[PassThroughProp] = dynamodbeventproperties("TumblingWindowInSeconds") + TumblingWindowInSeconds: PassThroughProp | None = dynamodbeventproperties("TumblingWindowInSeconds") class DynamoDBEvent(BaseModel): @@ -211,20 +211,20 @@ class DynamoDBEvent(BaseModel): class DocumentDBEventProperties(BaseModel): - BatchSize: Optional[PassThroughProp] = documentdbeventproperties("BatchSize") + BatchSize: PassThroughProp | None = documentdbeventproperties("BatchSize") Cluster: PassThroughProp = documentdbeventproperties("Cluster") - CollectionName: Optional[PassThroughProp] = documentdbeventproperties("CollectionName") + CollectionName: PassThroughProp | None = documentdbeventproperties("CollectionName") DatabaseName: PassThroughProp = documentdbeventproperties("DatabaseName") - Enabled: Optional[PassThroughProp] = documentdbeventproperties("Enabled") - FilterCriteria: Optional[PassThroughProp] = documentdbeventproperties("FilterCriteria") - FullDocument: Optional[PassThroughProp] = documentdbeventproperties("FullDocument") - MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = documentdbeventproperties( + Enabled: PassThroughProp | None = documentdbeventproperties("Enabled") + FilterCriteria: PassThroughProp | None = documentdbeventproperties("FilterCriteria") + FullDocument: PassThroughProp | None = documentdbeventproperties("FullDocument") + MaximumBatchingWindowInSeconds: PassThroughProp | None = documentdbeventproperties( "MaximumBatchingWindowInSeconds" ) - SecretsManagerKmsKeyId: Optional[str] = documentdbeventproperties("SecretsManagerKmsKeyId") + SecretsManagerKmsKeyId: str | None = documentdbeventproperties("SecretsManagerKmsKeyId") SourceAccessConfigurations: PassThroughProp = documentdbeventproperties("SourceAccessConfigurations") - StartingPosition: Optional[PassThroughProp] = documentdbeventproperties("StartingPosition") - StartingPositionTimestamp: Optional[PassThroughProp] = documentdbeventproperties("StartingPositionTimestamp") + StartingPosition: PassThroughProp | None = documentdbeventproperties("StartingPosition") + StartingPositionTimestamp: PassThroughProp | None = documentdbeventproperties("StartingPositionTimestamp") class DocumentDBEvent(BaseModel): @@ -233,14 +233,14 @@ class DocumentDBEvent(BaseModel): class SQSEventProperties(BaseModel): - BatchSize: Optional[PassThroughProp] = sqseventproperties("BatchSize") - Enabled: Optional[PassThroughProp] = sqseventproperties("Enabled") - FilterCriteria: Optional[PassThroughProp] = sqseventproperties("FilterCriteria") - FunctionResponseTypes: Optional[PassThroughProp] = sqseventproperties("FunctionResponseTypes") - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation - MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = sqseventproperties("MaximumBatchingWindowInSeconds") + BatchSize: PassThroughProp | None = sqseventproperties("BatchSize") + Enabled: PassThroughProp | None = sqseventproperties("Enabled") + FilterCriteria: PassThroughProp | None = sqseventproperties("FilterCriteria") + FunctionResponseTypes: PassThroughProp | None = sqseventproperties("FunctionResponseTypes") + KmsKeyArn: PassThroughProp | None # TODO: add documentation + MaximumBatchingWindowInSeconds: PassThroughProp | None = sqseventproperties("MaximumBatchingWindowInSeconds") Queue: PassThroughProp = sqseventproperties("Queue") - ScalingConfig: Optional[PassThroughProp] # Update docs when live + ScalingConfig: PassThroughProp | None # Update docs when live class SQSEvent(BaseModel): @@ -249,25 +249,25 @@ class SQSEvent(BaseModel): class ApiAuth(BaseModel): - ApiKeyRequired: Optional[bool] = apiauth("ApiKeyRequired") - AuthorizationScopes: Optional[List[str]] = apiauth("AuthorizationScopes") - Authorizer: Optional[str] = apiauth("Authorizer") - InvokeRole: Optional[SamIntrinsicable[str]] = apiauth("InvokeRole") - ResourcePolicy: Optional[ResourcePolicy] = apiauth("ResourcePolicy") + ApiKeyRequired: bool | None = apiauth("ApiKeyRequired") + AuthorizationScopes: list[str] | None = apiauth("AuthorizationScopes") + Authorizer: str | None = apiauth("Authorizer") + InvokeRole: SamIntrinsicable[str] | None = apiauth("InvokeRole") + ResourcePolicy: ResourcePolicy | None = apiauth("ResourcePolicy") # TODO explicitly mention in docs that intrinsics are not supported for OverrideApiAuth - OverrideApiAuth: Optional[bool] # TODO Add Docs + OverrideApiAuth: bool | None # TODO Add Docs class RequestModel(BaseModel): Model: str = requestmodel("Model") - Required: Optional[bool] = requestmodel("Required") - ValidateBody: Optional[bool] = requestmodel("ValidateBody") - ValidateParameters: Optional[bool] = requestmodel("ValidateParameters") + Required: bool | None = requestmodel("Required") + ValidateBody: bool | None = requestmodel("ValidateBody") + ValidateParameters: bool | None = requestmodel("ValidateParameters") class RequestParameters(BaseModel): - Caching: Optional[bool] = requestparameters("Caching") - Required: Optional[bool] = requestparameters("Required") + Caching: bool | None = requestparameters("Caching") + Required: bool | None = requestparameters("Required") # TODO: docs says either str or RequestParameter but implementation is an array of str or RequestParameter @@ -276,13 +276,13 @@ class RequestParameters(BaseModel): class ApiEventProperties(BaseModel): - Auth: Optional[ApiAuth] = apieventproperties("Auth") + Auth: ApiAuth | None = apieventproperties("Auth") Method: str = apieventproperties("Method") Path: str = apieventproperties("Path") - RequestModel: Optional[RequestModel] = apieventproperties("RequestModel") - RequestParameters: Optional[RequestModelProperty] = apieventproperties("RequestParameters") - RestApiId: Optional[Union[str, Ref]] = apieventproperties("RestApiId") - TimeoutInMillis: Optional[PassThroughProp] # TODO: add doc + RequestModel: RequestModel | None = apieventproperties("RequestModel") + RequestParameters: RequestModelProperty | None = apieventproperties("RequestParameters") + RestApiId: str | Ref | None = apieventproperties("RestApiId") + TimeoutInMillis: PassThroughProp | None # TODO: add doc class ApiEvent(BaseModel): @@ -291,12 +291,12 @@ class ApiEvent(BaseModel): class CloudWatchEventProperties(BaseModel): - Enabled: Optional[bool] = cloudwatcheventproperties("Enabled") - EventBusName: Optional[PassThroughProp] = cloudwatcheventproperties("EventBusName") - Input: Optional[PassThroughProp] = cloudwatcheventproperties("Input") - InputPath: Optional[PassThroughProp] = cloudwatcheventproperties("InputPath") - Pattern: Optional[PassThroughProp] = cloudwatcheventproperties("Pattern") - State: Optional[PassThroughProp] = cloudwatcheventproperties("State") + Enabled: bool | None = cloudwatcheventproperties("Enabled") + EventBusName: PassThroughProp | None = cloudwatcheventproperties("EventBusName") + Input: PassThroughProp | None = cloudwatcheventproperties("Input") + InputPath: PassThroughProp | None = cloudwatcheventproperties("InputPath") + Pattern: PassThroughProp | None = cloudwatcheventproperties("Pattern") + State: PassThroughProp | None = cloudwatcheventproperties("State") class CloudWatchEvent(BaseModel): @@ -305,20 +305,20 @@ class CloudWatchEvent(BaseModel): class DeadLetterConfig(BaseModel): - Arn: Optional[PassThroughProp] = deadletterconfig("Arn") - QueueLogicalId: Optional[str] = deadletterconfig("QueueLogicalId") - Type: Optional[Literal["SQS"]] = deadletterconfig("Type") + Arn: PassThroughProp | None = deadletterconfig("Arn") + QueueLogicalId: str | None = deadletterconfig("QueueLogicalId") + Type: Literal["SQS"] | None = deadletterconfig("Type") class EventsScheduleProperties(BaseModel): - DeadLetterConfig: Optional[DeadLetterConfig] = eventsscheduleproperties("DeadLetterConfig") - Description: Optional[PassThroughProp] = eventsscheduleproperties("Description") - Enabled: Optional[bool] = eventsscheduleproperties("Enabled") - Input: Optional[PassThroughProp] = eventsscheduleproperties("Input") - Name: Optional[PassThroughProp] = eventsscheduleproperties("Name") - RetryPolicy: Optional[PassThroughProp] = eventsscheduleproperties("RetryPolicy") - Schedule: Optional[PassThroughProp] = eventsscheduleproperties("Schedule") - State: Optional[PassThroughProp] = eventsscheduleproperties("State") + DeadLetterConfig: DeadLetterConfig | None = eventsscheduleproperties("DeadLetterConfig") + Description: PassThroughProp | None = eventsscheduleproperties("Description") + Enabled: bool | None = eventsscheduleproperties("Enabled") + Input: PassThroughProp | None = eventsscheduleproperties("Input") + Name: PassThroughProp | None = eventsscheduleproperties("Name") + RetryPolicy: PassThroughProp | None = eventsscheduleproperties("RetryPolicy") + Schedule: PassThroughProp | None = eventsscheduleproperties("Schedule") + State: PassThroughProp | None = eventsscheduleproperties("State") class ScheduleEvent(BaseModel): @@ -331,15 +331,15 @@ class EventBridgeRuleTarget(BaseModel): class EventBridgeRuleEventProperties(BaseModel): - DeadLetterConfig: Optional[DeadLetterConfig] = eventbridgeruleeventproperties("DeadLetterConfig") - EventBusName: Optional[PassThroughProp] = eventbridgeruleeventproperties("EventBusName") - Input: Optional[PassThroughProp] = eventbridgeruleeventproperties("Input") - InputPath: Optional[PassThroughProp] = eventbridgeruleeventproperties("InputPath") + DeadLetterConfig: DeadLetterConfig | None = eventbridgeruleeventproperties("DeadLetterConfig") + EventBusName: PassThroughProp | None = eventbridgeruleeventproperties("EventBusName") + Input: PassThroughProp | None = eventbridgeruleeventproperties("Input") + InputPath: PassThroughProp | None = eventbridgeruleeventproperties("InputPath") Pattern: PassThroughProp = eventbridgeruleeventproperties("Pattern") - RetryPolicy: Optional[PassThroughProp] = eventbridgeruleeventproperties("RetryPolicy") - Target: Optional[EventBridgeRuleTarget] = eventbridgeruleeventproperties("Target") - InputTransformer: Optional[PassThroughProp] # TODO: add docs - RuleName: Optional[PassThroughProp] = eventbridgeruleeventproperties("RuleName") + RetryPolicy: PassThroughProp | None = eventbridgeruleeventproperties("RetryPolicy") + Target: EventBridgeRuleTarget | None = eventbridgeruleeventproperties("Target") + InputTransformer: PassThroughProp | None # TODO: add docs + RuleName: PassThroughProp | None = eventbridgeruleeventproperties("RuleName") class EventBridgeRuleEvent(BaseModel): @@ -358,7 +358,7 @@ class CloudWatchLogsEvent(BaseModel): class IoTRuleEventProperties(BaseModel): - AwsIotSqlVersion: Optional[PassThroughProp] = iotruleeventproperties("AwsIotSqlVersion") + AwsIotSqlVersion: PassThroughProp | None = iotruleeventproperties("AwsIotSqlVersion") Sql: PassThroughProp = iotruleeventproperties("Sql") @@ -368,12 +368,12 @@ class IoTRuleEvent(BaseModel): class AlexaSkillEventProperties(BaseModel): - SkillId: Optional[str] = alexaskilleventproperties("SkillId") + SkillId: str | None = alexaskilleventproperties("SkillId") class AlexaSkillEvent(BaseModel): Type: Literal["AlexaSkill"] = event("Type") - Properties: Optional[AlexaSkillEventProperties] = event("Properties") + Properties: AlexaSkillEventProperties | None = event("Properties") class CognitoEventProperties(BaseModel): @@ -387,36 +387,36 @@ class CognitoEvent(BaseModel): class HttpApiAuth(BaseModel): - AuthorizationScopes: Optional[List[str]] = httpapiauth("AuthorizationScopes") - Authorizer: Optional[str] = httpapiauth("Authorizer") + AuthorizationScopes: list[str] | None = httpapiauth("AuthorizationScopes") + Authorizer: str | None = httpapiauth("Authorizer") class HttpApiEventProperties(BaseModel): - ApiId: Optional[SamIntrinsicable[str]] = httpapieventproperties("ApiId") - Auth: Optional[HttpApiAuth] = httpapieventproperties("Auth") - Method: Optional[str] = httpapieventproperties("Method") - Path: Optional[str] = httpapieventproperties("Path") - PayloadFormatVersion: Optional[SamIntrinsicable[str]] = httpapieventproperties("PayloadFormatVersion") - RouteSettings: Optional[PassThroughProp] = httpapieventproperties("RouteSettings") - TimeoutInMillis: Optional[SamIntrinsicable[int]] = httpapieventproperties("TimeoutInMillis") + ApiId: SamIntrinsicable[str] | None = httpapieventproperties("ApiId") + Auth: HttpApiAuth | None = httpapieventproperties("Auth") + Method: str | None = httpapieventproperties("Method") + Path: str | None = httpapieventproperties("Path") + PayloadFormatVersion: SamIntrinsicable[str] | None = httpapieventproperties("PayloadFormatVersion") + RouteSettings: PassThroughProp | None = httpapieventproperties("RouteSettings") + TimeoutInMillis: SamIntrinsicable[int] | None = httpapieventproperties("TimeoutInMillis") class HttpApiEvent(BaseModel): Type: Literal["HttpApi"] = event("Type") - Properties: Optional[HttpApiEventProperties] = event("Properties") + Properties: HttpApiEventProperties | None = event("Properties") class MSKEventProperties(BaseModel): - ConsumerGroupId: Optional[PassThroughProp] = mskeventproperties("ConsumerGroupId") - FilterCriteria: Optional[PassThroughProp] = mskeventproperties("FilterCriteria") - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation - MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = mskeventproperties("MaximumBatchingWindowInSeconds") - StartingPosition: Optional[PassThroughProp] = mskeventproperties("StartingPosition") - StartingPositionTimestamp: Optional[PassThroughProp] = mskeventproperties("StartingPositionTimestamp") + ConsumerGroupId: PassThroughProp | None = mskeventproperties("ConsumerGroupId") + FilterCriteria: PassThroughProp | None = mskeventproperties("FilterCriteria") + KmsKeyArn: PassThroughProp | None # TODO: add documentation + MaximumBatchingWindowInSeconds: PassThroughProp | None = mskeventproperties("MaximumBatchingWindowInSeconds") + StartingPosition: PassThroughProp | None = mskeventproperties("StartingPosition") + StartingPositionTimestamp: PassThroughProp | None = mskeventproperties("StartingPositionTimestamp") Stream: PassThroughProp = mskeventproperties("Stream") Topics: PassThroughProp = mskeventproperties("Topics") - SourceAccessConfigurations: Optional[PassThroughProp] = mskeventproperties("SourceAccessConfigurations") - DestinationConfig: Optional[PassThroughProp] # TODO: add documentation + SourceAccessConfigurations: PassThroughProp | None = mskeventproperties("SourceAccessConfigurations") + DestinationConfig: PassThroughProp | None # TODO: add documentation class MSKEvent(BaseModel): @@ -425,15 +425,15 @@ class MSKEvent(BaseModel): class MQEventProperties(BaseModel): - BatchSize: Optional[PassThroughProp] = mqeventproperties("BatchSize") + BatchSize: PassThroughProp | None = mqeventproperties("BatchSize") Broker: PassThroughProp = mqeventproperties("Broker") - DynamicPolicyName: Optional[bool] = mqeventproperties("DynamicPolicyName") - Enabled: Optional[PassThroughProp] = mqeventproperties("Enabled") - FilterCriteria: Optional[PassThroughProp] = mqeventproperties("FilterCriteria") - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation - MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = mqeventproperties("MaximumBatchingWindowInSeconds") + DynamicPolicyName: bool | None = mqeventproperties("DynamicPolicyName") + Enabled: PassThroughProp | None = mqeventproperties("Enabled") + FilterCriteria: PassThroughProp | None = mqeventproperties("FilterCriteria") + KmsKeyArn: PassThroughProp | None # TODO: add documentation + MaximumBatchingWindowInSeconds: PassThroughProp | None = mqeventproperties("MaximumBatchingWindowInSeconds") Queues: PassThroughProp = mqeventproperties("Queues") - SecretsManagerKmsKeyId: Optional[str] = mqeventproperties("SecretsManagerKmsKeyId") + SecretsManagerKmsKeyId: str | None = mqeventproperties("SecretsManagerKmsKeyId") SourceAccessConfigurations: PassThroughProp = mqeventproperties("SourceAccessConfigurations") @@ -443,17 +443,17 @@ class MQEvent(BaseModel): class SelfManagedKafkaEventProperties(BaseModel): - BatchSize: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("BatchSize") - ConsumerGroupId: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("ConsumerGroupId") - Enabled: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("Enabled") - FilterCriteria: Optional[PassThroughProp] = selfmanagedkafkaeventproperties("FilterCriteria") - KafkaBootstrapServers: Optional[List[SamIntrinsicable[str]]] = selfmanagedkafkaeventproperties( + BatchSize: PassThroughProp | None = selfmanagedkafkaeventproperties("BatchSize") + ConsumerGroupId: PassThroughProp | None = selfmanagedkafkaeventproperties("ConsumerGroupId") + Enabled: PassThroughProp | None = selfmanagedkafkaeventproperties("Enabled") + FilterCriteria: PassThroughProp | None = selfmanagedkafkaeventproperties("FilterCriteria") + KafkaBootstrapServers: list[SamIntrinsicable[str]] | None = selfmanagedkafkaeventproperties( "KafkaBootstrapServers" ) - KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation + KmsKeyArn: PassThroughProp | None # TODO: add documentation SourceAccessConfigurations: PassThroughProp = selfmanagedkafkaeventproperties("SourceAccessConfigurations") - StartingPosition: Optional[PassThroughProp] # TODO: add documentation - StartingPositionTimestamp: Optional[PassThroughProp] # TODO: add documentation + StartingPosition: PassThroughProp | None # TODO: add documentation + StartingPositionTimestamp: PassThroughProp | None # TODO: add documentation Topics: PassThroughProp = selfmanagedkafkaeventproperties("Topics") @@ -464,22 +464,22 @@ class SelfManagedKafkaEvent(BaseModel): # TODO: Same as ScheduleV2EventProperties in state machine? class ScheduleV2EventProperties(BaseModel): - DeadLetterConfig: Optional[DeadLetterConfig] = schedulev2eventproperties("DeadLetterConfig") - Description: Optional[PassThroughProp] = schedulev2eventproperties("Description") - EndDate: Optional[PassThroughProp] = schedulev2eventproperties("EndDate") - FlexibleTimeWindow: Optional[PassThroughProp] = schedulev2eventproperties("FlexibleTimeWindow") - GroupName: Optional[PassThroughProp] = schedulev2eventproperties("GroupName") - Input: Optional[PassThroughProp] = schedulev2eventproperties("Input") - KmsKeyArn: Optional[PassThroughProp] = schedulev2eventproperties("KmsKeyArn") - Name: Optional[PassThroughProp] = schedulev2eventproperties("Name") - PermissionsBoundary: Optional[PassThroughProp] = schedulev2eventproperties("PermissionsBoundary") - RetryPolicy: Optional[PassThroughProp] = schedulev2eventproperties("RetryPolicy") - RoleArn: Optional[PassThroughProp] = schedulev2eventproperties("RoleArn") - ScheduleExpression: Optional[PassThroughProp] = schedulev2eventproperties("ScheduleExpression") - ScheduleExpressionTimezone: Optional[PassThroughProp] = schedulev2eventproperties("ScheduleExpressionTimezone") - StartDate: Optional[PassThroughProp] = schedulev2eventproperties("StartDate") - State: Optional[PassThroughProp] = schedulev2eventproperties("State") - OmitName: Optional[bool] # TODO: add doc + DeadLetterConfig: DeadLetterConfig | None = schedulev2eventproperties("DeadLetterConfig") + Description: PassThroughProp | None = schedulev2eventproperties("Description") + EndDate: PassThroughProp | None = schedulev2eventproperties("EndDate") + FlexibleTimeWindow: PassThroughProp | None = schedulev2eventproperties("FlexibleTimeWindow") + GroupName: PassThroughProp | None = schedulev2eventproperties("GroupName") + Input: PassThroughProp | None = schedulev2eventproperties("Input") + KmsKeyArn: PassThroughProp | None = schedulev2eventproperties("KmsKeyArn") + Name: PassThroughProp | None = schedulev2eventproperties("Name") + PermissionsBoundary: PassThroughProp | None = schedulev2eventproperties("PermissionsBoundary") + RetryPolicy: PassThroughProp | None = schedulev2eventproperties("RetryPolicy") + RoleArn: PassThroughProp | None = schedulev2eventproperties("RoleArn") + ScheduleExpression: PassThroughProp | None = schedulev2eventproperties("ScheduleExpression") + ScheduleExpressionTimezone: PassThroughProp | None = schedulev2eventproperties("ScheduleExpressionTimezone") + StartDate: PassThroughProp | None = schedulev2eventproperties("StartDate") + State: PassThroughProp | None = schedulev2eventproperties("State") + OmitName: bool | None # TODO: add doc class ScheduleV2Event(BaseModel): @@ -517,194 +517,194 @@ class ScheduleV2Event(BaseModel): class Properties(BaseModel): - Architectures: Optional[Architectures] = passthrough_prop( + Architectures: Architectures | None = passthrough_prop( PROPERTIES_STEM, "Architectures", ["AWS::Lambda::Function", "Properties", "Architectures"], ) - AssumeRolePolicyDocument: Optional[AssumeRolePolicyDocument] = prop("AssumeRolePolicyDocument") - AutoPublishAlias: Optional[AutoPublishAlias] = prop("AutoPublishAlias") - AutoPublishAliasAllProperties: Optional[AutoPublishAliasAllProperties] = prop("AutoPublishAliasAllProperties") - AutoPublishCodeSha256: Optional[SamIntrinsicable[str]] = prop("AutoPublishCodeSha256") - CodeSigningConfigArn: Optional[SamIntrinsicable[str]] = passthrough_prop( + AssumeRolePolicyDocument: AssumeRolePolicyDocument | None = prop("AssumeRolePolicyDocument") + AutoPublishAlias: AutoPublishAlias | None = prop("AutoPublishAlias") + AutoPublishAliasAllProperties: AutoPublishAliasAllProperties | None = prop("AutoPublishAliasAllProperties") + AutoPublishCodeSha256: SamIntrinsicable[str] | None = prop("AutoPublishCodeSha256") + CodeSigningConfigArn: SamIntrinsicable[str] | None = passthrough_prop( PROPERTIES_STEM, "CodeSigningConfigArn", ["AWS::Lambda::Function", "Properties", "CodeSigningConfigArn"], ) - CodeUri: Optional[CodeUriType] = prop("CodeUri") - DeadLetterQueue: Optional[DeadLetterQueueType] = prop("DeadLetterQueue") - DeploymentPreference: Optional[DeploymentPreference] = prop("DeploymentPreference") - Description: Optional[Description] = passthrough_prop( + CodeUri: CodeUriType | None = prop("CodeUri") + DeadLetterQueue: DeadLetterQueueType | None = prop("DeadLetterQueue") + DeploymentPreference: DeploymentPreference | None = prop("DeploymentPreference") + Description: Description | None = passthrough_prop( PROPERTIES_STEM, "Description", ["AWS::Lambda::Function", "Properties", "Description"], ) # TODO: Make the notation shorter; resource type and SAM/CFN property names usually same - Environment: Optional[Environment] = passthrough_prop( + Environment: Environment | None = passthrough_prop( PROPERTIES_STEM, "Environment", ["AWS::Lambda::Function", "Properties", "Environment"], ) - EphemeralStorage: Optional[EphemeralStorage] = passthrough_prop( + EphemeralStorage: EphemeralStorage | None = passthrough_prop( PROPERTIES_STEM, "EphemeralStorage", ["AWS::Lambda::Function", "Properties", "EphemeralStorage"], ) - EventInvokeConfig: Optional[EventInvokeConfig] = prop("EventInvokeConfig") - Events: Optional[ - Dict[ + EventInvokeConfig: EventInvokeConfig | None = prop("EventInvokeConfig") + Events: None | ( + dict[ str, - Union[ - S3Event, - SNSEvent, - KinesisEvent, - DynamoDBEvent, - DocumentDBEvent, - SQSEvent, - ApiEvent, - ScheduleEvent, - ScheduleV2Event, - CloudWatchEvent, - EventBridgeRuleEvent, - CloudWatchLogsEvent, - IoTRuleEvent, - AlexaSkillEvent, - CognitoEvent, - HttpApiEvent, - MSKEvent, - MQEvent, - SelfManagedKafkaEvent, - ], + ( + S3Event | + SNSEvent | + KinesisEvent | + DynamoDBEvent | + DocumentDBEvent | + SQSEvent | + ApiEvent | + ScheduleEvent | + ScheduleV2Event | + CloudWatchEvent | + EventBridgeRuleEvent | + CloudWatchLogsEvent | + IoTRuleEvent | + AlexaSkillEvent | + CognitoEvent | + HttpApiEvent | + MSKEvent | + MQEvent | + SelfManagedKafkaEvent + ), ] - ] = prop("Events") - FileSystemConfigs: Optional[PassThroughProp] = passthrough_prop( + ) = prop("Events") + FileSystemConfigs: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "FileSystemConfigs", ["AWS::Lambda::Function", "Properties", "FileSystemConfigs"], ) - FunctionName: Optional[PassThroughProp] = passthrough_prop( + FunctionName: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "FunctionName", ["AWS::Lambda::Function", "Properties", "FunctionName"], ) - FunctionUrlConfig: Optional[FunctionUrlConfig] = prop("FunctionUrlConfig") - Handler: Optional[Handler] = passthrough_prop( + FunctionUrlConfig: FunctionUrlConfig | None = prop("FunctionUrlConfig") + Handler: Handler | None = passthrough_prop( PROPERTIES_STEM, "Handler", ["AWS::Lambda::Function", "Properties", "Handler"], ) - ImageConfig: Optional[PassThroughProp] = passthrough_prop( + ImageConfig: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "ImageConfig", ["AWS::Lambda::Function", "Properties", "ImageConfig"], ) - ImageUri: Optional[PassThroughProp] = passthrough_prop( + ImageUri: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "ImageUri", ["AWS::Lambda::Function.Code", "ImageUri"], ) - InlineCode: Optional[PassThroughProp] = prop("InlineCode") - KmsKeyArn: Optional[KmsKeyArn] = prop("KmsKeyArn") - Layers: Optional[Layers] = prop("Layers") - MemorySize: Optional[MemorySize] = prop("MemorySize") - PackageType: Optional[PassThroughProp] = prop("PackageType") - RolePath: Optional[RolePath] = passthrough_prop( + InlineCode: PassThroughProp | None = prop("InlineCode") + KmsKeyArn: KmsKeyArn | None = prop("KmsKeyArn") + Layers: Layers | None = prop("Layers") + MemorySize: MemorySize | None = prop("MemorySize") + PackageType: PassThroughProp | None = prop("PackageType") + RolePath: RolePath | None = passthrough_prop( PROPERTIES_STEM, "RolePath", ["AWS::IAM::Role", "Properties", "Path"], ) - PermissionsBoundary: Optional[PermissionsBoundary] = passthrough_prop( + PermissionsBoundary: PermissionsBoundary | None = passthrough_prop( PROPERTIES_STEM, "PermissionsBoundary", ["AWS::IAM::Role", "Properties", "PermissionsBoundary"], ) - Policies: Optional[Union[str, DictStrAny, List[Union[str, DictStrAny]]]] = prop("Policies") - ProvisionedConcurrencyConfig: Optional[ProvisionedConcurrencyConfig] = passthrough_prop( + Policies: str | DictStrAny | list[str | DictStrAny] | None = prop("Policies") + ProvisionedConcurrencyConfig: ProvisionedConcurrencyConfig | None = passthrough_prop( PROPERTIES_STEM, "ProvisionedConcurrencyConfig", ["AWS::Lambda::Alias", "Properties", "ProvisionedConcurrencyConfig"], ) - ReservedConcurrentExecutions: Optional[ReservedConcurrentExecutions] = prop("ReservedConcurrentExecutions") - Role: Optional[SamIntrinsicable[str]] = prop("Role") - Runtime: Optional[Runtime] = passthrough_prop( + ReservedConcurrentExecutions: ReservedConcurrentExecutions | None = prop("ReservedConcurrentExecutions") + Role: SamIntrinsicable[str] | None = prop("Role") + Runtime: Runtime | None = passthrough_prop( PROPERTIES_STEM, "Runtime", ["AWS::Lambda::Function", "Properties", "Runtime"], ) - SnapStart: Optional[SnapStart] = prop("SnapStart") - RuntimeManagementConfig: Optional[RuntimeManagementConfig] = prop("RuntimeManagementConfig") - Tags: Optional[Tags] = prop("Tags") - PropagateTags: Optional[bool] = prop("PropagateTags") - Timeout: Optional[Timeout] = prop("Timeout") - Tracing: Optional[Tracing] = prop("Tracing") - VersionDescription: Optional[PassThroughProp] = prop("VersionDescription") - VpcConfig: Optional[VpcConfig] = prop("VpcConfig") - LoggingConfig: Optional[PassThroughProp] # TODO: add documentation - RecursiveLoop: Optional[PassThroughProp] # TODO: add documentation - SourceKMSKeyArn: Optional[PassThroughProp] # TODO: add documentation + SnapStart: SnapStart | None = prop("SnapStart") + RuntimeManagementConfig: RuntimeManagementConfig | None = prop("RuntimeManagementConfig") + Tags: Tags | None = prop("Tags") + PropagateTags: bool | None = prop("PropagateTags") + Timeout: Timeout | None = prop("Timeout") + Tracing: Tracing | None = prop("Tracing") + VersionDescription: PassThroughProp | None = prop("VersionDescription") + VpcConfig: VpcConfig | None = prop("VpcConfig") + LoggingConfig: PassThroughProp | None # TODO: add documentation + RecursiveLoop: PassThroughProp | None # TODO: add documentation + SourceKMSKeyArn: PassThroughProp | None # TODO: add documentation class Globals(BaseModel): - Handler: Optional[Handler] = passthrough_prop( + Handler: Handler | None = passthrough_prop( PROPERTIES_STEM, "Handler", ["AWS::Lambda::Function", "Properties", "Handler"], ) - Runtime: Optional[Runtime] = passthrough_prop( + Runtime: Runtime | None = passthrough_prop( PROPERTIES_STEM, "Runtime", ["AWS::Lambda::Function", "Properties", "Runtime"], ) - CodeUri: Optional[CodeUriType] = prop("CodeUri") - DeadLetterQueue: Optional[DeadLetterQueueType] = prop("DeadLetterQueue") - Description: Optional[Description] = prop("Description") - MemorySize: Optional[MemorySize] = prop("MemorySize") - Timeout: Optional[Timeout] = prop("Timeout") - VpcConfig: Optional[VpcConfig] = prop("VpcConfig") - Environment: Optional[Environment] = passthrough_prop( + CodeUri: CodeUriType | None = prop("CodeUri") + DeadLetterQueue: DeadLetterQueueType | None = prop("DeadLetterQueue") + Description: Description | None = prop("Description") + MemorySize: MemorySize | None = prop("MemorySize") + Timeout: Timeout | None = prop("Timeout") + VpcConfig: VpcConfig | None = prop("VpcConfig") + Environment: Environment | None = passthrough_prop( PROPERTIES_STEM, "Environment", ["AWS::Lambda::Function", "Properties", "Environment"], ) - Tags: Optional[Tags] = prop("Tags") - PropagateTags: Optional[bool] = prop("PropagateTags") - Tracing: Optional[Tracing] = prop("Tracing") - KmsKeyArn: Optional[KmsKeyArn] = prop("KmsKeyArn") - Layers: Optional[Layers] = prop("Layers") - AutoPublishAlias: Optional[AutoPublishAlias] = prop("AutoPublishAlias") - DeploymentPreference: Optional[DeploymentPreference] = prop("DeploymentPreference") - RolePath: Optional[RolePath] = passthrough_prop( + Tags: Tags | None = prop("Tags") + PropagateTags: bool | None = prop("PropagateTags") + Tracing: Tracing | None = prop("Tracing") + KmsKeyArn: KmsKeyArn | None = prop("KmsKeyArn") + Layers: Layers | None = prop("Layers") + AutoPublishAlias: AutoPublishAlias | None = prop("AutoPublishAlias") + DeploymentPreference: DeploymentPreference | None = prop("DeploymentPreference") + RolePath: RolePath | None = passthrough_prop( PROPERTIES_STEM, "RolePath", ["AWS::IAM::Role", "Properties", "Path"], ) - PermissionsBoundary: Optional[PermissionsBoundary] = passthrough_prop( + PermissionsBoundary: PermissionsBoundary | None = passthrough_prop( PROPERTIES_STEM, "PermissionsBoundary", ["AWS::IAM::Role", "Properties", "PermissionsBoundary"], ) - ReservedConcurrentExecutions: Optional[ReservedConcurrentExecutions] = prop("ReservedConcurrentExecutions") - ProvisionedConcurrencyConfig: Optional[ProvisionedConcurrencyConfig] = prop("ProvisionedConcurrencyConfig") - AssumeRolePolicyDocument: Optional[AssumeRolePolicyDocument] = prop("AssumeRolePolicyDocument") - EventInvokeConfig: Optional[EventInvokeConfig] = prop("EventInvokeConfig") - Architectures: Optional[Architectures] = passthrough_prop( + ReservedConcurrentExecutions: ReservedConcurrentExecutions | None = prop("ReservedConcurrentExecutions") + ProvisionedConcurrencyConfig: ProvisionedConcurrencyConfig | None = prop("ProvisionedConcurrencyConfig") + AssumeRolePolicyDocument: AssumeRolePolicyDocument | None = prop("AssumeRolePolicyDocument") + EventInvokeConfig: EventInvokeConfig | None = prop("EventInvokeConfig") + Architectures: Architectures | None = passthrough_prop( PROPERTIES_STEM, "Architectures", ["AWS::Lambda::Function", "Properties", "Architectures"], ) - EphemeralStorage: Optional[EphemeralStorage] = passthrough_prop( + EphemeralStorage: EphemeralStorage | None = passthrough_prop( PROPERTIES_STEM, "EphemeralStorage", ["AWS::Lambda::Function", "Properties", "EphemeralStorage"], ) - SnapStart: Optional[SnapStart] = prop("SnapStart") - RuntimeManagementConfig: Optional[RuntimeManagementConfig] = prop("RuntimeManagementConfig") - LoggingConfig: Optional[PassThroughProp] # TODO: add documentation - RecursiveLoop: Optional[PassThroughProp] # TODO: add documentation - SourceKMSKeyArn: Optional[PassThroughProp] # TODO: add documentation + SnapStart: SnapStart | None = prop("SnapStart") + RuntimeManagementConfig: RuntimeManagementConfig | None = prop("RuntimeManagementConfig") + LoggingConfig: PassThroughProp | None # TODO: add documentation + RecursiveLoop: PassThroughProp | None # TODO: add documentation + SourceKMSKeyArn: PassThroughProp | None # TODO: add documentation class Resource(ResourceAttributes): Type: Literal["AWS::Serverless::Function"] - Properties: Optional[Properties] - Connectors: Optional[Dict[str, EmbeddedConnector]] + Properties: Properties | None + Connectors: dict[str, EmbeddedConnector] | None diff --git a/samtranslator/internal/schema_source/aws_serverless_httpapi.py b/samtranslator/internal/schema_source/aws_serverless_httpapi.py index c658527eb..ed3b4c010 100644 --- a/samtranslator/internal/schema_source/aws_serverless_httpapi.py +++ b/samtranslator/internal/schema_source/aws_serverless_httpapi.py @@ -24,80 +24,80 @@ class OAuth2Authorizer(BaseModel): - AuthorizationScopes: Optional[List[str]] = oauth2authorizer("AuthorizationScopes") - IdentitySource: Optional[str] = oauth2authorizer("IdentitySource") - JwtConfiguration: Optional[PassThroughProp] = oauth2authorizer("JwtConfiguration") + AuthorizationScopes: list[str] | None = oauth2authorizer("AuthorizationScopes") + IdentitySource: str | None = oauth2authorizer("IdentitySource") + JwtConfiguration: PassThroughProp | None = oauth2authorizer("JwtConfiguration") class LambdaAuthorizerIdentity(BaseModel): - Context: Optional[List[str]] = lambdauthorizeridentity("Context") - Headers: Optional[List[str]] = lambdauthorizeridentity("Headers") - QueryStrings: Optional[List[str]] = lambdauthorizeridentity("QueryStrings") - ReauthorizeEvery: Optional[int] = lambdauthorizeridentity("ReauthorizeEvery") - StageVariables: Optional[List[str]] = lambdauthorizeridentity("StageVariables") + Context: list[str] | None = lambdauthorizeridentity("Context") + Headers: list[str] | None = lambdauthorizeridentity("Headers") + QueryStrings: list[str] | None = lambdauthorizeridentity("QueryStrings") + ReauthorizeEvery: int | None = lambdauthorizeridentity("ReauthorizeEvery") + StageVariables: list[str] | None = lambdauthorizeridentity("StageVariables") class LambdaAuthorizer(BaseModel): # TODO: Many tests use floats for the version string; docs only mention string - AuthorizerPayloadFormatVersion: Union[Literal["1.0", "2.0"], float] = lambdaauthorizer( + AuthorizerPayloadFormatVersion: Literal["1.0", "2.0"] | float = lambdaauthorizer( "AuthorizerPayloadFormatVersion" ) - EnableSimpleResponses: Optional[bool] = lambdaauthorizer("EnableSimpleResponses") + EnableSimpleResponses: bool | None = lambdaauthorizer("EnableSimpleResponses") FunctionArn: SamIntrinsicable[str] = lambdaauthorizer("FunctionArn") - FunctionInvokeRole: Optional[SamIntrinsicable[str]] = lambdaauthorizer("FunctionInvokeRole") - EnableFunctionDefaultPermissions: Optional[bool] # TODO: add docs - Identity: Optional[LambdaAuthorizerIdentity] = lambdaauthorizer("Identity") + FunctionInvokeRole: SamIntrinsicable[str] | None = lambdaauthorizer("FunctionInvokeRole") + EnableFunctionDefaultPermissions: bool | None # TODO: add docs + Identity: LambdaAuthorizerIdentity | None = lambdaauthorizer("Identity") class Auth(BaseModel): # TODO: Docs doesn't say it's a map - Authorizers: Optional[ - Dict[ + Authorizers: None | ( + dict[ str, - Union[ - OAuth2Authorizer, - LambdaAuthorizer, - ], + ( + OAuth2Authorizer | + LambdaAuthorizer + ), ] - ] = auth("Authorizers") - DefaultAuthorizer: Optional[str] = auth("DefaultAuthorizer") - EnableIamAuthorizer: Optional[bool] = auth("EnableIamAuthorizer") + ) = auth("Authorizers") + DefaultAuthorizer: str | None = auth("DefaultAuthorizer") + EnableIamAuthorizer: bool | None = auth("EnableIamAuthorizer") class CorsConfiguration(BaseModel): - AllowCredentials: Optional[bool] = corsconfiguration("AllowCredentials") - AllowHeaders: Optional[List[str]] = corsconfiguration("AllowHeaders") - AllowMethods: Optional[List[str]] = corsconfiguration("AllowMethods") - AllowOrigins: Optional[List[str]] = corsconfiguration("AllowOrigins") - ExposeHeaders: Optional[List[str]] = corsconfiguration("ExposeHeaders") - MaxAge: Optional[int] = corsconfiguration("MaxAge") + AllowCredentials: bool | None = corsconfiguration("AllowCredentials") + AllowHeaders: list[str] | None = corsconfiguration("AllowHeaders") + AllowMethods: list[str] | None = corsconfiguration("AllowMethods") + AllowOrigins: list[str] | None = corsconfiguration("AllowOrigins") + ExposeHeaders: list[str] | None = corsconfiguration("ExposeHeaders") + MaxAge: int | None = corsconfiguration("MaxAge") class DefinitionUri(BaseModel): Bucket: str = definitionuri("Bucket") Key: str = definitionuri("Key") - Version: Optional[str] = definitionuri("Version") + Version: str | None = definitionuri("Version") class Route53(BaseModel): - DistributionDomainName: Optional[PassThroughProp] = route53("DistributionDomainName") - EvaluateTargetHealth: Optional[PassThroughProp] = route53("EvaluateTargetHealth") - HostedZoneId: Optional[PassThroughProp] = route53("HostedZoneId") - HostedZoneName: Optional[PassThroughProp] = route53("HostedZoneName") - IpV6: Optional[bool] = route53("IpV6") - SetIdentifier: Optional[PassThroughProp] # TODO: add docs - Region: Optional[PassThroughProp] # TODO: add docs + DistributionDomainName: PassThroughProp | None = route53("DistributionDomainName") + EvaluateTargetHealth: PassThroughProp | None = route53("EvaluateTargetHealth") + HostedZoneId: PassThroughProp | None = route53("HostedZoneId") + HostedZoneName: PassThroughProp | None = route53("HostedZoneName") + IpV6: bool | None = route53("IpV6") + SetIdentifier: PassThroughProp | None # TODO: add docs + Region: PassThroughProp | None # TODO: add docs class Domain(BaseModel): - BasePath: Optional[List[str]] = domain("BasePath") + BasePath: list[str] | None = domain("BasePath") CertificateArn: PassThroughProp = domain("CertificateArn") DomainName: PassThroughProp = domain("DomainName") - EndpointConfiguration: Optional[SamIntrinsicable[Literal["REGIONAL"]]] = domain("EndpointConfiguration") - MutualTlsAuthentication: Optional[PassThroughProp] = domain("MutualTlsAuthentication") - OwnershipVerificationCertificateArn: Optional[PassThroughProp] = domain("OwnershipVerificationCertificateArn") - Route53: Optional[Route53] = domain("Route53") - SecurityPolicy: Optional[PassThroughProp] = domain("SecurityPolicy") + EndpointConfiguration: SamIntrinsicable[Literal["REGIONAL"]] | None = domain("EndpointConfiguration") + MutualTlsAuthentication: PassThroughProp | None = domain("MutualTlsAuthentication") + OwnershipVerificationCertificateArn: PassThroughProp | None = domain("OwnershipVerificationCertificateArn") + Route53: Route53 | None = domain("Route53") + SecurityPolicy: PassThroughProp | None = domain("SecurityPolicy") AccessLogSettings = Optional[PassThroughProp] @@ -110,39 +110,39 @@ class Domain(BaseModel): class Properties(BaseModel): - AccessLogSettings: Optional[AccessLogSettings] = properties("AccessLogSettings") - Auth: Optional[Auth] = properties("Auth") + AccessLogSettings: AccessLogSettings | None = properties("AccessLogSettings") + Auth: Auth | None = properties("Auth") # TODO: Also string like in the docs? - CorsConfiguration: Optional[CorsConfigurationType] = properties("CorsConfiguration") - DefaultRouteSettings: Optional[DefaultRouteSettings] = properties("DefaultRouteSettings") - DefinitionBody: Optional[DictStrAny] = properties("DefinitionBody") - DefinitionUri: Optional[Union[str, DefinitionUri]] = properties("DefinitionUri") - Description: Optional[str] = properties("Description") - DisableExecuteApiEndpoint: Optional[PassThroughProp] = properties("DisableExecuteApiEndpoint") - Domain: Optional[Domain] = properties("Domain") - FailOnWarnings: Optional[FailOnWarnings] = properties("FailOnWarnings") - RouteSettings: Optional[RouteSettings] = properties("RouteSettings") - StageName: Optional[PassThroughProp] = properties("StageName") - StageVariables: Optional[StageVariables] = properties("StageVariables") - Tags: Optional[Tags] = properties("Tags") - PropagateTags: Optional[bool] # TODO: add docs - Name: Optional[PassThroughProp] = properties("Name") + CorsConfiguration: CorsConfigurationType | None = properties("CorsConfiguration") + DefaultRouteSettings: DefaultRouteSettings | None = properties("DefaultRouteSettings") + DefinitionBody: DictStrAny | None = properties("DefinitionBody") + DefinitionUri: str | DefinitionUri | None = properties("DefinitionUri") + Description: str | None = properties("Description") + DisableExecuteApiEndpoint: PassThroughProp | None = properties("DisableExecuteApiEndpoint") + Domain: Domain | None = properties("Domain") + FailOnWarnings: FailOnWarnings | None = properties("FailOnWarnings") + RouteSettings: RouteSettings | None = properties("RouteSettings") + StageName: PassThroughProp | None = properties("StageName") + StageVariables: StageVariables | None = properties("StageVariables") + Tags: Tags | None = properties("Tags") + PropagateTags: bool | None # TODO: add docs + Name: PassThroughProp | None = properties("Name") class Globals(BaseModel): - Auth: Optional[Auth] = properties("Auth") - AccessLogSettings: Optional[AccessLogSettings] = properties("AccessLogSettings") - StageVariables: Optional[StageVariables] = properties("StageVariables") - Tags: Optional[Tags] = properties("Tags") - RouteSettings: Optional[RouteSettings] = properties("RouteSettings") - FailOnWarnings: Optional[FailOnWarnings] = properties("FailOnWarnings") - Domain: Optional[Domain] = properties("Domain") - CorsConfiguration: Optional[CorsConfigurationType] = properties("CorsConfiguration") - DefaultRouteSettings: Optional[DefaultRouteSettings] = properties("DefaultRouteSettings") - PropagateTags: Optional[bool] # TODO: add docs + Auth: Auth | None = properties("Auth") + AccessLogSettings: AccessLogSettings | None = properties("AccessLogSettings") + StageVariables: StageVariables | None = properties("StageVariables") + Tags: Tags | None = properties("Tags") + RouteSettings: RouteSettings | None = properties("RouteSettings") + FailOnWarnings: FailOnWarnings | None = properties("FailOnWarnings") + Domain: Domain | None = properties("Domain") + CorsConfiguration: CorsConfigurationType | None = properties("CorsConfiguration") + DefaultRouteSettings: DefaultRouteSettings | None = properties("DefaultRouteSettings") + PropagateTags: bool | None # TODO: add docs class Resource(ResourceAttributes): Type: Literal["AWS::Serverless::HttpApi"] - Properties: Optional[Properties] - Connectors: Optional[Dict[str, EmbeddedConnector]] + Properties: Properties | None + Connectors: dict[str, EmbeddedConnector] | None diff --git a/samtranslator/internal/schema_source/aws_serverless_layerversion.py b/samtranslator/internal/schema_source/aws_serverless_layerversion.py index 298ecf8de..c612115f7 100644 --- a/samtranslator/internal/schema_source/aws_serverless_layerversion.py +++ b/samtranslator/internal/schema_source/aws_serverless_layerversion.py @@ -29,7 +29,7 @@ class ContentUri(BaseModel): "Key", ["AWS::Lambda::LayerVersion.Content", "S3Key"], ) - Version: Optional[PassThroughProp] = passthrough_prop( + Version: PassThroughProp | None = passthrough_prop( CONTENT_URI_STEM, "Version", ["AWS::Lambda::LayerVersion.Content", "S3ObjectVersion"], @@ -37,30 +37,30 @@ class ContentUri(BaseModel): class Properties(BaseModel): - CompatibleArchitectures: Optional[PassThroughProp] = passthrough_prop( + CompatibleArchitectures: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "CompatibleArchitectures", ["AWS::Lambda::LayerVersion", "Properties", "CompatibleArchitectures"], ) - CompatibleRuntimes: Optional[PassThroughProp] = passthrough_prop( + CompatibleRuntimes: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "CompatibleRuntimes", ["AWS::Lambda::LayerVersion", "Properties", "CompatibleRuntimes"], ) - PublishLambdaVersion: Optional[bool] # TODO: add docs - ContentUri: Union[str, ContentUri] = properties("ContentUri") - Description: Optional[PassThroughProp] = passthrough_prop( + PublishLambdaVersion: bool | None # TODO: add docs + ContentUri: str | ContentUri = properties("ContentUri") + Description: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "Description", ["AWS::Lambda::LayerVersion", "Properties", "Description"], ) - LayerName: Optional[PassThroughProp] = properties("LayerName") - LicenseInfo: Optional[PassThroughProp] = passthrough_prop( + LayerName: PassThroughProp | None = properties("LayerName") + LicenseInfo: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "LicenseInfo", ["AWS::Lambda::LayerVersion", "Properties", "LicenseInfo"], ) - RetentionPolicy: Optional[SamIntrinsicable[str]] = properties("RetentionPolicy") + RetentionPolicy: SamIntrinsicable[str] | None = properties("RetentionPolicy") class Resource(ResourceAttributes): @@ -69,4 +69,4 @@ class Resource(ResourceAttributes): class Globals(BaseModel): - PublishLambdaVersion: Optional[bool] # TODO: add docs + PublishLambdaVersion: bool | None # TODO: add docs diff --git a/samtranslator/internal/schema_source/aws_serverless_simpletable.py b/samtranslator/internal/schema_source/aws_serverless_simpletable.py index c21f9b9d7..2cf3cf71b 100644 --- a/samtranslator/internal/schema_source/aws_serverless_simpletable.py +++ b/samtranslator/internal/schema_source/aws_serverless_simpletable.py @@ -35,28 +35,28 @@ class PrimaryKey(BaseModel): class Properties(BaseModel): - PointInTimeRecoverySpecification: Optional[PassThroughProp] # TODO: add docs - PrimaryKey: Optional[PrimaryKey] = properties("PrimaryKey") - ProvisionedThroughput: Optional[PassThroughProp] = passthrough_prop( + PointInTimeRecoverySpecification: PassThroughProp | None # TODO: add docs + PrimaryKey: PrimaryKey | None = properties("PrimaryKey") + ProvisionedThroughput: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "ProvisionedThroughput", ["AWS::DynamoDB::Table", "Properties", "ProvisionedThroughput"], ) - SSESpecification: Optional[SSESpecification] = passthrough_prop( + SSESpecification: SSESpecification | None = passthrough_prop( PROPERTIES_STEM, "SSESpecification", ["AWS::DynamoDB::Table", "Properties", "SSESpecification"], ) - TableName: Optional[PassThroughProp] = passthrough_prop( + TableName: PassThroughProp | None = passthrough_prop( PROPERTIES_STEM, "TableName", ["AWS::DynamoDB::Table", "Properties", "TableName"], ) - Tags: Optional[Dict[str, Any]] = properties("Tags") + Tags: dict[str, Any] | None = properties("Tags") class Globals(BaseModel): - SSESpecification: Optional[SSESpecification] = passthrough_prop( + SSESpecification: SSESpecification | None = passthrough_prop( PROPERTIES_STEM, "SSESpecification", ["AWS::DynamoDB::Table", "Properties", "SSESpecification"], @@ -65,5 +65,5 @@ class Globals(BaseModel): class Resource(ResourceAttributes): Type: Literal["AWS::Serverless::SimpleTable"] - Properties: Optional[Properties] - Connectors: Optional[Dict[str, EmbeddedConnector]] + Properties: Properties | None + Connectors: dict[str, EmbeddedConnector] | None diff --git a/samtranslator/internal/schema_source/aws_serverless_statemachine.py b/samtranslator/internal/schema_source/aws_serverless_statemachine.py index 355064767..265482470 100644 --- a/samtranslator/internal/schema_source/aws_serverless_statemachine.py +++ b/samtranslator/internal/schema_source/aws_serverless_statemachine.py @@ -28,9 +28,9 @@ class DeadLetterConfig(BaseModel): - Arn: Optional[PassThroughProp] = deadletterconfig("Arn") - QueueLogicalId: Optional[str] = deadletterconfig("QueueLogicalId") - Type: Optional[Literal["SQS"]] = deadletterconfig("Type") + Arn: PassThroughProp | None = deadletterconfig("Arn") + QueueLogicalId: str | None = deadletterconfig("QueueLogicalId") + Type: Literal["SQS"] | None = deadletterconfig("Type") class ScheduleTarget(BaseModel): @@ -38,16 +38,16 @@ class ScheduleTarget(BaseModel): class ScheduleEventProperties(BaseModel): - DeadLetterConfig: Optional[DeadLetterConfig] = scheduleeventproperties("DeadLetterConfig") - Description: Optional[PassThroughProp] = scheduleeventproperties("Description") - Enabled: Optional[bool] = scheduleeventproperties("Enabled") - Input: Optional[PassThroughProp] = scheduleeventproperties("Input") - Name: Optional[PassThroughProp] = scheduleeventproperties("Name") - RetryPolicy: Optional[PassThroughProp] = scheduleeventproperties("RetryPolicy") - Schedule: Optional[PassThroughProp] = scheduleeventproperties("Schedule") - State: Optional[PassThroughProp] = scheduleeventproperties("State") - Target: Optional[ScheduleTarget] = scheduleeventproperties("Target") - RoleArn: Optional[PassThroughProp] # TODO: add doc + DeadLetterConfig: DeadLetterConfig | None = scheduleeventproperties("DeadLetterConfig") + Description: PassThroughProp | None = scheduleeventproperties("Description") + Enabled: bool | None = scheduleeventproperties("Enabled") + Input: PassThroughProp | None = scheduleeventproperties("Input") + Name: PassThroughProp | None = scheduleeventproperties("Name") + RetryPolicy: PassThroughProp | None = scheduleeventproperties("RetryPolicy") + Schedule: PassThroughProp | None = scheduleeventproperties("Schedule") + State: PassThroughProp | None = scheduleeventproperties("State") + Target: ScheduleTarget | None = scheduleeventproperties("Target") + RoleArn: PassThroughProp | None # TODO: add doc class ScheduleEvent(BaseModel): @@ -56,22 +56,22 @@ class ScheduleEvent(BaseModel): class ScheduleV2EventProperties(BaseModel): - DeadLetterConfig: Optional[DeadLetterConfig] = scheduleeventv2properties("DeadLetterConfig") - Description: Optional[PassThroughProp] = scheduleeventv2properties("Description") - EndDate: Optional[PassThroughProp] = scheduleeventv2properties("EndDate") - FlexibleTimeWindow: Optional[PassThroughProp] = scheduleeventv2properties("FlexibleTimeWindow") - GroupName: Optional[PassThroughProp] = scheduleeventv2properties("GroupName") - Input: Optional[PassThroughProp] = scheduleeventv2properties("Input") - KmsKeyArn: Optional[PassThroughProp] = scheduleeventv2properties("KmsKeyArn") - Name: Optional[PassThroughProp] = scheduleeventv2properties("Name") - PermissionsBoundary: Optional[PassThroughProp] = scheduleeventv2properties("PermissionsBoundary") - RetryPolicy: Optional[PassThroughProp] = scheduleeventv2properties("RetryPolicy") - RoleArn: Optional[PassThroughProp] = scheduleeventv2properties("RoleArn") - ScheduleExpression: Optional[PassThroughProp] = scheduleeventv2properties("ScheduleExpression") - ScheduleExpressionTimezone: Optional[PassThroughProp] = scheduleeventv2properties("ScheduleExpressionTimezone") - StartDate: Optional[PassThroughProp] = scheduleeventv2properties("StartDate") - State: Optional[PassThroughProp] = scheduleeventv2properties("State") - OmitName: Optional[bool] # TODO: add doc + DeadLetterConfig: DeadLetterConfig | None = scheduleeventv2properties("DeadLetterConfig") + Description: PassThroughProp | None = scheduleeventv2properties("Description") + EndDate: PassThroughProp | None = scheduleeventv2properties("EndDate") + FlexibleTimeWindow: PassThroughProp | None = scheduleeventv2properties("FlexibleTimeWindow") + GroupName: PassThroughProp | None = scheduleeventv2properties("GroupName") + Input: PassThroughProp | None = scheduleeventv2properties("Input") + KmsKeyArn: PassThroughProp | None = scheduleeventv2properties("KmsKeyArn") + Name: PassThroughProp | None = scheduleeventv2properties("Name") + PermissionsBoundary: PassThroughProp | None = scheduleeventv2properties("PermissionsBoundary") + RetryPolicy: PassThroughProp | None = scheduleeventv2properties("RetryPolicy") + RoleArn: PassThroughProp | None = scheduleeventv2properties("RoleArn") + ScheduleExpression: PassThroughProp | None = scheduleeventv2properties("ScheduleExpression") + ScheduleExpressionTimezone: PassThroughProp | None = scheduleeventv2properties("ScheduleExpressionTimezone") + StartDate: PassThroughProp | None = scheduleeventv2properties("StartDate") + State: PassThroughProp | None = scheduleeventv2properties("State") + OmitName: bool | None # TODO: add doc class ScheduleV2Event(BaseModel): @@ -80,24 +80,24 @@ class ScheduleV2Event(BaseModel): class ResourcePolicy(BaseModel): - AwsAccountBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("AwsAccountBlacklist") - AwsAccountWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("AwsAccountWhitelist") - CustomStatements: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("CustomStatements") - IntrinsicVpcBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpcBlacklist") - IntrinsicVpcWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpcWhitelist") - IntrinsicVpceBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpceBlacklist") - IntrinsicVpceWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IntrinsicVpceWhitelist") - IpRangeBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IpRangeBlacklist") - IpRangeWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("IpRangeWhitelist") - SourceVpcBlacklist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("SourceVpcBlacklist") - SourceVpcWhitelist: Optional[List[Union[str, DictStrAny]]] = resourcepolicy("SourceVpcWhitelist") + AwsAccountBlacklist: list[str | DictStrAny] | None = resourcepolicy("AwsAccountBlacklist") + AwsAccountWhitelist: list[str | DictStrAny] | None = resourcepolicy("AwsAccountWhitelist") + CustomStatements: list[str | DictStrAny] | None = resourcepolicy("CustomStatements") + IntrinsicVpcBlacklist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpcBlacklist") + IntrinsicVpcWhitelist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpcWhitelist") + IntrinsicVpceBlacklist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpceBlacklist") + IntrinsicVpceWhitelist: list[str | DictStrAny] | None = resourcepolicy("IntrinsicVpceWhitelist") + IpRangeBlacklist: list[str | DictStrAny] | None = resourcepolicy("IpRangeBlacklist") + IpRangeWhitelist: list[str | DictStrAny] | None = resourcepolicy("IpRangeWhitelist") + SourceVpcBlacklist: list[str | DictStrAny] | None = resourcepolicy("SourceVpcBlacklist") + SourceVpcWhitelist: list[str | DictStrAny] | None = resourcepolicy("SourceVpcWhitelist") class CloudWatchEventProperties(BaseModel): - EventBusName: Optional[PassThroughProp] = cloudwatcheventproperties("EventBusName") - Input: Optional[PassThroughProp] = cloudwatcheventproperties("Input") - InputPath: Optional[PassThroughProp] = cloudwatcheventproperties("InputPath") - Pattern: Optional[PassThroughProp] = cloudwatcheventproperties("Pattern") + EventBusName: PassThroughProp | None = cloudwatcheventproperties("EventBusName") + Input: PassThroughProp | None = cloudwatcheventproperties("Input") + InputPath: PassThroughProp | None = cloudwatcheventproperties("InputPath") + Pattern: PassThroughProp | None = cloudwatcheventproperties("Pattern") class CloudWatchEvent(BaseModel): @@ -110,15 +110,15 @@ class EventBridgeRuleTarget(BaseModel): class EventBridgeRuleEventProperties(BaseModel): - DeadLetterConfig: Optional[DeadLetterConfig] = eventbridgeruleeventproperties("DeadLetterConfig") - EventBusName: Optional[PassThroughProp] = eventbridgeruleeventproperties("EventBusName") - Input: Optional[PassThroughProp] = eventbridgeruleeventproperties("Input") - InputPath: Optional[PassThroughProp] = eventbridgeruleeventproperties("InputPath") - Pattern: Optional[PassThroughProp] = eventbridgeruleeventproperties("Pattern") - RetryPolicy: Optional[PassThroughProp] = eventbridgeruleeventproperties("RetryPolicy") - Target: Optional[EventBridgeRuleTarget] = eventbridgeruleeventproperties("Target") - RuleName: Optional[PassThroughProp] = eventbridgeruleeventproperties("RuleName") - InputTransformer: Optional[PassThroughProp] # TODO: add docs + DeadLetterConfig: DeadLetterConfig | None = eventbridgeruleeventproperties("DeadLetterConfig") + EventBusName: PassThroughProp | None = eventbridgeruleeventproperties("EventBusName") + Input: PassThroughProp | None = eventbridgeruleeventproperties("Input") + InputPath: PassThroughProp | None = eventbridgeruleeventproperties("InputPath") + Pattern: PassThroughProp | None = eventbridgeruleeventproperties("Pattern") + RetryPolicy: PassThroughProp | None = eventbridgeruleeventproperties("RetryPolicy") + Target: EventBridgeRuleTarget | None = eventbridgeruleeventproperties("Target") + RuleName: PassThroughProp | None = eventbridgeruleeventproperties("RuleName") + InputTransformer: PassThroughProp | None # TODO: add docs class EventBridgeRuleEvent(BaseModel): @@ -127,18 +127,18 @@ class EventBridgeRuleEvent(BaseModel): class Auth(BaseModel): - ApiKeyRequired: Optional[bool] = apiauth("ApiKeyRequired") - AuthorizationScopes: Optional[List[str]] = apiauth("AuthorizationScopes") - Authorizer: Optional[str] = apiauth("Authorizer") - ResourcePolicy: Optional[ResourcePolicy] = apiauth("ResourcePolicy") + ApiKeyRequired: bool | None = apiauth("ApiKeyRequired") + AuthorizationScopes: list[str] | None = apiauth("AuthorizationScopes") + Authorizer: str | None = apiauth("Authorizer") + ResourcePolicy: ResourcePolicy | None = apiauth("ResourcePolicy") class ApiEventProperties(BaseModel): - Auth: Optional[Auth] = apieventproperties("Auth") + Auth: Auth | None = apieventproperties("Auth") Method: str = apieventproperties("Method") Path: str = apieventproperties("Path") - RestApiId: Optional[SamIntrinsicable[str]] = apieventproperties("RestApiId") - UnescapeMappingTemplate: Optional[bool] = apieventproperties("UnescapeMappingTemplate") + RestApiId: SamIntrinsicable[str] | None = apieventproperties("RestApiId") + UnescapeMappingTemplate: bool | None = apieventproperties("UnescapeMappingTemplate") class ApiEvent(BaseModel): @@ -147,41 +147,41 @@ class ApiEvent(BaseModel): class Properties(BaseModel): - Definition: Optional[DictStrAny] = properties("Definition") - DefinitionSubstitutions: Optional[DictStrAny] = properties("DefinitionSubstitutions") - DefinitionUri: Optional[Union[str, PassThroughProp]] = properties("DefinitionUri") - Events: Optional[ - Dict[ + Definition: DictStrAny | None = properties("Definition") + DefinitionSubstitutions: DictStrAny | None = properties("DefinitionSubstitutions") + DefinitionUri: str | PassThroughProp | None = properties("DefinitionUri") + Events: None | ( + dict[ str, - Union[ - ScheduleEvent, - ScheduleV2Event, - CloudWatchEvent, - EventBridgeRuleEvent, - ApiEvent, - ], + ( + ScheduleEvent | + ScheduleV2Event | + CloudWatchEvent | + EventBridgeRuleEvent | + ApiEvent + ), ] - ] = properties("Events") - Logging: Optional[PassThroughProp] = properties("Logging") - Name: Optional[PassThroughProp] = properties("Name") - PermissionsBoundary: Optional[PassThroughProp] = properties("PermissionsBoundary") - Policies: Optional[Union[str, DictStrAny, List[Union[str, DictStrAny]]]] = properties("Policies") - Role: Optional[PassThroughProp] = properties("Role") - RolePath: Optional[PassThroughProp] = properties("RolePath") - Tags: Optional[DictStrAny] = properties("Tags") - PropagateTags: Optional[bool] # TODO: add docs - Tracing: Optional[PassThroughProp] = properties("Tracing") - Type: Optional[PassThroughProp] = properties("Type") - AutoPublishAlias: Optional[PassThroughProp] - DeploymentPreference: Optional[PassThroughProp] - UseAliasAsEventTarget: Optional[bool] + ) = properties("Events") + Logging: PassThroughProp | None = properties("Logging") + Name: PassThroughProp | None = properties("Name") + PermissionsBoundary: PassThroughProp | None = properties("PermissionsBoundary") + Policies: str | DictStrAny | list[str | DictStrAny] | None = properties("Policies") + Role: PassThroughProp | None = properties("Role") + RolePath: PassThroughProp | None = properties("RolePath") + Tags: DictStrAny | None = properties("Tags") + PropagateTags: bool | None # TODO: add docs + Tracing: PassThroughProp | None = properties("Tracing") + Type: PassThroughProp | None = properties("Type") + AutoPublishAlias: PassThroughProp | None + DeploymentPreference: PassThroughProp | None + UseAliasAsEventTarget: bool | None class Resource(ResourceAttributes): Type: Literal["AWS::Serverless::StateMachine"] Properties: Properties - Connectors: Optional[Dict[str, EmbeddedConnector]] + Connectors: dict[str, EmbeddedConnector] | None class Globals(BaseModel): - PropagateTags: Optional[bool] # TODO: add docs + PropagateTags: bool | None # TODO: add docs diff --git a/samtranslator/internal/schema_source/schema.py b/samtranslator/internal/schema_source/schema.py index 02ff7f903..c59b6554d 100644 --- a/samtranslator/internal/schema_source/schema.py +++ b/samtranslator/internal/schema_source/schema.py @@ -23,12 +23,12 @@ class Globals(BaseModel): - Function: Optional[aws_serverless_function.Globals] - Api: Optional[aws_serverless_api.Globals] - HttpApi: Optional[aws_serverless_httpapi.Globals] - SimpleTable: Optional[aws_serverless_simpletable.Globals] - StateMachine: Optional[aws_serverless_statemachine.Globals] - LayerVersion: Optional[aws_serverless_layerversion.Globals] + Function: aws_serverless_function.Globals | None + Api: aws_serverless_api.Globals | None + HttpApi: aws_serverless_httpapi.Globals | None + SimpleTable: aws_serverless_simpletable.Globals | None + StateMachine: aws_serverless_statemachine.Globals | None + LayerVersion: aws_serverless_layerversion.Globals | None Resources = Union[ @@ -45,25 +45,25 @@ class Globals(BaseModel): class _ModelWithoutResources(LenientBaseModel): - Globals: Optional[Globals] + Globals: Globals | None class SamModel(_ModelWithoutResources): - Resources: Dict[ + Resources: dict[ str, - Union[ - Resources, + ( + Resources | # Ignore resources that are not AWS::Serverless::* - any_cfn_resource.Resource, - ], + any_cfn_resource.Resource + ), ] class Model(_ModelWithoutResources): - Resources: Dict[str, Resources] + Resources: dict[str, Resources] -def get_schema(model: Type[pydantic.BaseModel]) -> Dict[str, Any]: +def get_schema(model: type[pydantic.BaseModel]) -> dict[str, Any]: obj = model.schema() # http://json-schema.org/understanding-json-schema/reference/schema.html#schema @@ -83,7 +83,7 @@ def json_dumps(obj: Any) -> str: return json.dumps(obj, indent=2, sort_keys=True) + "\n" -def _replace_in_dict(d: Dict[str, Any], keyword: str, replace: Callable[[Dict[str, Any]], Any]) -> Dict[str, Any]: +def _replace_in_dict(d: dict[str, Any], keyword: str, replace: Callable[[dict[str, Any]], Any]) -> dict[str, Any]: """ Replace any dict containing keyword. @@ -97,7 +97,7 @@ def _replace_in_dict(d: Dict[str, Any], keyword: str, replace: Callable[[Dict[st return d -def _deep_get(d: Dict[str, Any], path: List[str]) -> Dict[str, Any]: +def _deep_get(d: dict[str, Any], path: list[str]) -> dict[str, Any]: """ Returns value at path defined by the keys in `path`. """ @@ -106,7 +106,7 @@ def _deep_get(d: Dict[str, Any], path: List[str]) -> Dict[str, Any]: return d -def _add_embedded_connectors(schema: Dict[str, Any]) -> None: +def _add_embedded_connectors(schema: dict[str, Any]) -> None: """ Add embedded Connectors resource attribute to supported CloudFormation resources. """ @@ -123,7 +123,7 @@ def _add_embedded_connectors(schema: Dict[str, Any]) -> None: schema["definitions"][resource]["properties"]["Connectors"] = embedded_connector -def extend_with_cfn_schema(sam_schema: Dict[str, Any], cfn_schema: Dict[str, Any]) -> None: +def extend_with_cfn_schema(sam_schema: dict[str, Any], cfn_schema: dict[str, Any]) -> None: """ Add CloudFormation resources and template syntax to SAM schema. """ @@ -152,7 +152,7 @@ def extend_with_cfn_schema(sam_schema: Dict[str, Any], cfn_schema: Dict[str, Any _add_embedded_connectors(sam_schema) # Inject CloudFormation documentation to SAM pass-through properties - def replace_passthrough(d: Dict[str, Any]) -> Dict[str, Any]: + def replace_passthrough(d: dict[str, Any]) -> dict[str, Any]: passthrough = d["__samPassThrough"] schema = deepcopy(_deep_get(cfn_schema, passthrough["schemaPath"])) schema["markdownDescription"] = passthrough["markdownDescriptionOverride"] diff --git a/setup.py b/setup.py index 69a68d14d..78166c1f0 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # setup.py # @@ -32,7 +31,7 @@ def read(*filenames, **kwargs): sep = kwargs.get("sep", os.linesep) buf = [] for filename in filenames: - with io.open(filename, encoding=encoding) as f: + with open(filename, encoding=encoding) as f: buf.append(f.read()) return sep.join(buf) diff --git a/tests/policy_template_processor/test_processor.py b/tests/policy_template_processor/test_processor.py index 74c25e931..64870c3d6 100644 --- a/tests/policy_template_processor/test_processor.py +++ b/tests/policy_template_processor/test_processor.py @@ -50,7 +50,7 @@ def test_init_must_convert_template_value_dict_to_object( processor = PolicyTemplatesProcessor(policy_templates_dict) self.assertEqual(2, len(processor.policy_templates)) - self.assertEqual(set(["key1", "key2"]), set(processor.policy_templates.keys())) + self.assertEqual({"key1", "key2"}, set(processor.policy_templates.keys())) # Template.from_dict must be called only once for each template entry self.assertEqual(2, template_from_dict_mock.call_count) diff --git a/tests/utils/test_py27hash_fix.py b/tests/utils/test_py27hash_fix.py index 34a723988..6e76e00fc 100644 --- a/tests/utils/test_py27hash_fix.py +++ b/tests/utils/test_py27hash_fix.py @@ -497,7 +497,7 @@ def test_with_list(self): self.assertIsInstance(item, Py27Dict) def test_with_other_type(self): - original = [("a", "b"), set(["a", "b"]), 123, 123.123] + original = [("a", "b"), {"a", "b"}, 123, 123.123] converted = _convert_to_py27_type(original) self.assertIsInstance(converted[0], tuple) self.assertIsInstance(converted[1], set)