Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ireally drop python<=3.7 support #3678

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion integration/helpers/request_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
1 change: 0 additions & 1 deletion integration/single/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

250 changes: 125 additions & 125 deletions samtranslator/internal/schema_source/aws_serverless_api.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
548 changes: 274 additions & 274 deletions samtranslator/internal/schema_source/aws_serverless_function.py

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions samtranslator/internal/schema_source/aws_serverless_httpapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,38 @@ 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"],
)


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):
Expand All @@ -69,4 +69,4 @@ class Resource(ResourceAttributes):


class Globals(BaseModel):
PublishLambdaVersion: Optional[bool] # TODO: add docs
PublishLambdaVersion: bool | None # TODO: add docs
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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
Loading