Skip to content

Commit 6df3129

Browse files
committed
Fix Python
1 parent c9b1e21 commit 6df3129

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCodegenVisitor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class PythonServerCodegenVisitor(
132132
*/
133133
override fun stringShape(shape: StringShape) {
134134
fun pythonServerEnumGeneratorFactory(codegenContext: ServerCodegenContext, writer: RustWriter, shape: StringShape) =
135-
PythonServerEnumGenerator(codegenContext, writer, shape)
135+
PythonServerEnumGenerator(codegenContext, writer, shape, validationExceptionConversionGenerator)
136136
stringShape(shape, ::pythonServerEnumGeneratorFactory)
137137
}
138138

codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import software.amazon.smithy.rust.codegen.core.util.dq
1717
import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCargoDependency
1818
import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext
1919
import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerEnumGenerator
20+
import software.amazon.smithy.rust.codegen.server.smithy.generators.ValidationExceptionConversionGenerator
2021

2122
/**
2223
* To share enums defined in Rust with Python, `pyo3` provides the `PyClass` trait.
@@ -27,7 +28,8 @@ class PythonServerEnumGenerator(
2728
codegenContext: ServerCodegenContext,
2829
private val writer: RustWriter,
2930
shape: StringShape,
30-
) : ServerEnumGenerator(codegenContext, writer, shape) {
31+
validationExceptionConversionGenerator: ValidationExceptionConversionGenerator,
32+
) : ServerEnumGenerator(codegenContext, writer, shape, validationExceptionConversionGenerator) {
3133

3234
private val pyO3 = PythonServerCargoDependency.PyO3.toType()
3335

codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/testutil/PythonServerTestHelpers.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import software.amazon.smithy.rust.codegen.core.testutil.generatePluginContext
1313
import software.amazon.smithy.rust.codegen.core.util.runCommand
1414
import software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCodegenVisitor
1515
import software.amazon.smithy.rust.codegen.server.python.smithy.customizations.DECORATORS
16+
import software.amazon.smithy.rust.codegen.server.smithy.customizations.CustomValidationExceptionWithReasonDecorator
1617
import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations
18+
import software.amazon.smithy.rust.codegen.server.smithy.customizations.SmithyValidationExceptionDecorator
1719
import software.amazon.smithy.rust.codegen.server.smithy.customize.CombinedServerCodegenDecorator
1820
import java.io.File
1921
import java.nio.file.Path
@@ -25,10 +27,13 @@ fun generatePythonServerPluginContext(model: Model) =
2527
generatePluginContext(model, runtimeConfig = TestRuntimeConfig)
2628

2729
fun executePythonServerCodegenVisitor(pluginCtx: PluginContext) {
28-
val codegenDecorator: CombinedServerCodegenDecorator =
30+
val codegenDecorator =
2931
CombinedServerCodegenDecorator.fromClasspath(
3032
pluginCtx,
31-
CombinedServerCodegenDecorator(DECORATORS + ServerRequiredCustomizations()),
33+
*DECORATORS,
34+
ServerRequiredCustomizations(),
35+
SmithyValidationExceptionDecorator(),
36+
CustomValidationExceptionWithReasonDecorator(),
3237
)
3338
PythonServerCodegenVisitor(pluginCtx, codegenDecorator).execute()
3439
}

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerCodegenVisitor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ open class ServerCodegenVisitor(
103103
protected var codegenContext: ServerCodegenContext
104104
protected var protocolGeneratorFactory: ProtocolGeneratorFactory<ServerProtocolGenerator, ServerCodegenContext>
105105
protected var protocolGenerator: ServerProtocolGenerator
106-
private var validationExceptionConversionGenerator: ValidationExceptionConversionGenerator
106+
protected var validationExceptionConversionGenerator: ValidationExceptionConversionGenerator
107107

108108
init {
109109
val symbolVisitorConfig =

0 commit comments

Comments
 (0)