From 85d2ace0d6be9b0113bf498ff8ffc1fd9e6e3a09 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Wed, 22 Feb 2023 10:21:06 -0800 Subject: [PATCH] Upgrade Kotlin and Ktlint (#2392) * Upgrade Kotlin to 1.7.21 * Upgrade Ktlint to 0.48.2 * Run `pre-commit run --all-files` to fix broken Ktlints * Fix string comparison broken by code formatting --- .editorconfig | 8 ++- .pre-commit-config.yaml | 4 +- aws/SDK_CHANGELOG.next.json | 2 +- .../amazon/smithy/rustsdk/RegionDecorator.kt | 4 +- .../customize/glacier/AccountIdAutofill.kt | 4 +- .../customize/route53/Route53Decorator.kt | 4 +- .../rustsdk/endpoints/AwsEndpointDecorator.kt | 3 +- aws/sdk/build.gradle.kts | 4 +- build.gradle.kts | 8 +-- buildSrc/src/main/kotlin/CodegenTestCommon.kt | 10 +++- .../main/kotlin/aws/sdk/DocsLandingPage.kt | 4 +- .../src/main/kotlin/aws/sdk/ModelMetadata.kt | 2 +- .../src/main/kotlin/aws/sdk/ServiceLoader.kt | 10 ++-- .../customizations/ApiKeyAuthDecorator.kt | 2 +- .../customizations/ClientDocsGenerator.kt | 4 +- .../endpoint/EndpointConfigCustomization.kt | 4 +- .../client/smithy/endpoint/rulesgen/StdLib.kt | 5 +- .../client/FluentClientGenerator.kt | 30 +++++----- .../IdempotencyTokenProviderCustomization.kt | 4 +- .../smithy/generators/error/ErrorGenerator.kt | 3 + .../generators/error/ServiceErrorGenerator.kt | 4 +- .../protocol/ProtocolTestGenerator.kt | 6 +- .../protocols/HttpBoundProtocolGenerator.kt | 4 +- .../HttpVersionListGeneratorTest.kt | 4 +- .../config/ServiceConfigGeneratorTest.kt | 4 +- .../rust/codegen/core/rustlang/RustType.kt | 6 +- .../rust/codegen/core/rustlang/RustWriter.kt | 18 ++++-- .../codegen/core/smithy/CodegenDelegator.kt | 4 +- .../smithy/StreamingTraitSymbolProvider.kt | 8 ++- .../rust/codegen/core/smithy/SymbolVisitor.kt | 16 +++-- .../smithy/generators/BuilderGenerator.kt | 4 +- .../core/smithy/generators/LibRsGenerator.kt | 4 +- .../smithy/generators/StructureGenerator.kt | 4 +- .../generators/http/HttpBindingGenerator.kt | 16 ++--- .../protocols/parse/JsonParserGenerator.kt | 4 +- .../parse/XmlBindingTraitParserGenerator.kt | 6 +- .../XmlBindingTraitSerializerGenerator.kt | 2 +- .../transformers/OperationNormalizer.kt | 4 +- .../core/testutil/EventStreamTestTools.kt | 2 +- .../smithy/rust/codegen/core/testutil/Rust.kt | 12 ++-- .../smithy/rust/codegen/core/util/LetIf.kt | 4 +- .../smithy/rust/codegen/core/util/Smithy.kt | 4 +- .../codegen/core/rustlang/RustTypeTest.kt | 21 ++++++- .../smithy/PythonServerSymbolProvider.kt | 8 ++- .../server/python/smithy/PythonType.kt | 4 +- .../smithy/RustServerCodegenPythonPlugin.kt | 4 +- .../PythonServerCodegenDecorator.kt | 8 +-- .../generators/PythonApplicationGenerator.kt | 14 +++-- .../generators/PythonServerTypesTest.kt | 58 +++++++++---------- .../DeriveEqAndHashSymbolMetadataProvider.kt | 2 +- .../LengthTraitValidationErrorMessage.kt | 8 ++- .../RangeTraitValidationErrorMessage.kt | 8 ++- .../server/smithy/RustServerCodegenPlugin.kt | 4 +- .../smithy/ValidateUnsupportedConstraints.kt | 20 +++++-- ...mValidationExceptionWithReasonDecorator.kt | 4 +- .../SmithyValidationExceptionDecorator.kt | 8 ++- .../ConstrainedCollectionGenerator.kt | 30 +++++----- .../PubCrateConstrainedCollectionGenerator.kt | 20 +++---- .../ServerBuilderConstraintViolations.kt | 12 +++- .../generators/ServerBuilderGenerator.kt | 16 ++--- .../ServerHttpSensitivityGenerator.kt | 54 +++++++++++------ .../generators/ServerServiceGenerator.kt | 4 +- .../http/ServerRequestBindingGenerator.kt | 4 +- .../protocol/ServerProtocolTestGenerator.kt | 38 ++++++------ .../ServerHttpBoundProtocolGenerator.kt | 22 ++++--- .../smithy/ConstraintsMemberShapeTest.kt | 6 +- ...CrateConstrainedShapeSymbolProviderTest.kt | 8 ++- .../RecursiveConstraintViolationsTest.kt | 6 +- ...ateUnsupportedConstraintsAreNotUsedTest.kt | 14 +++-- ...ionNotAttachedErrorMessageDecoratorTest.kt | 14 ++--- gradle.properties | 4 +- .../examples/Makefile | 2 +- .../examples/stubgen_test.py | 2 +- .../src/types.rs | 8 +-- 74 files changed, 431 insertions(+), 263 deletions(-) diff --git a/.editorconfig b/.editorconfig index db30a6257e..55bfe517da 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,5 +9,11 @@ indent_size = 4 indent_style = space insert_final_newline = true max_line_length = 120 + # Ktlint-specific config -disabled_rules = filename, max-line-length, argument-list-wrapping, parameter-list-wrapping +ktlint_standard = enabled +ktlint_experimental = disabled +ktlint_standard_filename = disabled +ktlint_standard_max-line-length = disabled +ktlint_standard_argument-list-wrapping = disabled +ktlint_standard_parameter-list-wrapping = disabled diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c6da8695fc..cce6e26327 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,10 +20,10 @@ repos: files: ^.*$ pass_filenames: false - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.5.0 + rev: v2.6.0 hooks: - id: pretty-format-kotlin - args: [--autofix, --ktlint-version, 0.46.1] + args: [--autofix, --ktlint-version, 0.48.2] - id: pretty-format-yaml args: [--autofix, --indent, '2'] - id: pretty-format-rust diff --git a/aws/SDK_CHANGELOG.next.json b/aws/SDK_CHANGELOG.next.json index 5a4025621f..5673dbc79f 100644 --- a/aws/SDK_CHANGELOG.next.json +++ b/aws/SDK_CHANGELOG.next.json @@ -498,4 +498,4 @@ } ], "aws-sdk-model": [] -} \ No newline at end of file +} diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index ab37a9d598..af625e7979 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -130,7 +130,9 @@ class RegionDecorator : ClientCodegenDecorator { object : EndpointCustomization { override fun loadBuiltInFromServiceConfig(parameter: Parameter, configRef: String): Writable? { return when (parameter.builtIn) { - Builtins.REGION.builtIn -> writable { rust("$configRef.region.as_ref().map(|r|r.as_ref().to_owned())") } + Builtins.REGION.builtIn -> writable { + rust("$configRef.region.as_ref().map(|r|r.as_ref().to_owned())") + } else -> null } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt index 65e4f3a455..63ef01d1b1 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/glacier/AccountIdAutofill.kt @@ -37,7 +37,9 @@ class AccountIdAutofill : OperationCustomization() { val input = operation.inputShape(model) return if (input.memberNames.contains("accountId")) { AccountIdAutofill() - } else null + } else { + null + } } } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt index c8b8cb9813..007254c479 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/customize/route53/Route53Decorator.kt @@ -49,7 +49,9 @@ class Route53Decorator : ClientCodegenDecorator { operation.inputShape(codegenContext.model).members().find { it.hasTrait() } return if (hostedZoneMember != null) { baseCustomizations + TrimResourceIdCustomization(codegenContext.symbolProvider.toMemberName(hostedZoneMember)) - } else baseCustomizations + } else { + baseCustomizations + } } private fun isResourceId(shape: Shape): Boolean { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt index 7c1de7e013..7885db72d6 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt @@ -250,8 +250,7 @@ class AwsEndpointDecorator : ClientCodegenDecorator { } ServiceConfig.ConfigStruct -> rust("endpoint_url: Option,") - ServiceConfig.ConfigStructAdditionalDocs -> emptySection - ServiceConfig.Extras -> emptySection + else -> {} } } } diff --git a/aws/sdk/build.gradle.kts b/aws/sdk/build.gradle.kts index 9d049f6116..3147877704 100644 --- a/aws/sdk/build.gradle.kts +++ b/aws/sdk/build.gradle.kts @@ -52,7 +52,9 @@ dependencies { // Class and functions for service and protocol membership for SDK generation -val awsServices: AwsServices by lazy { discoverServices(properties.get("aws.sdk.models.path"), loadServiceMembership()) } +val awsServices: AwsServices by lazy { + discoverServices(properties.get("aws.sdk.models.path"), loadServiceMembership()) +} val eventStreamAllowList: Set by lazy { eventStreamAllowList() } val crateVersioner by lazy { aws.sdk.CrateVersioner.defaultFor(rootProject, properties) } diff --git a/build.gradle.kts b/build.gradle.kts index 2c06af6725..a2d6385db4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,9 +14,7 @@ buildscript { } } -plugins { - kotlin("jvm") version "1.3.72" apply false -} +plugins { } allprojects { repositories { @@ -61,7 +59,7 @@ tasks.register("ktlint") { group = "Verification" classpath = configurations.getByName("ktlint") mainClass.set("com.pinterest.ktlint.Main") - args = listOf("--verbose", "--relative", "--") + lintPaths + args = listOf("--log-level=info", "--relative", "--") + lintPaths // https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802 jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED") } @@ -71,7 +69,7 @@ tasks.register("ktlintFormat") { group = "formatting" classpath = configurations.getByName("ktlint") mainClass.set("com.pinterest.ktlint.Main") - args = listOf("--verbose", "--relative", "--format", "--") + lintPaths + args = listOf("--log-level=info", "--relative", "--format", "--") + lintPaths // https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802 jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED") } diff --git a/buildSrc/src/main/kotlin/CodegenTestCommon.kt b/buildSrc/src/main/kotlin/CodegenTestCommon.kt index d975d1a521..033d418c84 100644 --- a/buildSrc/src/main/kotlin/CodegenTestCommon.kt +++ b/buildSrc/src/main/kotlin/CodegenTestCommon.kt @@ -62,7 +62,7 @@ enum class Cargo(val toString: String) { CHECK("cargoCheck"), TEST("cargoTest"), DOCS("cargoDoc"), - CLIPPY("cargoClippy"); + CLIPPY("cargoClippy"), } private fun generateCargoWorkspace(pluginName: String, tests: List) = @@ -86,7 +86,9 @@ private fun codegenTests(properties: PropertyRetriever, allTests: List { AllCargoCommands } require(ret.isNotEmpty()) { - "None of the provided cargo commands (`$cargoCommandsOverride`) are valid cargo commands (`${AllCargoCommands.map { it.toString }}`)" + "None of the provided cargo commands (`$cargoCommandsOverride`) are valid cargo commands (`${AllCargoCommands.map { + it.toString + }}`)" } return ret } diff --git a/buildSrc/src/main/kotlin/aws/sdk/DocsLandingPage.kt b/buildSrc/src/main/kotlin/aws/sdk/DocsLandingPage.kt index d522a02f4a..715917c4db 100644 --- a/buildSrc/src/main/kotlin/aws/sdk/DocsLandingPage.kt +++ b/buildSrc/src/main/kotlin/aws/sdk/DocsLandingPage.kt @@ -44,7 +44,9 @@ fun Project.docsLandingPage(awsServices: AwsServices, outputPath: File) { /** * Generate a link to the examples for a given service */ -private fun examplesLink(service: AwsService, project: Project) = service.examplesUri(project)?.let { "([examples]($it))" } +private fun examplesLink(service: AwsService, project: Project) = service.examplesUri(project)?.let { + "([examples]($it))" +} /** * Generate a link to the docs diff --git a/buildSrc/src/main/kotlin/aws/sdk/ModelMetadata.kt b/buildSrc/src/main/kotlin/aws/sdk/ModelMetadata.kt index a70aa7a0d6..95d65fd106 100644 --- a/buildSrc/src/main/kotlin/aws/sdk/ModelMetadata.kt +++ b/buildSrc/src/main/kotlin/aws/sdk/ModelMetadata.kt @@ -11,7 +11,7 @@ import java.io.File enum class ChangeType { UNCHANGED, FEATURE, - DOCUMENTATION + DOCUMENTATION, } /** Model metadata toml file */ diff --git a/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt b/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt index fdc6448b0c..44510d1b11 100644 --- a/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt +++ b/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt @@ -135,9 +135,9 @@ fun Project.discoverServices(awsModelsPath: String?, serviceMembership: Membersh serviceMembership.exclusions.forEach { disabledService -> check(baseModules.contains(disabledService)) { "Service $disabledService was explicitly disabled but no service was generated with that name. Generated:\n ${ - baseModules.joinToString( - "\n ", - ) + baseModules.joinToString( + "\n ", + ) }" } } @@ -206,7 +206,9 @@ fun parseMembership(rawList: String): Membership { } val conflictingMembers = inclusions.intersect(exclusions) - require(conflictingMembers.isEmpty()) { "$conflictingMembers specified both for inclusion and exclusion in $rawList" } + require(conflictingMembers.isEmpty()) { + "$conflictingMembers specified both for inclusion and exclusion in $rawList" + } return Membership(inclusions, exclusions) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt index c46ecfe35d..0d9f5bde46 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt @@ -100,7 +100,7 @@ private class ApiKeyOperationCustomization(private val runtimeConfig: RuntimeCon """ ${section.request}.properties_mut().insert(api_key_config.clone()); let api_key = api_key_config.api_key(); - """, + """, ) val definitionName = authDefinition.getName() if (authDefinition.getIn() == HttpApiKeyAuthTrait.Location.QUERY) { diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt index 8b8d419ad0..835f243df3 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ClientDocsGenerator.kt @@ -16,7 +16,9 @@ class ClientDocsGenerator : LibRsCustomization() { return when (section) { is LibRsSection.ModuleDocumentation -> if (section.subsection == LibRsSection.CrateOrganization) { crateLayout() - } else emptySection + } else { + emptySection + } else -> emptySection } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt index 4d44c5602c..1b31dec174 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/EndpointConfigCustomization.kt @@ -90,7 +90,9 @@ internal class EndpointConfigCustomization( /// let config = $moduleUseName::Config::builder().endpoint_resolver(prefix_resolver); /// ``` """ - } else "" + } else { + "" + } rustTemplate( """ /// Sets the endpoint resolver to use when making requests. diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/StdLib.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/StdLib.kt index d2d43f2858..2c16a51bb7 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/StdLib.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/rulesgen/StdLib.kt @@ -74,10 +74,9 @@ class AwsPartitionResolver(runtimeConfig: RuntimeConfig, private val partitionsD ) override fun structFieldInit() = writable { + val json = Node.printJson(partitionsDotJson).dq() rustTemplate( - """partition_resolver: #{PartitionResolver}::new_from_json(b${ - Node.printJson(partitionsDotJson).dq() - }).expect("valid JSON")""", + """partition_resolver: #{PartitionResolver}::new_from_json(b$json).expect("valid JSON")""", *codegenScope, ) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index 3b8c473849..9b61ffe5ca 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -136,15 +136,15 @@ class FluentClientGenerator( "smithy_inst" to generics.smithyInst, "client" to RuntimeType.smithyClient(runtimeConfig), "client_docs" to writable - { - customizations.forEach { - it.section( - FluentClientSection.FluentClientDocs( - serviceShape, - ), - )(this) - } - }, + { + customizations.forEach { + it.section( + FluentClientSection.FluentClientDocs( + serviceShape, + ), + )(this) + } + }, ) writer.rustBlockTemplate( "impl${generics.inst} Client${generics.inst} #{bounds:W}", @@ -156,7 +156,9 @@ class FluentClientGenerator( val fullPath = operation.fullyQualifiedFluentBuilder(symbolProvider) val maybePaginated = if (operation.isPaginated(model)) { "\n/// This operation supports pagination; See [`into_paginator()`]($fullPath::into_paginator)." - } else "" + } else { + "" + } val output = operation.outputShape(model) val operationOk = symbolProvider.toSymbol(output) @@ -201,10 +203,10 @@ class FluentClientGenerator( writer.rust( """ pub fn ${ - clientOperationFnName( - operation, - symbolProvider, - ) + clientOperationFnName( + operation, + symbolProvider, + ) }(&self) -> fluent_builders::$name${generics.inst} { fluent_builders::$name::new(self.handle.clone()) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt index 7cda821957..75b075dc4d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/IdempotencyTokenProviderCustomization.kt @@ -63,7 +63,9 @@ class IdempotencyTokenProviderCustomization : NamedCustomization( rust("make_token: self.make_token.unwrap_or_else(#T::default_provider),", RuntimeType.IdempotencyToken) } - is ServiceConfig.DefaultForTests -> writable { rust("""${section.configBuilderRef}.set_make_token(Some("00000000-0000-4000-8000-000000000000".into()));""") } + is ServiceConfig.DefaultForTests -> writable { + rust("""${section.configBuilderRef}.set_make_token(Some("00000000-0000-4000-8000-000000000000".into()));""") + } else -> writable { } } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt index feddf95a2f..65c1f3ce05 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ErrorGenerator.kt @@ -52,6 +52,7 @@ class ErrorGenerator( is StructureSection.AdditionalDebugFields -> { rust("""${section.formatterName}.field("meta", &self.meta);""") } + else -> {} } } }, @@ -90,6 +91,8 @@ class ErrorGenerator( is BuilderSection.AdditionalFieldsInBuild -> { rust("meta: self.meta.unwrap_or_default(),") } + + else -> {} } } }, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServiceErrorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServiceErrorGenerator.kt index ca71dd9033..f461d59e05 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServiceErrorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/error/ServiceErrorGenerator.kt @@ -53,7 +53,9 @@ class ServiceErrorGenerator( private val symbolProvider = codegenContext.symbolProvider private val model = codegenContext.model - private val allErrors = operations.flatMap { it.allErrors(model) }.map { it.id }.distinctBy { it.getName(codegenContext.serviceShape) } + private val allErrors = operations.flatMap { + it.allErrors(model) + }.map { it.id }.distinctBy { it.getName(codegenContext.serviceShape) } .map { codegenContext.model.expectShape(it, StructureShape::class.java) } .sortedBy { it.id.getName(codegenContext.serviceShape) } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index 5aa6f2ee56..beffafe7ef 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -246,10 +246,10 @@ class ProtocolTestGenerator( expectedShape: StructureShape, ) { if (!protocolSupport.responseDeserialization || ( - !protocolSupport.errorDeserialization && expectedShape.hasTrait( + !protocolSupport.errorDeserialization && expectedShape.hasTrait( ErrorTrait::class.java, ) - ) + ) ) { rust("/* test case disabled for this protocol (not yet supported) */") return @@ -356,7 +356,7 @@ class ProtocolTestGenerator( assertOk(rustWriter) { rustWriter.write( "#T(&body, ${ - rustWriter.escape(body).dq() + rustWriter.escape(body).dq() }, #T::from(${(mediaType ?: "unknown").dq()}))", RuntimeType.protocolTest(codegenContext.runtimeConfig, "validate_body"), RuntimeType.protocolTest(codegenContext.runtimeConfig, "MediaType"), diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt index 2bddfb00e4..d69c864d65 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt @@ -350,7 +350,9 @@ class HttpBoundProtocolTraitImplGenerator( val err = if (BuilderGenerator.hasFallibleBuilder(outputShape, symbolProvider)) { ".map_err(${format(errorSymbol)}::unhandled)?" - } else "" + } else { + "" + } writeCustomizations(customizations, OperationSection.MutateOutput(customizations, operationShape)) diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt index 0b860545aa..32236c8f79 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt @@ -205,7 +205,9 @@ class FakeSigningDecorator : ClientCodegenDecorator { codegenContext: ClientCodegenContext, baseCustomizations: List, ): List { - return baseCustomizations.filterNot { it is EventStreamSigningConfig } + FakeSigningConfig(codegenContext.runtimeConfig) + return baseCustomizations.filterNot { + it is EventStreamSigningConfig + } + FakeSigningConfig(codegenContext.runtimeConfig) } } diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt index 7273428183..2aaa3e21dd 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGeneratorTest.kt @@ -94,7 +94,9 @@ internal class ServiceConfigGeneratorTest { } ServiceConfig.BuilderStruct -> writable { rust("config_field: Option") } ServiceConfig.BuilderImpl -> emptySection - ServiceConfig.BuilderBuild -> writable { rust("config_field: self.config_field.unwrap_or_default(),") } + ServiceConfig.BuilderBuild -> writable { + rust("config_field: self.config_field.unwrap_or_default(),") + } else -> emptySection } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt index 59953d5418..0ada867b42 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt @@ -222,7 +222,9 @@ fun RustType.asArgument(name: String) = Argument( fun RustType.render(fullyQualified: Boolean = true): String { val namespace = if (fullyQualified) { this.namespace?.let { "$it::" } ?: "" - } else "" + } else { + "" + } val base = when (this) { is RustType.Unit -> this.name is RustType.Bool -> this.name @@ -426,7 +428,7 @@ enum class AttributeKind { /** * Outer attributes, written without the bang after the hash, apply to the thing that follows the attribute. */ - Outer + Outer, } /** diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt index 553e30205e..e9bc8798cb 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt @@ -168,7 +168,7 @@ private fun transformTemplate(template: String, scope: Array.mergeIdenticalTestDependencies(): List()) { symbol.makeRustBoxed() - } else symbol + } else { + symbol + } fun symbolBuilder(shape: Shape?, rustType: RustType): Symbol.Builder = Symbol.builder().shape(shape).rustType(rustType) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt index 000e2845e4..18700df815 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/BuilderGenerator.kt @@ -142,7 +142,9 @@ class BuilderGenerator( private val metadata = structureSymbol.expectRustMetadata() // Filter out any derive that isn't Debug, PartialEq, or Clone. Then add a Default derive - private val builderDerives = metadata.derives.filter { it == RuntimeType.Debug || it == RuntimeType.PartialEq || it == RuntimeType.Clone } + RuntimeType.Default + private val builderDerives = metadata.derives.filter { + it == RuntimeType.Debug || it == RuntimeType.PartialEq || it == RuntimeType.Clone + } + RuntimeType.Default private val builderName = "Builder" fun render(writer: RustWriter) { diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt index 359386e34d..c50ee55707 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/LibRsGenerator.kt @@ -44,7 +44,9 @@ class LibRsGenerator( val libraryDocs = settings.getService(model).getTrait()?.value ?: settings.moduleName containerDocs(escape(libraryDocs)) - val crateLayout = customizations.map { it.section(LibRsSection.ModuleDocumentation(LibRsSection.CrateOrganization)) }.filter { !it.isEmpty() } + val crateLayout = customizations.map { + it.section(LibRsSection.ModuleDocumentation(LibRsSection.CrateOrganization)) + }.filter { !it.isEmpty() } if (crateLayout.isNotEmpty()) { containerDocs("\n## Crate Organization") crateLayout.forEach { it(this) } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt index 46f0c31544..e91bf3b871 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/StructureGenerator.kt @@ -88,7 +88,9 @@ open class StructureGenerator( }.toSet().sorted() return if (lifetimes.isNotEmpty()) { "<${lifetimes.joinToString { "'$it" }}>" - } else "" + } else { + "" + } } /** diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index c3a156fcca..6a66296c8f 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -460,7 +460,7 @@ class HttpBindingGenerator( // Rename here technically not required, operations and members cannot be renamed. private fun fnName(operationShape: OperationShape, binding: HttpBindingDescriptor) = "${ - operationShape.id.getName(service).toSnakeCase() + operationShape.id.getName(service).toSnakeCase() }_${binding.member.container.name.toSnakeCase()}_${binding.memberName.toSnakeCase()}" /** @@ -691,13 +691,13 @@ class HttpBindingGenerator( #{invalid_header_name:W} })?; let header_value = ${ - headerFmtFun( - this, - valueTargetShape, - timestampFormat, - "v", - isMultiValuedHeader = false, - ) + headerFmtFun( + this, + valueTargetShape, + timestampFormat, + "v", + isMultiValuedHeader = false, + ) }; let header_value: #{HeaderValue} = header_value.parse().map_err(|err| { #{invalid_header_value:W} diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index 1e8f8151f7..f13c1d4821 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -153,7 +153,9 @@ class JsonParserGenerator( override fun payloadParser(member: MemberShape): RuntimeType { val shape = model.expectShape(member.target) - check(shape is UnionShape || shape is StructureShape || shape is DocumentShape) { "payload parser should only be used on structures & unions" } + check(shape is UnionShape || shape is StructureShape || shape is DocumentShape) { + "payload parser should only be used on structures & unions" + } val fnName = symbolProvider.deserializeFunctionName(shape) + "_payload" return RuntimeType.forInlineFun(fnName, jsonDeserModule) { rustBlockTemplate( diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt index 74b71bb7a9..2615123874 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt @@ -131,7 +131,9 @@ class XmlBindingTraitParserGenerator( */ override fun payloadParser(member: MemberShape): RuntimeType { val shape = model.expectShape(member.target) - check(shape is UnionShape || shape is StructureShape) { "payload parser should only be used on structures & unions" } + check(shape is UnionShape || shape is StructureShape) { + "payload parser should only be used on structures & unions" + } val fnName = symbolProvider.deserializeFunctionName(member) return RuntimeType.forInlineFun(fnName, xmlDeserModule) { rustBlock( @@ -456,7 +458,7 @@ class XmlBindingTraitParserGenerator( private fun RustWriter.case(member: MemberShape, inner: Writable) { rustBlock( "s if ${ - member.xmlName().matchExpression("s") + member.xmlName().matchExpression("s") } /* ${member.memberName} ${escape(member.id.toString())} */ => ", ) { inner() diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt index 3d69218e25..81430c51fb 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt @@ -157,7 +157,7 @@ class XmlBindingTraitSerializerGenerator( let mut writer = #{XmlWriter}::new(&mut out); ##[allow(unused_mut)] let mut root = writer.start_el(${xmlIndex.payloadShapeName(member).dq()})${ - target.xmlNamespace(root = true).apply() + target.xmlNamespace(root = true).apply() }; """, *codegenScope, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt index 1a00d431ae..78a6852fd6 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/transformers/OperationNormalizer.kt @@ -59,7 +59,9 @@ object OperationNormalizer { val shapeConflict = newShapes.firstOrNull { shape -> model.getShape(shape.id).isPresent } check( shapeConflict == null, - ) { "shape $shapeConflict conflicted with an existing shape in the model (${model.getShape(shapeConflict!!.id)}. This is a bug." } + ) { + "shape $shapeConflict conflicted with an existing shape in the model (${model.getShape(shapeConflict!!.id)}. This is a bug." + } val modelWithOperationInputs = model.toBuilder().addShapes(newShapes).build() return transformer.mapShapes(modelWithOperationInputs) { // Update all operations to point to their new input/output shapes diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/EventStreamTestTools.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/EventStreamTestTools.kt index 4cfebd3242..c038ff5d52 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/EventStreamTestTools.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/EventStreamTestTools.kt @@ -42,7 +42,7 @@ data class TestEventStreamProject( enum class EventStreamTestVariety { Marshall, - Unmarshall + Unmarshall, } interface EventStreamTestRequirements { diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt index 5fa053e4b0..40d89b0985 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt @@ -229,11 +229,13 @@ fun RustWriter.assertNoNewDependencies(block: Writable, dependencyFilter: (Cargo val writtenOut = this.toString() val badLines = writtenOut.lines().filter { line -> badDeps.any { line.contains(it) } } throw CodegenException( - "found invalid dependencies. ${invalidDeps.map { it.first }}\nHint: the following lines may be the problem.\n${ - badLines.joinToString( - separator = "\n", - prefix = " ", - ) + "found invalid dependencies. ${invalidDeps.map { + it.first + }}\nHint: the following lines may be the problem.\n${ + badLines.joinToString( + separator = "\n", + prefix = " ", + ) }", ) } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/LetIf.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/LetIf.kt index 2ac4da683d..89868f7a00 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/LetIf.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/LetIf.kt @@ -10,7 +10,9 @@ package software.amazon.smithy.rust.codegen.core.util fun T.letIf(cond: Boolean, f: (T) -> T): T { return if (cond) { f(this) - } else this + } else { + this + } } fun List.extendIf(condition: Boolean, f: () -> T) = if (condition) { diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt index 06c344337f..2e5e7fd5b6 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Smithy.kt @@ -42,7 +42,9 @@ fun StructureShape.expectMember(member: String): MemberShape = fun UnionShape.expectMember(member: String): MemberShape = this.getMember(member).orElseThrow { CodegenException("$member did not exist on $this") } -fun StructureShape.errorMessageMember(): MemberShape? = this.getMember("message").or { this.getMember("Message") }.orNull() +fun StructureShape.errorMessageMember(): MemberShape? = this.getMember("message").or { + this.getMember("Message") +}.orNull() fun StructureShape.hasStreamingMember(model: Model) = this.findStreamingMember(model) != null fun UnionShape.hasStreamingMember(model: Model) = this.findMemberWithTrait(model) != null diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypeTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypeTest.kt index 41e0c10066..7fa364dfaf 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypeTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustTypeTest.kt @@ -163,7 +163,12 @@ internal class RustTypesTest { ), ), ) - forInputExpectOutput(writable { attributeMacro.render(this) }, "#[cfg(all(feature = \"unstable\", any(feature = \"serialize\", feature = \"deserialize\")))]\n") + forInputExpectOutput( + writable { + attributeMacro.render(this) + }, + "#[cfg(all(feature = \"unstable\", any(feature = \"serialize\", feature = \"deserialize\")))]\n", + ) } @Test @@ -178,7 +183,12 @@ internal class RustTypesTest { ), ), ) - forInputExpectOutput(writable { attributeMacro.render(this) }, "#[cfg(all(feature = \"unstable\", feature = \"serialize\", feature = \"deserialize\"))]\n") + forInputExpectOutput( + writable { + attributeMacro.render(this) + }, + "#[cfg(all(feature = \"unstable\", feature = \"serialize\", feature = \"deserialize\"))]\n", + ) } @Test @@ -197,7 +207,12 @@ internal class RustTypesTest { RuntimeType.StdError, ), ) - forInputExpectOutput(writable { attributeMacro.render(this) }, "#[derive(std::clone::Clone, std::error::Error, std::fmt::Debug)]\n") + forInputExpectOutput( + writable { + attributeMacro.render(this) + }, + "#[derive(std::clone::Clone, std::error::Error, std::fmt::Debug)]\n", + ) } @Test diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt index 5e8f858371..b7009623eb 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerSymbolProvider.kt @@ -100,14 +100,18 @@ class PythonStreamingShapeMetadataProvider(private val base: RustSymbolProvider) val baseMetadata = base.toSymbol(structureShape).expectRustMetadata() return if (structureShape.hasStreamingMember(model)) { baseMetadata.withoutDerives(RuntimeType.PartialEq) - } else baseMetadata + } else { + baseMetadata + } } override fun unionMeta(unionShape: UnionShape): RustMetadata { val baseMetadata = base.toSymbol(unionShape).expectRustMetadata() return if (unionShape.hasStreamingMember(model)) { baseMetadata.withoutDerives(RuntimeType.PartialEq) - } else baseMetadata + } else { + baseMetadata + } } override fun memberMeta(memberShape: MemberShape) = base.toSymbol(memberShape).expectRustMetadata() diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonType.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonType.kt index 2dd2f6ba65..c5606b5d38 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonType.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonType.kt @@ -138,7 +138,9 @@ fun RustType.pythonType(): PythonType = fun PythonType.render(fullyQualified: Boolean = true): String { val namespace = if (fullyQualified) { this.namespace?.let { "$it." } ?: "" - } else "" + } else { + "" + } val base = when (this) { is PythonType.None -> this.name is PythonType.Bool -> this.name diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustServerCodegenPythonPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustServerCodegenPythonPlugin.kt index 9631367024..908e8416e4 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustServerCodegenPythonPlugin.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustServerCodegenPythonPlugin.kt @@ -79,7 +79,9 @@ class RustServerCodegenPythonPlugin : SmithyBuildPlugin { // Generate public constrained types for directly constrained shapes. // In the Python server project, this is only done to generate constrained types for simple shapes (e.g. // a `string` shape with the `length` trait), but these always remain `pub(crate)`. - .let { if (constrainedTypes) ConstrainedShapeSymbolProvider(it, serviceShape, constrainedTypes) else it } + .let { + if (constrainedTypes) ConstrainedShapeSymbolProvider(it, serviceShape, constrainedTypes) else it + } // Generate different types for EventStream shapes (e.g. transcribe streaming) .let { EventStreamSymbolProvider(rustSymbolProviderConfig.runtimeConfig, it, CodegenTarget.SERVER) } // Add Rust attributes (like `#[derive(PartialEq)]`) to generated shapes diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt index 15de1bab08..9e353db2cd 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/customizations/PythonServerCodegenDecorator.kt @@ -163,11 +163,11 @@ class InitPyDecorator : ServerCodegenDecorator { rustCrate.withFile("python/$libName/__init__.py") { writeWithNoFormatting( """ -from .$libName import * + from .$libName import * -__doc__ = $libName.__doc__ -if hasattr($libName, "__all__"): - __all__ = $libName.__all__ + __doc__ = $libName.__doc__ + if hasattr($libName, "__all__"): + __all__ = $libName.__all__ """.trimIndent(), ) } diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt index f52b8fc760..8db6dc8439 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt @@ -106,7 +106,7 @@ class PythonApplicationGenerator( ##[#{pyo3}::pyclass] ##[derive(Debug)] /// :generic Ctx: - /// :extends typing.Generic\[Ctx\]: + /// :extends typing.Generic\[Ctx\]: /// :rtype None: pub struct App { handlers: #{HashMap}, @@ -285,10 +285,10 @@ class PythonApplicationGenerator( /// Main entrypoint: start the server on multiple workers. /// - /// :param address ${PythonType.Optional(PythonType.Str).renderAsDocstring()}: - /// :param port ${PythonType.Optional(PythonType.Int).renderAsDocstring()}: - /// :param backlog ${PythonType.Optional(PythonType.Int).renderAsDocstring()}: - /// :param workers ${PythonType.Optional(PythonType.Int).renderAsDocstring()}: + /// :param address ${PythonType.Optional(PythonType.Str).renderAsDocstring()}: + /// :param port ${PythonType.Optional(PythonType.Int).renderAsDocstring()}: + /// :param backlog ${PythonType.Optional(PythonType.Int).renderAsDocstring()}: + /// :param workers ${PythonType.Optional(PythonType.Int).renderAsDocstring()}: /// :param tls ${PythonType.Optional(tlsConfig).renderAsDocstring()}: /// :rtype ${PythonType.None.renderAsDocstring()}: ##[pyo3(text_signature = "(${'$'}self, address=None, port=None, backlog=None, workers=None, tls=None)")] @@ -434,7 +434,9 @@ class PythonApplicationGenerator( val operationDocumentation = it.getTrait()?.value val ret = if (!operationDocumentation.isNullOrBlank()) { operationDocumentation.replace("#", "##").prependIndent("/// ## ") + "\n" - } else "" + } else { + "" + } ret + """ /// ${it.signature()}: diff --git a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerTypesTest.kt b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerTypesTest.kt index c15b399744..be510db87b 100644 --- a/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerTypesTest.kt +++ b/codegen-server/python/src/test/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerTypesTest.kt @@ -21,7 +21,7 @@ internal class PythonServerTypesTest { fun `document type`() { val model = """ namespace test - + use aws.protocols#restJson1 @restJson1 @@ -30,7 +30,7 @@ internal class PythonServerTypesTest { Echo, ], } - + @http(method: "POST", uri: "/echo") operation Echo { input: EchoInput, @@ -40,7 +40,7 @@ internal class PythonServerTypesTest { structure EchoInput { value: Document, } - + structure EchoOutput { value: Document, } @@ -53,38 +53,38 @@ internal class PythonServerTypesTest { Pair( """ { "value": 42 } """, """ - assert input.value == 42 - output = EchoOutput(value=input.value) + assert input.value == 42 + output = EchoOutput(value=input.value) """, ), Pair( """ { "value": "foobar" } """, """ - assert input.value == "foobar" - output = EchoOutput(value=input.value) + assert input.value == "foobar" + output = EchoOutput(value=input.value) """, ), Pair( """ - { - "value": [ - true, - false, - 42, - 42.0, - -42, - { - "nested": "value" - }, - { - "nested": [1, 2, 3] - } - ] - } + { + "value": [ + true, + false, + 42, + 42.0, + -42, + { + "nested": "value" + }, + { + "nested": [1, 2, 3] + } + ] + } """, """ - assert input.value == [True, False, 42, 42.0, -42, {"nested": "value"}, {"nested": [1, 2, 3]}] - output = EchoOutput(value=input.value) + assert input.value == [True, False, 42, 42.0, -42, {"nested": "value"}, {"nested": [1, 2, 3]}] + output = EchoOutput(value=input.value) """, ), ) @@ -97,7 +97,7 @@ internal class PythonServerTypesTest { use pyo3::{types::IntoPyDict, IntoPy, Python}; use hyper::{Body, Request, body}; use crate::{input, output}; - + pyo3::prepare_freethreaded_python(); """.trimIndent(), ) @@ -112,9 +112,9 @@ internal class PythonServerTypesTest { Ok(Python::with_gil(|py| { let globals = [("EchoOutput", py.get_type::())].into_py_dict(py); let locals = [("input", input.into_py(py))].into_py_dict(py); - + py.run(${pythonHandler.dq()}, Some(globals), Some(locals)).unwrap(); - + locals .get_item("output") .unwrap() @@ -124,13 +124,13 @@ internal class PythonServerTypesTest { }) .build() .unwrap(); - + let req = Request::builder() .method("POST") .uri("/echo") .body(Body::from(${payload.dq()})) .unwrap(); - + let res = service.call(req).await.unwrap(); assert!(res.status().is_success()); let body = body::to_bytes(res.into_body()).await.unwrap(); diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/DeriveEqAndHashSymbolMetadataProvider.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/DeriveEqAndHashSymbolMetadataProvider.kt index 9b54c15132..d3f7059271 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/DeriveEqAndHashSymbolMetadataProvider.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/DeriveEqAndHashSymbolMetadataProvider.kt @@ -56,7 +56,7 @@ class DeriveEqAndHashSymbolMetadataProvider( val baseMetadata = base.toSymbol(shape).expectRustMetadata() // See class-level documentation for why we filter these out. return if (walker.walkShapes(shape) - .any { it is FloatShape || it is DoubleShape || it is DocumentShape || it.hasTrait() } + .any { it is FloatShape || it is DoubleShape || it is DocumentShape || it.hasTrait() } ) { baseMetadata } else { diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/LengthTraitValidationErrorMessage.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/LengthTraitValidationErrorMessage.kt index b15b2dc8f0..cb08de3c73 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/LengthTraitValidationErrorMessage.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/LengthTraitValidationErrorMessage.kt @@ -11,9 +11,11 @@ fun LengthTrait.validationErrorMessage(): String { val beginning = "Value with length {} at '{}' failed to satisfy constraint: Member must have length " val ending = if (this.min.isPresent && this.max.isPresent) { "between ${this.min.get()} and ${this.max.get()}, inclusive" - } else if (this.min.isPresent) ( - "greater than or equal to ${this.min.get()}" - ) else { + } else if (this.min.isPresent) { + ( + "greater than or equal to ${this.min.get()}" + ) + } else { check(this.max.isPresent) "less than or equal to ${this.max.get()}" } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RangeTraitValidationErrorMessage.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RangeTraitValidationErrorMessage.kt index 5512da8470..2088150394 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RangeTraitValidationErrorMessage.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RangeTraitValidationErrorMessage.kt @@ -11,9 +11,11 @@ fun RangeTrait.validationErrorMessage(): String { val beginning = "Value {} at '{}' failed to satisfy constraint: Member must be " val ending = if (this.min.isPresent && this.max.isPresent) { "between ${this.min.get()} and ${this.max.get()}, inclusive" - } else if (this.min.isPresent) ( - "greater than or equal to ${this.min.get()}" - ) else { + } else if (this.min.isPresent) { + ( + "greater than or equal to ${this.min.get()}" + ) + } else { check(this.max.isPresent) "less than or equal to ${this.max.get()}" } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustServerCodegenPlugin.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustServerCodegenPlugin.kt index 7f0ac42796..8df61342de 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustServerCodegenPlugin.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustServerCodegenPlugin.kt @@ -71,7 +71,9 @@ class RustServerCodegenPlugin : ServerDecoratableBuildPlugin() { ) = SymbolVisitor(model, serviceShape = serviceShape, config = rustSymbolProviderConfig) // Generate public constrained types for directly constrained shapes. - .let { if (includeConstrainedShapeProvider) ConstrainedShapeSymbolProvider(it, serviceShape, constrainedTypes) else it } + .let { + if (includeConstrainedShapeProvider) ConstrainedShapeSymbolProvider(it, serviceShape, constrainedTypes) else it + } // Generate different types for EventStream shapes (e.g. transcribe streaming) .let { EventStreamSymbolProvider(rustSymbolProviderConfig.runtimeConfig, it, CodegenTarget.SERVER) } // Generate [ByteStream] instead of `Blob` for streaming binary shapes (e.g. S3 GetObject) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraints.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraints.kt index 5116ec82d5..3a6cdabcd0 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraints.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraints.kt @@ -40,7 +40,7 @@ private sealed class UnsupportedConstraintMessageKind { fun intoLogMessage(ignoreUnsupportedConstraints: Boolean): LogMessage { fun buildMessage(intro: String, willSupport: Boolean, trackingIssue: String? = null, canBeIgnored: Boolean = true): String { var msg = """ - $intro + $intro This is not supported in the smithy-rs server SDK.""" if (willSupport) { msg += """ @@ -117,7 +117,7 @@ private sealed class UnsupportedConstraintMessageKind { Level.SEVERE, buildMessage( """ - The map shape `${mapShape.id}` is reachable from the list shape `${listShape.id}`, which has the + The map shape `${mapShape.id}` is reachable from the list shape `${listShape.id}`, which has the `@uniqueItems` trait attached. """.trimIndent().replace("\n", " "), willSupport = false, @@ -240,7 +240,9 @@ fun validateUnsupportedConstraints( .filterMapShapesToTraits(allConstraintTraits) .map { (shape, trait) -> UnsupportedConstraintOnShapeReachableViaAnEventStream(shape, trait) } .toSet() - val eventStreamErrors = eventStreamShapes.map { it.expectTrait() }.map { it.errorMembers } + val eventStreamErrors = eventStreamShapes.map { + it.expectTrait() + }.map { it.errorMembers } val unsupportedConstraintErrorShapeReachableViaAnEventStreamSet = eventStreamErrors .flatMap { it } .flatMap { walker.walkShapes(it) } @@ -278,10 +280,16 @@ fun validateUnsupportedConstraints( .toSet() val messages = - unsupportedLengthTraitOnStreamingBlobShapeSet.map { it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) } + - unsupportedConstraintShapeReachableViaAnEventStreamSet.map { it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) } + + unsupportedLengthTraitOnStreamingBlobShapeSet.map { + it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) + } + + unsupportedConstraintShapeReachableViaAnEventStreamSet.map { + it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) + } + unsupportedRangeTraitOnShapeSet.map { it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) } + - mapShapeReachableFromUniqueItemsListShapeSet.map { it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) } + mapShapeReachableFromUniqueItemsListShapeSet.map { + it.intoLogMessage(codegenConfig.ignoreUnsupportedConstraints) + } return ValidationResult(shouldAbort = messages.any { it.level == Level.SEVERE }, messages) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/CustomValidationExceptionWithReasonDecorator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/CustomValidationExceptionWithReasonDecorator.kt index 92de1fca48..746ea98ca9 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/CustomValidationExceptionWithReasonDecorator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/CustomValidationExceptionWithReasonDecorator.kt @@ -256,7 +256,7 @@ class ValidationExceptionWithReasonConversionGenerator(private val codegenContex override fun collectionShapeConstraintViolationImplBlock( collectionConstraintsInfo: - Collection, + Collection, isMemberConstrained: Boolean, ) = writable { val validationExceptionFields = collectionConstraintsInfo.map { @@ -276,7 +276,7 @@ class ValidationExceptionWithReasonConversionGenerator(private val codegenContex is CollectionTraitInfo.UniqueItems -> { rust( """ - Self::UniqueItems { duplicate_indices, .. } => + Self::UniqueItems { duplicate_indices, .. } => crate::model::ValidationExceptionField { message: format!("${it.uniqueItemsTrait.validationErrorMessage()}", &duplicate_indices, &path), name: path, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/SmithyValidationExceptionDecorator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/SmithyValidationExceptionDecorator.kt index 7d6d3eb9c8..42e2eac264 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/SmithyValidationExceptionDecorator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/SmithyValidationExceptionDecorator.kt @@ -209,15 +209,17 @@ class SmithyValidationExceptionConversionGenerator(private val codegenContext: S override fun collectionShapeConstraintViolationImplBlock( collectionConstraintsInfo: - Collection, + Collection, isMemberConstrained: Boolean, ) = writable { - val validationExceptionFields = collectionConstraintsInfo.map { it.toTraitInfo().asValidationExceptionField }.toMutableList() + val validationExceptionFields = collectionConstraintsInfo.map { + it.toTraitInfo().asValidationExceptionField + }.toMutableList() if (isMemberConstrained) { validationExceptionFields += { rust( """Self::Member(index, member_constraint_violation) => - member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string()) + member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string()) """, ) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ConstrainedCollectionGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ConstrainedCollectionGenerator.kt index d146f422b0..9b5775478e 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ConstrainedCollectionGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ConstrainedCollectionGenerator.kt @@ -116,29 +116,31 @@ class ConstrainedCollectionGenerator( #{ValidationFunctions:W} """, *codegenScope, - "ValidationFunctions" to constraintsInfo.map { it.validationFunctionDefinition(constraintViolation, inner) }.join("\n"), + "ValidationFunctions" to constraintsInfo.map { + it.validationFunctionDefinition(constraintViolation, inner) + }.join("\n"), ) } writer.rustTemplate( """ - impl #{TryFrom}<$inner> for $name { - type Error = #{ConstraintViolation}; + impl #{TryFrom}<$inner> for $name { + type Error = #{ConstraintViolation}; - /// ${rustDocsTryFromMethod(name, inner)} - fn try_from(value: $inner) -> Result { - #{ConstraintChecks:W} + /// ${rustDocsTryFromMethod(name, inner)} + fn try_from(value: $inner) -> Result { + #{ConstraintChecks:W} - Ok(Self(value)) + Ok(Self(value)) + } } - } - impl #{From}<$name> for $inner { - fn from(value: $name) -> Self { - value.into_inner() + impl #{From}<$name> for $inner { + fn from(value: $name) -> Self { + value.into_inner() + } } - } - """, + """, *codegenScope, "ConstraintChecks" to constraintsInfo.map { it.tryFromCheck }.join("\n"), ) @@ -248,7 +250,7 @@ sealed class CollectionTraitInfo { // [1]: https://github.com/awslabs/smithy-typescript/blob/517c85f8baccf0e5334b4e66d8786bdb5791c595/smithy-typescript-ssdk-libs/server-common/src/validation/index.ts#L106-L111 rust( """ - Self::UniqueItems { duplicate_indices, .. } => + Self::UniqueItems { duplicate_indices, .. } => crate::model::ValidationExceptionField { message: format!("${uniqueItemsTrait.validationErrorMessage()}", &duplicate_indices, &path), path, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/PubCrateConstrainedCollectionGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/PubCrateConstrainedCollectionGenerator.kt index ac4426fa29..1a563c25b9 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/PubCrateConstrainedCollectionGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/PubCrateConstrainedCollectionGenerator.kt @@ -108,11 +108,11 @@ class PubCrateConstrainedCollectionGenerator( impl #{From}<#{Symbol}> for $name { fn from(v: #{Symbol}) -> Self { ${ - if (innerNeedsConstraining) { - "Self(v.into_iter().map(|item| item.into()).collect())" - } else { - "Self(v)" - } + if (innerNeedsConstraining) { + "Self(v.into_iter().map(|item| item.into()).collect())" + } else { + "Self(v)" + } } } } @@ -120,11 +120,11 @@ class PubCrateConstrainedCollectionGenerator( impl #{From}<$name> for #{Symbol} { fn from(v: $name) -> Self { ${ - if (innerNeedsConstraining) { - "v.0.into_iter().map(|item| item.into()).collect()" - } else { - "v.0" - } + if (innerNeedsConstraining) { + "v.0.into_iter().map(|item| item.into()).collect()" + } else { + "v.0" + } } } } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderConstraintViolations.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderConstraintViolations.kt index 799997c819..1ecb71d878 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderConstraintViolations.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderConstraintViolations.kt @@ -133,7 +133,11 @@ class ServerBuilderConstraintViolations( for (constraintViolation in all) { when (constraintViolation.kind) { ConstraintViolationKind.MISSING_MEMBER -> { - writer.docs("${constraintViolation.message(symbolProvider, model).replaceFirstChar { it.uppercaseChar() }}.") + writer.docs( + "${constraintViolation.message(symbolProvider, model).replaceFirstChar { + it.uppercaseChar() + }}.", + ) writer.rust("${constraintViolation.name()},") } @@ -149,7 +153,11 @@ class ServerBuilderConstraintViolations( // Note we cannot express the inner constraint violation as `>::Error`, because `T` might // be `pub(crate)` and that would leak `T` in a public interface. - writer.docs("${constraintViolation.message(symbolProvider, model)}.".replaceFirstChar { it.uppercaseChar() }) + writer.docs( + "${constraintViolation.message(symbolProvider, model)}.".replaceFirstChar { + it.uppercaseChar() + }, + ) Attribute.DocHidden.render(writer) writer.rust("${constraintViolation.name()}(#T),", constraintViolationSymbol) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGenerator.kt index 34a7115714..c544c5b4c3 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerBuilderGenerator.kt @@ -191,7 +191,9 @@ class ServerBuilderGenerator( // since we are a builder and everything is optional. val baseDerives = structureSymbol.expectRustMetadata().derives // Filter out any derive that isn't Debug or Clone. Then add a Default derive - val builderDerives = baseDerives.filter { it == RuntimeType.Debug || it == RuntimeType.Clone } + RuntimeType.Default + val builderDerives = baseDerives.filter { + it == RuntimeType.Debug || it == RuntimeType.Clone + } + RuntimeType.Default Attribute(derive(builderDerives)).render(writer) writer.rustBlock("${visibility.toRustQualifier()} struct Builder") { members.forEach { renderBuilderMember(this, it) } @@ -393,12 +395,12 @@ class ServerBuilderGenerator( rust( """ self.$memberName = ${ - // TODO(https://github.com/awslabs/smithy-rs/issues/1302, https://github.com/awslabs/smithy/issues/1179): See above. - if (symbolProvider.toSymbol(member).isOptional()) { - "input.map(|v| v.into())" - } else { - "Some(input.into())" - } + // TODO(https://github.com/awslabs/smithy-rs/issues/1302, https://github.com/awslabs/smithy/issues/1179): See above. + if (symbolProvider.toSymbol(member).isOptional()) { + "input.map(|v| v.into())" + } else { + "Some(input.into())" + } }; self """, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt index 47b42825fa..0163f094f5 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt @@ -85,10 +85,14 @@ class LabelSensitivity(internal val labelIndexes: List, internal val greedy private fun hasRedactions(): Boolean = labelIndexes.isNotEmpty() || greedyLabel != null /** Returns the type of the `MakeFmt`. */ - fun type(): Writable = if (hasRedactions()) writable { - rustTemplate("#{SmithyHttpServer}::instrumentation::sensitivity::uri::MakeLabel bool>", *codegenScope) - } else writable { - rustTemplate("#{SmithyHttpServer}::instrumentation::MakeIdentity", *codegenScope) + fun type(): Writable = if (hasRedactions()) { + writable { + rustTemplate("#{SmithyHttpServer}::instrumentation::sensitivity::uri::MakeLabel bool>", *codegenScope) + } + } else { + writable { + rustTemplate("#{SmithyHttpServer}::instrumentation::MakeIdentity", *codegenScope) + } } /** Returns the value of the `GreedyLabel`. */ @@ -105,9 +109,13 @@ class LabelSensitivity(internal val labelIndexes: List, internal val greedy } /** Returns the setter enclosing the closure or suffix position. */ - fun setter(): Writable = if (hasRedactions()) writable { - rustTemplate(".label(#{Closure:W}, #{GreedyLabel:W})", "Closure" to closure(), "GreedyLabel" to greedyLabelStruct()) - } else writable { } + fun setter(): Writable = if (hasRedactions()) { + writable { + rustTemplate(".label(#{Closure:W}, #{GreedyLabel:W})", "Closure" to closure(), "GreedyLabel" to greedyLabelStruct()) + } + } else { + writable { } + } } /** Models the ways headers can be bound and sensitive */ @@ -156,11 +164,15 @@ sealed class HeaderSensitivity( /** Returns the closure used during construction. */ internal fun closure(): Writable { - val nameMatch = if (headerKeys.isEmpty()) writable { - rust("false") - } else writable { - val matches = headerKeys.joinToString("|") { it.dq() } - rust("matches!(name.as_str(), $matches)") + val nameMatch = if (headerKeys.isEmpty()) { + writable { + rust("false") + } + } else { + writable { + val matches = headerKeys.joinToString("|") { it.dq() } + rust("matches!(name.as_str(), $matches)") + } } val suffixAndValue = when (this) { @@ -252,11 +264,15 @@ sealed class QuerySensitivity( is SensitiveMapValue -> writable { rust("true") } - is NotSensitiveMapValue -> if (queryKeys.isEmpty()) writable { - rust("false;") - } else writable { - val matches = queryKeys.joinToString("|") { it.dq() } - rust("matches!(name, $matches);") + is NotSensitiveMapValue -> if (queryKeys.isEmpty()) { + writable { + rust("false;") + } + } else { + writable { + val matches = queryKeys.joinToString("|") { it.dq() } + rust("matches!(name, $matches);") + } } } @@ -498,7 +514,9 @@ class ServerHttpSensitivityGenerator( ) } - val value = writable { rustTemplate("#{SmithyHttpServer}::instrumentation::sensitivity::RequestFmt::new()", *codegenScope) } + headerSensitivity.setter() + labelSensitivity.setter() + querySensitivity.setters() + val value = writable { + rustTemplate("#{SmithyHttpServer}::instrumentation::sensitivity::RequestFmt::new()", *codegenScope) + } + headerSensitivity.setter() + labelSensitivity.setter() + querySensitivity.setters() return MakeFmt(type, value) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt index fc7e2cdd8b..4d2a275fce 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt @@ -48,7 +48,9 @@ open class ServerServiceGenerator( fun documentation(writer: RustWriter) { val operations = index.getContainedOperations(codegenContext.serviceShape).toSortedSet(compareBy { it.id }) val builderFieldNames = - operations.associateWith { RustReservedWords.escapeIfNeeded(codegenContext.symbolProvider.toSymbol(it).name.toSnakeCase()) } + operations.associateWith { + RustReservedWords.escapeIfNeeded(codegenContext.symbolProvider.toSymbol(it).name.toSnakeCase()) + } .toSortedMap( compareBy { it.id }, ) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt index d12813cf19..d761be13e7 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt @@ -82,7 +82,9 @@ class ServerRequestAfterDeserializingIntoAHashMapOfHttpPrefixHeadersWrapInUncons if (section.memberShape.targetCanReachConstrainedShape(codegenContext.model, codegenContext.unconstrainedShapeSymbolProvider)) { rust( "let out = out.map(#T);", - codegenContext.unconstrainedShapeSymbolProvider.toSymbol(section.memberShape).mapRustType { it.stripOuter() }, + codegenContext.unconstrainedShapeSymbolProvider.toSymbol(section.memberShape).mapRustType { + it.stripOuter() + }, ) } } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 28480bbc5a..d1ff2b37d4 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -344,8 +344,8 @@ class ServerProtocolTestGenerator( val operationErrorName = "crate::error::${operationSymbol.name}Error" if (!protocolSupport.responseSerialization || ( - !protocolSupport.errorSerialization && shape.hasTrait() - ) + !protocolSupport.errorSerialization && shape.hasTrait() + ) ) { rust("/* test case disabled for this protocol (not yet supported) */") return @@ -415,22 +415,22 @@ class ServerProtocolTestGenerator( rustTemplate( """ .body(${ - if (body != null) { - // The `replace` is necessary to fix the malformed request test `RestJsonInvalidJsonBody`. - // https://github.com/awslabs/smithy/blob/887ae4f6d118e55937105583a07deb90d8fabe1c/smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-request-body.smithy#L47 - // - // Smithy is written in Java, which parses `\u000c` within a `String` as a single char given by the - // corresponding Unicode code point. That is the "form feed" 0x0c character. When printing it, - // it gets written as "\f", which is an invalid Rust escape sequence: https://static.rust-lang.org/doc/master/reference.html#literals - // So we need to write the corresponding Rust Unicode escape sequence to make the program compile. - // - // We also escape to avoid interactions with templating in the case where the body contains `#`. - val sanitizedBody = escape(body.replace("\u000c", "\\u{000c}")).dq() - - "#{SmithyHttpServer}::body::Body::from(#{Bytes}::from_static($sanitizedBody.as_bytes()))" - } else { - "#{SmithyHttpServer}::body::Body::empty()" - } + if (body != null) { + // The `replace` is necessary to fix the malformed request test `RestJsonInvalidJsonBody`. + // https://github.com/awslabs/smithy/blob/887ae4f6d118e55937105583a07deb90d8fabe1c/smithy-aws-protocol-tests/model/restJson1/malformedRequests/malformed-request-body.smithy#L47 + // + // Smithy is written in Java, which parses `\u000c` within a `String` as a single char given by the + // corresponding Unicode code point. That is the "form feed" 0x0c character. When printing it, + // it gets written as "\f", which is an invalid Rust escape sequence: https://static.rust-lang.org/doc/master/reference.html#literals + // So we need to write the corresponding Rust Unicode escape sequence to make the program compile. + // + // We also escape to avoid interactions with templating in the case where the body contains `#`. + val sanitizedBody = escape(body.replace("\u000c", "\\u{000c}")).dq() + + "#{SmithyHttpServer}::body::Body::from(#{Bytes}::from_static($sanitizedBody.as_bytes()))" + } else { + "#{SmithyHttpServer}::body::Body::empty()" + } }).unwrap(); """, *codegenScope, @@ -643,7 +643,7 @@ class ServerProtocolTestGenerator( assertOk(rustWriter) { rustWriter.rust( "#T(&body, ${ - rustWriter.escape(body).dq() + rustWriter.escape(body).dq() }, #T::from(${(mediaType ?: "unknown").dq()}))", RuntimeType.protocolTest(codegenContext.runtimeConfig, "validate_body"), RuntimeType.protocolTest(codegenContext.runtimeConfig, "MediaType"), diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt index 50721990b4..adf7cf0a93 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt @@ -658,11 +658,11 @@ private class ServerHttpBoundProtocolTraitImplGenerator( """ { input = input.${member.setterName()}(${ - if (symbolProvider.toSymbol(binding.member).isOptional()) { - "Some(value)" - } else { - "value" - } + if (symbolProvider.toSymbol(binding.member).isOptional()) { + "Some(value)" + } else { + "value" + } }); } """, @@ -690,7 +690,9 @@ private class ServerHttpBoundProtocolTraitImplGenerator( ) ) { "?" - } else "" + } else { + "" + } rustTemplate("input.build()$err", *codegenScope) } @@ -840,7 +842,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( // * a map of list of string; or // * a map of set of string. enum class QueryParamsTargetMapValueType { - STRING, LIST, SET; + STRING, LIST, SET } private fun queryParamsTargetMapValueType(targetMapValue: Shape): QueryParamsTargetMapValueType = @@ -1023,7 +1025,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( rustBlock("if !$memberName.is_empty()") { withBlock( "input = input.${ - binding.member.setterName() + binding.member.setterName() }(", ");", ) { @@ -1032,7 +1034,9 @@ private class ServerHttpBoundProtocolTraitImplGenerator( "#T(", ")", conditional = hasConstrainedTarget, - unconstrainedShapeSymbolProvider.toSymbol(binding.member).mapRustType { it.stripOuter() }, + unconstrainedShapeSymbolProvider.toSymbol(binding.member).mapRustType { + it.stripOuter() + }, ) { write(memberName) } diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ConstraintsMemberShapeTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ConstraintsMemberShapeTest.kt index 5d29d109a3..952140d726 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ConstraintsMemberShapeTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ConstraintsMemberShapeTest.kt @@ -445,7 +445,11 @@ class ConstraintsMemberShapeTest { // In case the target shape has some more constraints, which the member shape did not override, // then those still need to apply on the new standalone shape that has been defined. val leftOverTraits = originalTargetShape.allTraits.values - .filter { beforeOverridingTrait -> beforeTransformConstraintTraits.none { beforeOverridingTrait.toShapeId() == it.toShapeId() } } + .filter { beforeOverridingTrait -> + beforeTransformConstraintTraits.none { + beforeOverridingTrait.toShapeId() == it.toShapeId() + } + } val allNewShapeTraits = memberTargetShape.allTraits.values.toList() assert((leftOverTraits + newShapeConstrainedTraits).all { it in allNewShapeTraits }) { lazyMessage } } diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/PubCrateConstrainedShapeSymbolProviderTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/PubCrateConstrainedShapeSymbolProviderTest.kt index f0b339a485..8d07a5959a 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/PubCrateConstrainedShapeSymbolProviderTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/PubCrateConstrainedShapeSymbolProviderTest.kt @@ -55,13 +55,17 @@ class PubCrateConstrainedShapeSymbolProviderTest { @Test fun `it should crash when provided with a shape that is directly constrained`() { val constrainedStringShape = model.lookup("test#ConstrainedString") - shouldThrow { pubCrateConstrainedShapeSymbolProvider.toSymbol(constrainedStringShape) } + shouldThrow { + pubCrateConstrainedShapeSymbolProvider.toSymbol(constrainedStringShape) + } } @Test fun `it should crash when provided with a shape that is unconstrained`() { val unconstrainedStringShape = model.lookup("test#UnconstrainedString") - shouldThrow { pubCrateConstrainedShapeSymbolProvider.toSymbol(unconstrainedStringShape) } + shouldThrow { + pubCrateConstrainedShapeSymbolProvider.toSymbol(unconstrainedStringShape) + } } @Test diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RecursiveConstraintViolationsTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RecursiveConstraintViolationsTest.kt index 8285d20c8b..7467d0d76f 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RecursiveConstraintViolationsTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RecursiveConstraintViolationsTest.kt @@ -52,7 +52,7 @@ internal class RecursiveConstraintViolationsTest { private fun recursiveListModel(sparse: Boolean, listPrefix: String = ""): Pair = """ $baseModel - + structure Recursive { list: ${listPrefix}List } @@ -71,7 +71,7 @@ internal class RecursiveConstraintViolationsTest { private fun recursiveMapModel(sparse: Boolean, mapPrefix: String = ""): Pair = """ $baseModel - + structure Recursive { map: ${mapPrefix}Map } @@ -91,7 +91,7 @@ internal class RecursiveConstraintViolationsTest { private fun recursiveUnionModel(unionPrefix: String = ""): Pair = """ $baseModel - + structure Recursive { attributeValue: ${unionPrefix}AttributeValue } diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraintsAreNotUsedTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraintsAreNotUsedTest.kt index bb19a86deb..68b88a7978 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraintsAreNotUsedTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraintsAreNotUsedTest.kt @@ -155,16 +155,16 @@ internal class ValidateUnsupportedConstraintsAreNotUsedTest { private val mapShapeReachableFromUniqueItemsListShapeModel = """ $baseModel - + structure TestInputOutput { uniqueItemsList: UniqueItemsList } - + @uniqueItems list UniqueItemsList { member: Map } - + map Map { key: String value: String @@ -177,10 +177,12 @@ internal class ValidateUnsupportedConstraintsAreNotUsedTest { validationResult.messages shouldHaveSize 1 validationResult.shouldAbort shouldBe true - validationResult.messages[0].message shouldContain """ - The map shape `test#Map` is reachable from the list shape `test#UniqueItemsList`, which has the + validationResult.messages[0].message shouldContain( + """ + The map shape `test#Map` is reachable from the list shape `test#UniqueItemsList`, which has the `@uniqueItems` trait attached. - """.trimIndent().replace("\n", " ") + """.trimIndent().replace("\n", " ") + ) } @Test diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/PostprocessValidationExceptionNotAttachedErrorMessageDecoratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/PostprocessValidationExceptionNotAttachedErrorMessageDecoratorTest.kt index 10b146805e..9130d30b33 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/PostprocessValidationExceptionNotAttachedErrorMessageDecoratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/PostprocessValidationExceptionNotAttachedErrorMessageDecoratorTest.kt @@ -23,16 +23,16 @@ internal class PostprocessValidationExceptionNotAttachedErrorMessageDecoratorTes """ namespace test use aws.protocols#restJson1 - + @restJson1 service TestService { operations: ["ConstrainedOperation"], } - - operation ConstrainedOperation { - input: ConstrainedOperationInput + + operation ConstrainedOperation { + input: ConstrainedOperationInput } - + structure ConstrainedOperationInput { @required requiredString: String @@ -51,9 +51,9 @@ internal class PostprocessValidationExceptionNotAttachedErrorMessageDecoratorTes val level = validationResult.messages.first().level val message = """ -${validationResult.messages.first().message} + ${validationResult.messages.first().message} -There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man. + There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man. """ return validationResult.copy(messages = listOf(LogMessage(level, message))) diff --git a/gradle.properties b/gradle.properties index 54255495bc..a353e421af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,10 +21,10 @@ smithyGradlePluginVersion=0.6.0 smithyVersion=1.26.2 # kotlin -kotlinVersion=1.6.21 +kotlinVersion=1.7.21 # testing/utility -ktlintVersion=0.46.1 +ktlintVersion=0.48.2 kotestVersion=5.2.3 # Avoid registering dependencies/plugins/tasks that are only used for testing purposes isTestingEnabled=true diff --git a/rust-runtime/aws-smithy-http-server-python/examples/Makefile b/rust-runtime/aws-smithy-http-server-python/examples/Makefile index bd4e88bba7..3b73f08ca6 100644 --- a/rust-runtime/aws-smithy-http-server-python/examples/Makefile +++ b/rust-runtime/aws-smithy-http-server-python/examples/Makefile @@ -37,7 +37,7 @@ install-wheel: generate-stubs: python3 $(CUR_DIR)/stubgen.py pokemon_service_server_sdk $(SERVER_SDK_DST)/python/pokemon_service_server_sdk -build: codegen +build: codegen $(MAKE) build-wheel $(MAKE) install-wheel $(MAKE) generate-stubs diff --git a/rust-runtime/aws-smithy-http-server-python/examples/stubgen_test.py b/rust-runtime/aws-smithy-http-server-python/examples/stubgen_test.py index 30c8cb5da6..f1d2aa840a 100644 --- a/rust-runtime/aws-smithy-http-server-python/examples/stubgen_test.py +++ b/rust-runtime/aws-smithy-http-server-python/examples/stubgen_test.py @@ -30,7 +30,7 @@ def foo(): """, """ import typing - + foo: typing.Any """, ) diff --git a/rust-runtime/aws-smithy-http-server-python/src/types.rs b/rust-runtime/aws-smithy-http-server-python/src/types.rs index 24eb72f9a8..1ae44a0432 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/types.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/types.rs @@ -710,10 +710,10 @@ mod tests { .into(), ), "{ - 't': True, - 'foo': 'foo', - 'f42': 42.0, - 'i42': 42, + 't': True, + 'foo': 'foo', + 'f42': 42.0, + 'i42': 42, 'f': False, 'vec': [ 'inner',