Skip to content

Commit

Permalink
Adjust Python
Browse files Browse the repository at this point in the history
  • Loading branch information
david-perez committed Jan 18, 2023
1 parent dd6c32e commit f1f0b3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import software.amazon.smithy.rust.codegen.core.smithy.EventStreamSymbolProvider
import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitor
import software.amazon.smithy.rust.codegen.core.smithy.SymbolVisitorConfig
import software.amazon.smithy.rust.codegen.server.python.smithy.customizations.DECORATORS
import software.amazon.smithy.rust.codegen.server.smithy.ConstrainedShapeSymbolMetadataProvider
import software.amazon.smithy.rust.codegen.server.smithy.ConstrainedShapeSymbolProvider
import software.amazon.smithy.rust.codegen.server.smithy.DeriveEqAndHashSymbolMetadataProvider
import software.amazon.smithy.rust.codegen.server.smithy.customizations.ServerRequiredCustomizations
import software.amazon.smithy.rust.codegen.server.smithy.customize.CombinedServerCodegenDecorator
import java.util.logging.Level
Expand Down Expand Up @@ -54,7 +56,7 @@ class PythonCodegenServerPlugin : SmithyBuildPlugin {
}

companion object {
/** SymbolProvider
/**
* When generating code, smithy types need to be converted into Rust types—that is the core role of the symbol provider
*
* The Symbol provider is composed of a base [SymbolVisitor] which handles the core functionality, then is layered
Expand All @@ -75,10 +77,14 @@ class PythonCodegenServerPlugin : SmithyBuildPlugin {
.let { if (constrainedTypes) ConstrainedShapeSymbolProvider(it, model, serviceShape) else it }
// Generate different types for EventStream shapes (e.g. transcribe streaming)
.let { EventStreamSymbolProvider(symbolVisitorConfig.runtimeConfig, it, model, CodegenTarget.SERVER) }
// Constrained shapes generate newtypes that need the same derives we place on types generated from aggregate shapes.
.let { ConstrainedShapeSymbolMetadataProvider(it, model, constrainedTypes) }
// Add Rust attributes (like `#[derive(PartialEq)]`) to generated shapes
.let { BaseSymbolMetadataProvider(it, model, additionalAttributes = listOf()) }
// Streaming shapes need different derives (e.g. they cannot derive Eq)
.let { PythonStreamingShapeMetadataProvider(it, model) }
// Derive `Eq` and `Hash` if possible.
.let { DeriveEqAndHashSymbolMetadataProvider(it, model) }
// Rename shapes that clash with Rust reserved words & and other SDK specific features e.g. `send()` cannot
// be the name of an operation input
.let { RustReservedWordSymbolProvider(it, model) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PythonServerSymbolVisitor(
val target = model.expectShape(shape.target)
val container = model.expectShape(shape.container)

// We are only targetting non syntetic inputs and outputs.
// We are only targeting non-synthetic inputs and outputs.
if (!container.hasTrait<SyntheticOutputTrait>() && !container.hasTrait<SyntheticInputTrait>()) {
return initial
}
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http-server-python/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::PyError;

/// Python Wrapper for [aws_smithy_types::Blob].
#[pyclass]
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Blob(aws_smithy_types::Blob);

impl Blob {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'blob> From<&'blob Blob> for &'blob aws_smithy_types::Blob {

/// Python Wrapper for [aws_smithy_types::date_time::DateTime].
#[pyclass]
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DateTime(aws_smithy_types::date_time::DateTime);

#[pyclass]
Expand Down

0 comments on commit f1f0b3d

Please sign in to comment.