Skip to content

Commit 2bb969f

Browse files
authored
[Python] Ensure we generate correct string literals in Python unions (#2478)
* Make sure string literals are valid * Remove raw string marker * Remove jsonrpc model * Add commented JsonRPC1.0 model
1 parent bebc58a commit 2bb969f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

codegen-server-test/python/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ val allCodegenTests = "../../codegen-core/common-test-models".let { commonModels
5454
// TODO(https://github.com/awslabs/smithy-rs/issues/1401) `@uniqueItems` is used.
5555
extraConfig = """, "codegen": { "ignoreUnsupportedConstraints": true } """,
5656
),
57+
// TODO(https://github.com/awslabs/smithy-rs/issues/2476)
58+
// CodegenTest(
59+
// "aws.protocoltests.json#JsonProtocol",
60+
// "json_rpc11",
61+
// extraConfig = """, "codegen": { "ignoreUnsupportedConstraints": true } """,
62+
// ),
63+
// TODO(https://github.com/awslabs/smithy-rs/issues/2479)
64+
// CodegenTest("aws.protocoltests.json10#JsonRpc10", "json_rpc10"),
5765
)
5866
}
5967

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class PythonServerUnionGenerator(
186186
match self.0.as_$funcNamePart() {
187187
Ok(variant) => Ok($variantType),
188188
Err(_) => Err(#{pyo3}::exceptions::PyValueError::new_err(
189-
"${unionSymbol.name} variant is not of type ${memberSymbol.rustType().pythonType().renderAsDocstring()}"
189+
r"${unionSymbol.name} variant is not of type ${memberSymbol.rustType().pythonType().renderAsDocstring()}"
190190
)),
191191
}
192192
""",

0 commit comments

Comments
 (0)