Server Test Python

Server Test Python

rev. 1d902e1fdfff69f8aafe42b2306fa317ef96d562 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/python/rest_json/socket/__init__.pyi

@@ -1,0 +27,0 @@
    1         -
import typing
    2         -
    3         -
class PySocket:
    4         -
    """
    5         -
    Socket implementation that can be shared between multiple Python processes.
    6         -
    7         -
    Python cannot handle true multi-threaded applications due to the [GIL],
    8         -
    often resulting in reduced performance and only one core used by the application.
    9         -
    To work around this, Python web applications usually create a socket with
   10         -
    SO_REUSEADDR and SO_REUSEPORT enabled that can be shared between multiple
   11         -
    Python processes, allowing you to maximize performance and use all available
   12         -
    computing capacity of the host.
   13         -
   14         -
    [GIL]: https://wiki.python.org/moin/GlobalInterpreterLock
   15         -
    """
   16         -
   17         -
    def try_clone(self) -> PySocket:
   18         -
        """
   19         -
        Clone the inner socket allowing it to be shared between multiple
   20         -
        Python processes.
   21         -
        """
   22         -
        ...
   23         -
   24         -
   25         -
    def __init__(self, address: str, port: int, backlog: typing.Optional[int] = ...) -> None:
   26         -
        ...
   27         -

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/python/rest_json/tls/__init__.pyi

@@ -1,0 +10,0 @@
    1         -
import pathlib
    2         -
    3         -
class TlsConfig:
    4         -
    """
    5         -
    PyTlsConfig represents TLS configuration created from Python.
    6         -
    """
    7         -
    8         -
    def __init__(self, key_path: pathlib.Path, cert_path: pathlib.Path, reload_secs: int = ...) -> None:
    9         -
        ...
   10         -

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/python/rest_json/types/__init__.pyi

@@ -1,0 +209,0 @@
    1         -
import typing
    2         -
    3         -
class Blob:
    4         -
    """
    5         -
    Python Wrapper for [aws_smithy_types::Blob].
    6         -
    """
    7         -
    8         -
    data: bytes
    9         -
    """
   10         -
    Python getter for the `Blob` byte array.
   11         -
    """
   12         -
   13         -
    def __init__(self, input: bytes) -> None:
   14         -
        ...
   15         -
   16         -
   17         -
class ByteStream:
   18         -
    """
   19         -
    Python Wrapper for [aws_smithy_types::byte_stream::ByteStream].
   20         -
   21         -
    ByteStream provides misuse-resistant primitives to make it easier to handle common patterns with streaming data.
   22         -
   23         -
    On the Rust side, The Python implementation wraps the original [ByteStream](aws_smithy_types::byte_stream::ByteStream)
   24         -
    in a clonable structure and implements the [Stream](futures::stream::Stream) trait for it to
   25         -
    allow Rust to handle the type transparently.
   26         -
   27         -
    On the Python side both sync and async iterators are exposed by implementing `__iter__()` and `__aiter__()` magic methods,
   28         -
    which allows to just loop over the stream chunks.
   29         -
   30         -
    ### Example of async streaming:
   31         -
   32         -
    ```python
   33         -
        stream = await ByteStream.from_path("/tmp/music.mp3")
   34         -
        async for chunk in stream:
   35         -
            print(chunk)
   36         -
    ```
   37         -
   38         -
    ### Example of sync streaming:
   39         -
   40         -
    ```python
   41         -
        stream = ByteStream.from_stream_blocking("/tmp/music.mp3")
   42         -
        for chunk in stream:
   43         -
            print(chunk)
   44         -
    ```
   45         -
   46         -
    The main difference between the two implementations is that the async one is scheduling the Python coroutines as Rust futures,
   47         -
    effectively maintaining the asyncronous behavior that Rust exposes, while the sync one is blocking the Tokio runtime to be able
   48         -
    to await one chunk at a time.
   49         -
   50         -
    The original Rust [ByteStream](aws_smithy_types::byte_stream::ByteStream) is wrapped inside a `Arc<Mutex>` to allow the type to be
   51         -
    [Clone] (required by PyO3) and to allow internal mutability, required to fetch the next chunk of data.
   52         -
    """
   53         -
   54         -
    @staticmethod
   55         -
    def from_path(path: str) -> typing.Awaitable[ByteStream]:
   56         -
        """
   57         -
        Create a new [ByteStream](aws_smithy_types::byte_stream::ByteStream) from a path, forcing
   58         -
        Python to await this coroutine.
   59         -
        """
   60         -
        ...
   61         -
   62         -
   63         -
    @staticmethod
   64         -
    def from_path_blocking(path: str) -> ByteStream:
   65         -
        """
   66         -
        Create a new [ByteStream](aws_smithy_types::byte_stream::ByteStream) from a path, without
   67         -
        requiring Python to await this method.
   68         -
   69         -
        **NOTE:** This method will block the Rust event loop when it is running.
   70         -
        """
   71         -
        ...
   72         -
   73         -
   74         -
    def __init__(self, input: bytes) -> None:
   75         -
        ...
   76         -
   77         -
   78         -
class DateTime:
   79         -
    """
   80         -
    Python Wrapper for [aws_smithy_types::date_time::DateTime].
   81         -
    """
   82         -
   83         -
    def as_nanos(self) -> int:
   84         -
        """
   85         -
        Returns the number of nanoseconds since the Unix epoch that this `DateTime` represents.
   86         -
        """
   87         -
        ...
   88         -
   89         -
   90         -
    def as_secs_f64(self) -> float:
   91         -
        """
   92         -
        Returns the `DateTime` value as an `f64` representing the seconds since the Unix epoch.
   93         -
        """
   94         -
        ...
   95         -
   96         -
   97         -
    @staticmethod
   98         -
    def from_fractional_secs(epoch_seconds: int, fraction: float) -> DateTime:
   99         -
        """
  100         -
        Creates a `DateTime` from a number of seconds and a fractional second since the Unix epoch.
  101         -
        """
  102         -
        ...
  103         -
  104         -
  105         -
    @staticmethod
  106         -
    def from_millis(epoch_millis: int) -> DateTime:
  107         -
        """
  108         -
        Creates a `DateTime` from a number of milliseconds since the Unix epoch.
  109         -
        """
  110         -
        ...
  111         -
  112         -
  113         -
    @staticmethod
  114         -
    def from_nanos(epoch_nanos: int) -> DateTime:
  115         -
        """
  116         -
        Creates a `DateTime` from a number of nanoseconds since the Unix epoch.
  117         -
        """
  118         -
        ...
  119         -
  120         -
  121         -
    @staticmethod
  122         -
    def from_secs(epoch_seconds: int) -> DateTime:
  123         -
        """
  124         -
        Creates a `DateTime` from a number of seconds since the Unix epoch.
  125         -
        """
  126         -
        ...
  127         -
  128         -
  129         -
    @staticmethod
  130         -
    def from_secs_and_nanos(seconds: int, subsecond_nanos: int) -> DateTime:
  131         -
        """
  132         -
        Creates a `DateTime` from a number of seconds and sub-second nanos since the Unix epoch.
  133         -
        """
  134         -
        ...
  135         -
  136         -
  137         -
    @staticmethod
  138         -
    def from_secs_f64(epoch_seconds: float) -> DateTime:
  139         -
        """
  140         -
        Creates a `DateTime` from an `f64` representing the number of seconds since the Unix epoch.
  141         -
        """
  142         -
        ...
  143         -
  144         -
  145         -
    @staticmethod
  146         -
    def from_str(s: str, format: Format) -> DateTime:
  147         -
        """
  148         -
        Parses a `DateTime` from a string using the given `format`.
  149         -
        """
  150         -
        ...
  151         -
  152         -
  153         -
    def has_subsec_nanos(self) -> bool:
  154         -
        """
  155         -
        Returns true if sub-second nanos is greater than zero.
  156         -
        """
  157         -
        ...
  158         -
  159         -
  160         -
    @staticmethod
  161         -
    def read(format: Format, delim: str) -> typing.Tuple[DateTime, str]:
  162         -
        """
  163         -
        Read 1 date of `format` from `s`, expecting either `delim` or EOF.
  164         -
  165         -
        TODO(PythonTyping): How do we represent `char` in Python?
  166         -
        """
  167         -
        ...
  168         -
  169         -
  170         -
    def secs(self) -> int:
  171         -
        """
  172         -
        Returns the epoch seconds component of the `DateTime`.
  173         -
        """
  174         -
        ...
  175         -
  176         -
  177         -
    def subsec_nanos(self) -> int:
  178         -
        """
  179         -
        Returns the sub-second nanos component of the `DateTime`.
  180         -
        """
  181         -
        ...
  182         -
  183         -
  184         -
    def to_millis(self) -> int:
  185         -
        """
  186         -
        Converts the `DateTime` to the number of milliseconds since the Unix epoch.
  187         -
        """
  188         -
        ...
  189         -
  190         -
  191         -
class Format:
  192         -
    """
  193         -
    Formats for representing a `DateTime` in the Smithy protocols.
  194         -
    """
  195         -
  196         -
    DateTime: Format
  197         -
    """
  198         -
    Formats for representing a `DateTime` in the Smithy protocols.
  199         -
    """
  200         -
  201         -
    EpochSeconds: Format
  202         -
    """
  203         -
    Formats for representing a `DateTime` in the Smithy protocols.
  204         -
    """
  205         -
  206         -
    HttpDate: Format
  207         -
    """
  208         -
    Formats for representing a `DateTime` in the Smithy protocols.
  209         -
    """

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/model.rs

@@ -3071,3071 +3138,3132 @@
 3091   3091   
        /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if a [`ConstraintViolation`] occurs.
 3092   3092   
        ///
 3093   3093   
        pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
 3094   3094   
            self.build_enforcing_all_constraints()
 3095   3095   
        }
 3096   3096   
        fn build_enforcing_all_constraints(
 3097   3097   
            self,
 3098   3098   
        ) -> Result<crate::model::TopLevel, ConstraintViolation> {
 3099   3099   
            Ok(crate::model::TopLevel {
 3100   3100   
                dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
 3101         -
                dialog_list: self.dialog_list.unwrap_or_else(
 3102         -
                    #[allow(clippy::redundant_closure)]
 3103         -
                    || ::std::vec::Vec::new(),
 3104         -
                ),
 3105         -
                dialog_map: self.dialog_map.unwrap_or_else(
 3106         -
                    #[allow(clippy::redundant_closure)]
 3107         -
                    || ::std::collections::HashMap::new(),
 3108         -
                ),
        3101  +
                dialog_list: self.dialog_list.unwrap_or_default(),
        3102  +
                dialog_map: self.dialog_map.unwrap_or_default(),
 3109   3103   
            })
 3110   3104   
        }
 3111   3105   
    }
 3112   3106   
}
 3113   3107   
/// See [`TopLevel`](crate::model::TopLevel).
 3114   3108   
pub mod top_level {
 3115   3109   
 3116   3110   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
 3117   3111   
    /// Holds one variant for each of the ways the builder can fail.
 3118   3112   
@@ -3152,3146 +3219,3207 @@
 3172   3166   
        /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if you do not provide a value for all non-`Option`al members.
 3173   3167   
        ///
 3174   3168   
        pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
 3175   3169   
            self.build_enforcing_required_and_enum_traits()
 3176   3170   
        }
 3177   3171   
        fn build_enforcing_required_and_enum_traits(
 3178   3172   
            self,
 3179   3173   
        ) -> Result<crate::model::TopLevel, ConstraintViolation> {
 3180   3174   
            Ok(crate::model::TopLevel {
 3181   3175   
                dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
 3182         -
                dialog_list: self.dialog_list.unwrap_or_else(
 3183         -
                    #[allow(clippy::redundant_closure)]
 3184         -
                    || ::std::vec::Vec::new(),
 3185         -
                ),
 3186         -
                dialog_map: self.dialog_map.unwrap_or_else(
 3187         -
                    #[allow(clippy::redundant_closure)]
 3188         -
                    || ::std::collections::HashMap::new(),
 3189         -
                ),
        3176  +
                dialog_list: self.dialog_list.unwrap_or_default(),
        3177  +
                dialog_map: self.dialog_map.unwrap_or_default(),
 3190   3178   
            })
 3191   3179   
        }
 3192   3180   
    }
 3193   3181   
}
 3194   3182   
/// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
 3195   3183   
pub(crate) mod client_optional_defaults_internal {
 3196   3184   
 3197   3185   
    impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
 3198   3186   
        fn from(builder: Builder) -> Self {
 3199   3187   
            builder.build()
@@ -3520,3508 +3623,3605 @@
 3540   3528   
        }
 3541   3529   
        fn build_enforcing_all_constraints(
 3542   3530   
            self,
 3543   3531   
        ) -> Result<crate::model::Defaults, ConstraintViolation> {
 3544   3532   
            Ok(crate::model::Defaults {
 3545   3533   
                default_string: self.default_string.unwrap_or_else(
 3546   3534   
                    #[allow(clippy::redundant_closure)]
 3547   3535   
                    || String::from("hi"),
 3548   3536   
                ),
 3549   3537   
                default_boolean: self.default_boolean.unwrap_or(true),
 3550         -
                default_list: self.default_list.unwrap_or_else(
 3551         -
                    #[allow(clippy::redundant_closure)]
 3552         -
                    || ::std::vec::Vec::new(),
 3553         -
                ),
        3538  +
                default_list: self.default_list.unwrap_or_default(),
 3554   3539   
                default_document_map: self.default_document_map.unwrap_or_else(
 3555   3540   
                    #[allow(clippy::redundant_closure)]
 3556   3541   
                    || {
 3557   3542   
                        ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
 3558   3543   
                            .into()
 3559   3544   
                    },
 3560   3545   
                ),
 3561   3546   
                default_document_string: self.default_document_string.unwrap_or_else(
 3562   3547   
                    #[allow(clippy::redundant_closure)]
 3563   3548   
                    || {
 3564   3549   
                        ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
 3565   3550   
                            .into()
 3566   3551   
                    },
 3567   3552   
                ),
 3568   3553   
                default_document_boolean: self
 3569   3554   
                    .default_document_boolean
 3570   3555   
                    .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
 3571   3556   
                default_document_list: self.default_document_list.unwrap_or_else(
 3572   3557   
                    #[allow(clippy::redundant_closure)]
 3573   3558   
                    || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
 3574   3559   
                ),
 3575   3560   
                default_null_document: self.default_null_document,
 3576   3561   
                default_timestamp: self.default_timestamp.unwrap_or_else(
 3577   3562   
                    #[allow(clippy::redundant_closure)]
 3578   3563   
                    || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
 3579   3564   
                ),
 3580   3565   
                default_blob: self.default_blob.unwrap_or_else(
 3581   3566   
                    #[allow(clippy::redundant_closure)]
 3582   3567   
                    || ::aws_smithy_types::Blob::new("abc").into(),
 3583   3568   
                ),
 3584   3569   
                default_byte: self.default_byte.unwrap_or(1i8),
 3585   3570   
                default_short: self.default_short.unwrap_or(1i16),
 3586   3571   
                default_integer: self.default_integer.unwrap_or(10i32),
 3587   3572   
                default_long: self.default_long.unwrap_or(100i64),
 3588   3573   
                default_float: self.default_float.unwrap_or(1.0f32),
 3589   3574   
                default_double: self.default_double.unwrap_or(1.0f64),
 3590         -
                default_map: self.default_map.unwrap_or_else(
 3591         -
                    #[allow(clippy::redundant_closure)]
 3592         -
                    || ::std::collections::HashMap::new(),
 3593         -
                ),
        3575  +
                default_map: self.default_map.unwrap_or_default(),
 3594   3576   
                default_enum: self
 3595   3577   
                    .default_enum
 3596   3578   
                    .map(|v| match v {
 3597   3579   
                        crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
 3598   3580   
                        crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
 3599   3581   
                    })
 3600   3582   
                    .map(|res| res.map_err(ConstraintViolation::DefaultEnum))
 3601   3583   
                    .transpose()?
 3602   3584   
                    .unwrap_or(
 3603   3585   
                        "FOO"
@@ -3819,3801 +3922,3898 @@
 3839   3821   
        pub fn build(self) -> crate::model::Defaults {
 3840   3822   
            self.build_enforcing_required_and_enum_traits()
 3841   3823   
        }
 3842   3824   
        fn build_enforcing_required_and_enum_traits(self) -> crate::model::Defaults {
 3843   3825   
            crate::model::Defaults {
 3844   3826   
                default_string: self.default_string.unwrap_or_else(
 3845   3827   
                    #[allow(clippy::redundant_closure)]
 3846   3828   
                    || String::from("hi"),
 3847   3829   
                ),
 3848   3830   
                default_boolean: self.default_boolean.unwrap_or(true),
 3849         -
                default_list: self.default_list.unwrap_or_else(
 3850         -
                    #[allow(clippy::redundant_closure)]
 3851         -
                    || ::std::vec::Vec::new(),
 3852         -
                ),
        3831  +
                default_list: self.default_list.unwrap_or_default(),
 3853   3832   
                default_document_map: self.default_document_map.unwrap_or_else(
 3854   3833   
                    #[allow(clippy::redundant_closure)]
 3855   3834   
                    || {
 3856   3835   
                        ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
 3857   3836   
                            .into()
 3858   3837   
                    },
 3859   3838   
                ),
 3860   3839   
                default_document_string: self.default_document_string.unwrap_or_else(
 3861   3840   
                    #[allow(clippy::redundant_closure)]
 3862   3841   
                    || {
 3863   3842   
                        ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
 3864   3843   
                            .into()
 3865   3844   
                    },
 3866   3845   
                ),
 3867   3846   
                default_document_boolean: self
 3868   3847   
                    .default_document_boolean
 3869   3848   
                    .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
 3870   3849   
                default_document_list: self.default_document_list.unwrap_or_else(
 3871   3850   
                    #[allow(clippy::redundant_closure)]
 3872   3851   
                    || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
 3873   3852   
                ),
 3874   3853   
                default_null_document: self.default_null_document,
 3875   3854   
                default_timestamp: self.default_timestamp.unwrap_or_else(
 3876   3855   
                    #[allow(clippy::redundant_closure)]
 3877   3856   
                    || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
 3878   3857   
                ),
 3879   3858   
                default_blob: self.default_blob.unwrap_or_else(
 3880   3859   
                    #[allow(clippy::redundant_closure)]
 3881   3860   
                    || ::aws_smithy_types::Blob::new("abc").into(),
 3882   3861   
                ),
 3883   3862   
                default_byte: self.default_byte.unwrap_or(1i8),
 3884   3863   
                default_short: self.default_short.unwrap_or(1i16),
 3885   3864   
                default_integer: self.default_integer.unwrap_or(10i32),
 3886   3865   
                default_long: self.default_long.unwrap_or(100i64),
 3887   3866   
                default_float: self.default_float.unwrap_or(1.0f32),
 3888   3867   
                default_double: self.default_double.unwrap_or(1.0f64),
 3889         -
                default_map: self.default_map.unwrap_or_else(
 3890         -
                    #[allow(clippy::redundant_closure)]
 3891         -
                    || ::std::collections::HashMap::new(),
 3892         -
                ),
        3868  +
                default_map: self.default_map.unwrap_or_default(),
 3893   3869   
                default_enum: self.default_enum.unwrap_or(
 3894   3870   
                    "FOO"
 3895   3871   
                        .parse::<crate::model::TestEnum>()
 3896   3872   
                        .expect("static value validated to member"),
 3897   3873   
                ),
 3898   3874   
                default_int_enum: self.default_int_enum.unwrap_or(1i32),
 3899   3875   
                empty_string: self.empty_string.unwrap_or_else(
 3900   3876   
                    #[allow(clippy::redundant_closure)]
 3901   3877   
                    || String::from(""),
 3902   3878   
                ),

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/output.rs

@@ -6224,6224 +6291,6285 @@
 6244   6244   
        ) -> Result<crate::output::OperationWithNestedStructureOutput, ConstraintViolation>
 6245   6245   
        {
 6246   6246   
            self.build_enforcing_required_and_enum_traits()
 6247   6247   
        }
 6248   6248   
        fn build_enforcing_required_and_enum_traits(
 6249   6249   
            self,
 6250   6250   
        ) -> Result<crate::output::OperationWithNestedStructureOutput, ConstraintViolation>
 6251   6251   
        {
 6252   6252   
            Ok(crate::output::OperationWithNestedStructureOutput {
 6253   6253   
                dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
 6254         -
                dialog_list: self.dialog_list.unwrap_or_else(
 6255         -
                    #[allow(clippy::redundant_closure)]
 6256         -
                    || ::std::vec::Vec::new(),
 6257         -
                ),
 6258         -
                dialog_map: self.dialog_map.unwrap_or_else(
 6259         -
                    #[allow(clippy::redundant_closure)]
 6260         -
                    || ::std::collections::HashMap::new(),
 6261         -
                ),
        6254  +
                dialog_list: self.dialog_list.unwrap_or_default(),
        6255  +
                dialog_map: self.dialog_map.unwrap_or_default(),
 6262   6256   
            })
 6263   6257   
        }
 6264   6258   
    }
 6265   6259   
}
 6266   6260   
/// See [`OperationWithDefaultsOutput`](crate::output::OperationWithDefaultsOutput).
 6267   6261   
pub mod operation_with_defaults_output {
 6268   6262   
 6269   6263   
    impl ::std::convert::From<Builder> for crate::output::OperationWithDefaultsOutput {
 6270   6264   
        fn from(builder: Builder) -> Self {
 6271   6265   
            builder.build()
@@ -6460,6454 +6563,6551 @@
 6480   6474   
        }
 6481   6475   
        fn build_enforcing_required_and_enum_traits(
 6482   6476   
            self,
 6483   6477   
        ) -> crate::output::OperationWithDefaultsOutput {
 6484   6478   
            crate::output::OperationWithDefaultsOutput {
 6485   6479   
                default_string: self.default_string.unwrap_or_else(
 6486   6480   
                    #[allow(clippy::redundant_closure)]
 6487   6481   
                    || String::from("hi"),
 6488   6482   
                ),
 6489   6483   
                default_boolean: self.default_boolean.unwrap_or(true),
 6490         -
                default_list: self.default_list.unwrap_or_else(
 6491         -
                    #[allow(clippy::redundant_closure)]
 6492         -
                    || ::std::vec::Vec::new(),
 6493         -
                ),
        6484  +
                default_list: self.default_list.unwrap_or_default(),
 6494   6485   
                default_document_map: self.default_document_map.unwrap_or_else(
 6495   6486   
                    #[allow(clippy::redundant_closure)]
 6496   6487   
                    || {
 6497   6488   
                        ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
 6498   6489   
                            .into()
 6499   6490   
                    },
 6500   6491   
                ),
 6501   6492   
                default_document_string: self.default_document_string.unwrap_or_else(
 6502   6493   
                    #[allow(clippy::redundant_closure)]
 6503   6494   
                    || {
 6504   6495   
                        ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
 6505   6496   
                            .into()
 6506   6497   
                    },
 6507   6498   
                ),
 6508   6499   
                default_document_boolean: self
 6509   6500   
                    .default_document_boolean
 6510   6501   
                    .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
 6511   6502   
                default_document_list: self.default_document_list.unwrap_or_else(
 6512   6503   
                    #[allow(clippy::redundant_closure)]
 6513   6504   
                    || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
 6514   6505   
                ),
 6515   6506   
                default_null_document: self.default_null_document,
 6516   6507   
                default_timestamp: self.default_timestamp.unwrap_or_else(
 6517   6508   
                    #[allow(clippy::redundant_closure)]
 6518   6509   
                    || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
 6519   6510   
                ),
 6520   6511   
                default_blob: self.default_blob.unwrap_or_else(
 6521   6512   
                    #[allow(clippy::redundant_closure)]
 6522   6513   
                    || ::aws_smithy_types::Blob::new("abc").into(),
 6523   6514   
                ),
 6524   6515   
                default_byte: self.default_byte.unwrap_or(1i8),
 6525   6516   
                default_short: self.default_short.unwrap_or(1i16),
 6526   6517   
                default_integer: self.default_integer.unwrap_or(10i32),
 6527   6518   
                default_long: self.default_long.unwrap_or(100i64),
 6528   6519   
                default_float: self.default_float.unwrap_or(1.0f32),
 6529   6520   
                default_double: self.default_double.unwrap_or(1.0f64),
 6530         -
                default_map: self.default_map.unwrap_or_else(
 6531         -
                    #[allow(clippy::redundant_closure)]
 6532         -
                    || ::std::collections::HashMap::new(),
 6533         -
                ),
        6521  +
                default_map: self.default_map.unwrap_or_default(),
 6534   6522   
                default_enum: self.default_enum.unwrap_or(
 6535   6523   
                    "FOO"
 6536   6524   
                        .parse::<crate::model::TestEnum>()
 6537   6525   
                        .expect("static value validated to member"),
 6538   6526   
                ),
 6539   6527   
                default_int_enum: self.default_int_enum.unwrap_or(1i32),
 6540   6528   
                empty_string: self.empty_string.unwrap_or_else(
 6541   6529   
                    #[allow(clippy::redundant_closure)]
 6542   6530   
                    || String::from(""),
 6543   6531   
                ),

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/__init__.pyi

@@ -1,0 +215,0 @@
    1         -
import rest_json_extras.input
    2         -
import rest_json_extras.middleware
    3         -
import rest_json_extras.output
    4         -
import rest_json_extras.tls
    5         -
import typing
    6         -
    7         -
Ctx = typing.TypeVar('Ctx')
    8         -
    9         -
class App(typing.Generic[Ctx]):
   10         -
    """
   11         -
    Main Python application, used to register operations and context and start multiple
   12         -
    workers on the same shared socket.
   13         -
   14         -
    Operations can be registered using the application object as a decorator (`@app.operation_name`).
   15         -
   16         -
    Here's a full example to get you started:
   17         -
   18         -
    ```python
   19         -
    from rest_json_extras import input
   20         -
    from rest_json_extras import output
   21         -
    from rest_json_extras import error
   22         -
    from rest_json_extras import middleware
   23         -
    from rest_json_extras import App
   24         -
   25         -
    @dataclass
   26         -
    class Context:
   27         -
        counter: int = 0
   28         -
   29         -
    app = App()
   30         -
    app.context(Context())
   31         -
   32         -
    @app.request_middleware
   33         -
    def request_middleware(request: middleware::Request):
   34         -
        if request.get_header("x-amzn-id") != "secret":
   35         -
            raise middleware.MiddlewareException("Unsupported `x-amz-id` header", 401)
   36         -
   37         -
    @app.case_insensitive_error_operation
   38         -
    def case_insensitive_error_operation(input: input::CaseInsensitiveErrorOperationInput, ctx: Context) -> output::CaseInsensitiveErrorOperationOutput:
   39         -
        raise NotImplementedError
   40         -
   41         -
    @app.empty_struct_with_content_on_wire_op
   42         -
    def empty_struct_with_content_on_wire_op(input: input::EmptyStructWithContentOnWireOpInput, ctx: Context) -> output::EmptyStructWithContentOnWireOpOutput:
   43         -
        raise NotImplementedError
   44         -
   45         -
    @app.enum_query
   46         -
    def enum_query(input: input::EnumQueryInput, ctx: Context) -> output::EnumQueryOutput:
   47         -
        raise NotImplementedError
   48         -
   49         -
    @app.escaped_string_values
   50         -
    def escaped_string_values(input: input::EscapedStringValuesInput, ctx: Context) -> output::EscapedStringValuesOutput:
   51         -
        raise NotImplementedError
   52         -
   53         -
    @app.map_with_enum_key_op
   54         -
    def map_with_enum_key_op(input: input::MapWithEnumKeyOpInput, ctx: Context) -> output::MapWithEnumKeyOpOutput:
   55         -
        raise NotImplementedError
   56         -
   57         -
    @app.null_in_non_sparse
   58         -
    def null_in_non_sparse(input: input::NullInNonSparseInput, ctx: Context) -> output::NullInNonSparseOutput:
   59         -
        raise NotImplementedError
   60         -
   61         -
    @app.primitive_int_header
   62         -
    def primitive_int_header(input: input::PrimitiveIntHeaderInput, ctx: Context) -> output::PrimitiveIntHeaderOutput:
   63         -
        raise NotImplementedError
   64         -
   65         -
    @app.primitive_int_op
   66         -
    def primitive_int_op(input: input::PrimitiveIntOpInput, ctx: Context) -> output::PrimitiveIntOpOutput:
   67         -
        raise NotImplementedError
   68         -
   69         -
    @app.query_precedence
   70         -
    def query_precedence(input: input::QueryPrecedenceInput, ctx: Context) -> output::QueryPrecedenceOutput:
   71         -
        raise NotImplementedError
   72         -
   73         -
    @app.status_response
   74         -
    def status_response(input: input::StatusResponseInput, ctx: Context) -> output::StatusResponseOutput:
   75         -
        raise NotImplementedError
   76         -
   77         -
    @app.string_payload
   78         -
    def string_payload(input: input::StringPayloadInput, ctx: Context) -> output::StringPayloadOutput:
   79         -
        raise NotImplementedError
   80         -
   81         -
    app.run()
   82         -
    ```
   83         -
   84         -
    Any of operations above can be written as well prepending the `async` keyword and
   85         -
    the Python application will automatically handle it and schedule it on the event loop for you.
   86         -
    """
   87         -
   88         -
    def case_insensitive_error_operation(self, func: typing.Union[typing.Callable[[rest_json_extras.input.CaseInsensitiveErrorOperationInput, Ctx], typing.Union[rest_json_extras.output.CaseInsensitiveErrorOperationOutput, typing.Awaitable[rest_json_extras.output.CaseInsensitiveErrorOperationOutput]]], typing.Callable[[rest_json_extras.input.CaseInsensitiveErrorOperationInput], typing.Union[rest_json_extras.output.CaseInsensitiveErrorOperationOutput, typing.Awaitable[rest_json_extras.output.CaseInsensitiveErrorOperationOutput]]]]) -> None:
   89         -
        """
   90         -
        Method to register `case_insensitive_error_operation` Python implementation inside the handlers map.
   91         -
        It can be used as a function decorator in Python.
   92         -
        """
   93         -
        ...
   94         -
   95         -
   96         -
    def context(self, context: Ctx) -> None:
   97         -
        """
   98         -
        Register a context object that will be shared between handlers.
   99         -
        """
  100         -
        ...
  101         -
  102         -
  103         -
    def empty_struct_with_content_on_wire_op(self, func: typing.Union[typing.Callable[[rest_json_extras.input.EmptyStructWithContentOnWireOpInput, Ctx], typing.Union[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput, typing.Awaitable[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput]]], typing.Callable[[rest_json_extras.input.EmptyStructWithContentOnWireOpInput], typing.Union[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput, typing.Awaitable[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput]]]]) -> None:
  104         -
        """
  105         -
        Method to register `empty_struct_with_content_on_wire_op` Python implementation inside the handlers map.
  106         -
        It can be used as a function decorator in Python.
  107         -
        """
  108         -
        ...
  109         -
  110         -
  111         -
    def enum_query(self, func: typing.Union[typing.Callable[[rest_json_extras.input.EnumQueryInput, Ctx], typing.Union[rest_json_extras.output.EnumQueryOutput, typing.Awaitable[rest_json_extras.output.EnumQueryOutput]]], typing.Callable[[rest_json_extras.input.EnumQueryInput], typing.Union[rest_json_extras.output.EnumQueryOutput, typing.Awaitable[rest_json_extras.output.EnumQueryOutput]]]]) -> None:
  112         -
        """
  113         -
        Method to register `enum_query` Python implementation inside the handlers map.
  114         -
        It can be used as a function decorator in Python.
  115         -
        """
  116         -
        ...
  117         -
  118         -
  119         -
    def escaped_string_values(self, func: typing.Union[typing.Callable[[rest_json_extras.input.EscapedStringValuesInput, Ctx], typing.Union[rest_json_extras.output.EscapedStringValuesOutput, typing.Awaitable[rest_json_extras.output.EscapedStringValuesOutput]]], typing.Callable[[rest_json_extras.input.EscapedStringValuesInput], typing.Union[rest_json_extras.output.EscapedStringValuesOutput, typing.Awaitable[rest_json_extras.output.EscapedStringValuesOutput]]]]) -> None:
  120         -
        """
  121         -
        Method to register `escaped_string_values` Python implementation inside the handlers map.
  122         -
        It can be used as a function decorator in Python.
  123         -
        """
  124         -
        ...
  125         -
  126         -
  127         -
    def map_with_enum_key_op(self, func: typing.Union[typing.Callable[[rest_json_extras.input.MapWithEnumKeyOpInput, Ctx], typing.Union[rest_json_extras.output.MapWithEnumKeyOpOutput, typing.Awaitable[rest_json_extras.output.MapWithEnumKeyOpOutput]]], typing.Callable[[rest_json_extras.input.MapWithEnumKeyOpInput], typing.Union[rest_json_extras.output.MapWithEnumKeyOpOutput, typing.Awaitable[rest_json_extras.output.MapWithEnumKeyOpOutput]]]]) -> None:
  128         -
        """
  129         -
        Method to register `map_with_enum_key_op` Python implementation inside the handlers map.
  130         -
        It can be used as a function decorator in Python.
  131         -
        """
  132         -
        ...
  133         -
  134         -
  135         -
    def middleware(self, func: typing.Callable[[rest_json_extras.middleware.Request, typing.Callable[[rest_json_extras.middleware.Request], typing.Awaitable[rest_json_extras.middleware.Response]]], typing.Awaitable[rest_json_extras.middleware.Response]]) -> None:
  136         -
        """
  137         -
        Register a Python function to be executed inside a Tower middleware layer.
  138         -
        """
  139         -
        ...
  140         -
  141         -
  142         -
    def null_in_non_sparse(self, func: typing.Union[typing.Callable[[rest_json_extras.input.NullInNonSparseInput, Ctx], typing.Union[rest_json_extras.output.NullInNonSparseOutput, typing.Awaitable[rest_json_extras.output.NullInNonSparseOutput]]], typing.Callable[[rest_json_extras.input.NullInNonSparseInput], typing.Union[rest_json_extras.output.NullInNonSparseOutput, typing.Awaitable[rest_json_extras.output.NullInNonSparseOutput]]]]) -> None:
  143         -
        """
  144         -
        Method to register `null_in_non_sparse` Python implementation inside the handlers map.
  145         -
        It can be used as a function decorator in Python.
  146         -
        """
  147         -
        ...
  148         -
  149         -
  150         -
    def primitive_int_header(self, func: typing.Union[typing.Callable[[rest_json_extras.input.PrimitiveIntHeaderInput, Ctx], typing.Union[rest_json_extras.output.PrimitiveIntHeaderOutput, typing.Awaitable[rest_json_extras.output.PrimitiveIntHeaderOutput]]], typing.Callable[[rest_json_extras.input.PrimitiveIntHeaderInput], typing.Union[rest_json_extras.output.PrimitiveIntHeaderOutput, typing.Awaitable[rest_json_extras.output.PrimitiveIntHeaderOutput]]]]) -> None:
  151         -
        """
  152         -
        Method to register `primitive_int_header` Python implementation inside the handlers map.
  153         -
        It can be used as a function decorator in Python.
  154         -
        """
  155         -
        ...
  156         -
  157         -
  158         -
    def primitive_int_op(self, func: typing.Union[typing.Callable[[rest_json_extras.input.PrimitiveIntOpInput, Ctx], typing.Union[rest_json_extras.output.PrimitiveIntOpOutput, typing.Awaitable[rest_json_extras.output.PrimitiveIntOpOutput]]], typing.Callable[[rest_json_extras.input.PrimitiveIntOpInput], typing.Union[rest_json_extras.output.PrimitiveIntOpOutput, typing.Awaitable[rest_json_extras.output.PrimitiveIntOpOutput]]]]) -> None:
  159         -
        """
  160         -
        Method to register `primitive_int_op` Python implementation inside the handlers map.
  161         -
        It can be used as a function decorator in Python.
  162         -
        """
  163         -
        ...
  164         -
  165         -
  166         -
    def query_precedence(self, func: typing.Union[typing.Callable[[rest_json_extras.input.QueryPrecedenceInput, Ctx], typing.Union[rest_json_extras.output.QueryPrecedenceOutput, typing.Awaitable[rest_json_extras.output.QueryPrecedenceOutput]]], typing.Callable[[rest_json_extras.input.QueryPrecedenceInput], typing.Union[rest_json_extras.output.QueryPrecedenceOutput, typing.Awaitable[rest_json_extras.output.QueryPrecedenceOutput]]]]) -> None:
  167         -
        """
  168         -
        Method to register `query_precedence` Python implementation inside the handlers map.
  169         -
        It can be used as a function decorator in Python.
  170         -
        """
  171         -
        ...
  172         -
  173         -
  174         -
    def run(self, address: typing.Optional[str] = ..., port: typing.Optional[int] = ..., backlog: typing.Optional[int] = ..., workers: typing.Optional[int] = ..., tls: typing.Optional[rest_json_extras.tls.TlsConfig] = ...) -> None:
  175         -
        """
  176         -
        Main entrypoint: start the server on multiple workers.
  177         -
        """
  178         -
        ...
  179         -
  180         -
  181         -
    def run_lambda(self) -> None:
  182         -
        """
  183         -
        Lambda entrypoint: start the server on Lambda.
  184         -
        """
  185         -
        ...
  186         -
  187         -
  188         -
    def start_worker(self) -> None:
  189         -
        """
  190         -
        Build the service and start a single worker.
  191         -
        """
  192         -
        ...
  193         -
  194         -
  195         -
    def status_response(self, func: typing.Union[typing.Callable[[rest_json_extras.input.StatusResponseInput, Ctx], typing.Union[rest_json_extras.output.StatusResponseOutput, typing.Awaitable[rest_json_extras.output.StatusResponseOutput]]], typing.Callable[[rest_json_extras.input.StatusResponseInput], typing.Union[rest_json_extras.output.StatusResponseOutput, typing.Awaitable[rest_json_extras.output.StatusResponseOutput]]]]) -> None:
  196         -
        """
  197         -
        Method to register `status_response` Python implementation inside the handlers map.
  198         -
        It can be used as a function decorator in Python.
  199         -
        """
  200         -
        ...
  201         -
  202         -
  203         -
    def string_payload(self, func: typing.Union[typing.Callable[[rest_json_extras.input.StringPayloadInput, Ctx], typing.Union[rest_json_extras.output.StringPayloadOutput, typing.Awaitable[rest_json_extras.output.StringPayloadOutput]]], typing.Callable[[rest_json_extras.input.StringPayloadInput], typing.Union[rest_json_extras.output.StringPayloadOutput, typing.Awaitable[rest_json_extras.output.StringPayloadOutput]]]]) -> None:
  204         -
        """
  205         -
        Method to register `string_payload` Python implementation inside the handlers map.
  206         -
        It can be used as a function decorator in Python.
  207         -
        """
  208         -
        ...
  209         -
  210         -
  211         -
    def __init__(self) -> None:
  212         -
        ...
  213         -
  214         -
  215         -
CODEGEN_VERSION: str = ...

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/aws_lambda/__init__.pyi

@@ -1,0 +143,0 @@
    1         -
import typing
    2         -
    3         -
class ClientApplication:
    4         -
    """
    5         -
    AWS Mobile SDK client fields.
    6         -
    """
    7         -
    8         -
    app_package_name: str
    9         -
    """
   10         -
    The package name for the mobile application invoking the function
   11         -
    """
   12         -
   13         -
    app_title: str
   14         -
    """
   15         -
    The app title for the mobile app as registered with AWS' mobile services.
   16         -
    """
   17         -
   18         -
    app_version_code: str
   19         -
    """
   20         -
    The app version code.
   21         -
    """
   22         -
   23         -
    app_version_name: str
   24         -
    """
   25         -
    The version name of the application as registered with AWS' mobile services.
   26         -
    """
   27         -
   28         -
    installation_id: str
   29         -
    """
   30         -
    The mobile app installation id
   31         -
    """
   32         -
   33         -
class ClientContext:
   34         -
    """
   35         -
    Client context sent by the AWS Mobile SDK.
   36         -
    """
   37         -
   38         -
    client: ClientApplication
   39         -
    """
   40         -
    Information about the mobile application invoking the function.
   41         -
    """
   42         -
   43         -
    custom: typing.Dict[str, str]
   44         -
    """
   45         -
    Custom properties attached to the mobile event context.
   46         -
    """
   47         -
   48         -
    environment: typing.Dict[str, str]
   49         -
    """
   50         -
    Environment settings from the mobile client.
   51         -
    """
   52         -
   53         -
class CognitoIdentity:
   54         -
    """
   55         -
    Cognito identity information sent with the event
   56         -
    """
   57         -
   58         -
    identity_id: str
   59         -
    """
   60         -
    The unique identity id for the Cognito credentials invoking the function.
   61         -
    """
   62         -
   63         -
    identity_pool_id: str
   64         -
    """
   65         -
    The identity pool id the caller is "registered" with.
   66         -
    """
   67         -
   68         -
class Config:
   69         -
    """
   70         -
    Configuration derived from environment variables.
   71         -
    """
   72         -
   73         -
    function_name: str
   74         -
    """
   75         -
    The name of the function.
   76         -
    """
   77         -
   78         -
    log_group: str
   79         -
    """
   80         -
    The name of the Amazon CloudWatch Logs group for the function.
   81         -
    """
   82         -
   83         -
    log_stream: str
   84         -
    """
   85         -
    The name of the Amazon CloudWatch Logs stream for the function.
   86         -
    """
   87         -
   88         -
    memory: int
   89         -
    """
   90         -
    The amount of memory available to the function in MB.
   91         -
    """
   92         -
   93         -
    version: str
   94         -
    """
   95         -
    The version of the function being executed.
   96         -
    """
   97         -
   98         -
class LambdaContext:
   99         -
    """
  100         -
    The Lambda function execution context. The values in this struct
  101         -
    are populated using the [Lambda environment variables](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)
  102         -
    and the headers returned by the poll request to the Runtime APIs.
  103         -
    """
  104         -
  105         -
    client_context: typing.Optional[ClientContext]
  106         -
    """
  107         -
    The client context object sent by the AWS mobile SDK. This field is
  108         -
    empty unless the function is invoked using an AWS mobile SDK.
  109         -
    """
  110         -
  111         -
    deadline: int
  112         -
    """
  113         -
    The execution deadline for the current invocation in milliseconds.
  114         -
    """
  115         -
  116         -
    env_config: Config
  117         -
    """
  118         -
    Lambda function configuration from the local environment variables.
  119         -
    Includes information such as the function name, memory allocation,
  120         -
    version, and log streams.
  121         -
    """
  122         -
  123         -
    identity: typing.Optional[CognitoIdentity]
  124         -
    """
  125         -
    The Cognito identity that invoked the function. This field is empty
  126         -
    unless the invocation request to the Lambda APIs was made using AWS
  127         -
    credentials issues by Amazon Cognito Identity Pools.
  128         -
    """
  129         -
  130         -
    invoked_function_arn: str
  131         -
    """
  132         -
    The ARN of the Lambda function being invoked.
  133         -
    """
  134         -
  135         -
    request_id: str
  136         -
    """
  137         -
    The AWS request ID generated by the Lambda service.
  138         -
    """
  139         -
  140         -
    xray_trace_id: typing.Optional[str]
  141         -
    """
  142         -
    The X-Ray trace ID for the current invocation.
  143         -
    """

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/error/__init__.pyi

@@ -1,0 +40,0 @@
    1         -
import rest_json_extras.model
    2         -
import typing
    3         -
    4         -
class CaseInsensitiveError(Exception):
    5         -
    message: typing.Optional[str]
    6         -
    7         -
    def __init__(self, message: typing.Optional[str] = ...) -> None:
    8         -
        ...
    9         -
   10         -
   11         -
class ExtraError(Exception):
   12         -
    def __init__(self) -> None:
   13         -
        ...
   14         -
   15         -
   16         -
class InternalServerError(Exception):
   17         -
    message: str
   18         -
   19         -
    def __init__(self, message: str) -> None:
   20         -
        ...
   21         -
   22         -
   23         -
class ValidationException(Exception):
   24         -
    """
   25         -
    A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
   26         -
    """
   27         -
   28         -
    field_list: typing.Optional[typing.List[rest_json_extras.model.ValidationExceptionField]]
   29         -
    """
   30         -
    A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
   31         -
    """
   32         -
   33         -
    message: str
   34         -
    """
   35         -
    A summary of the validation failure.
   36         -
    """
   37         -
   38         -
    def __init__(self, message: str, field_list: typing.Optional[typing.List[rest_json_extras.model.ValidationExceptionField]] = ...) -> None:
   39         -
        ...
   40         -

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/input/__init__.pyi

@@ -1,0 +73,0 @@
    1         -
import rest_json_extras.model
    2         -
import typing
    3         -
    4         -
class CaseInsensitiveErrorOperationInput:
    5         -
    def __init__(self) -> None:
    6         -
        ...
    7         -
    8         -
    9         -
class EmptyStructWithContentOnWireOpInput:
   10         -
    def __init__(self) -> None:
   11         -
        ...
   12         -
   13         -
   14         -
class EnumQueryInput:
   15         -
    enum: rest_json_extras.model.StringEnum
   16         -
   17         -
    def __init__(self, r#enum: rest_json_extras.model.StringEnum) -> None:
   18         -
        ...
   19         -
   20         -
   21         -
class EscapedStringValuesInput:
   22         -
    enum: typing.Optional[rest_json_extras.model.EnumWithEscapedChars]
   23         -
   24         -
    some_string: typing.Optional[str]
   25         -
   26         -
    def __init__(self, r#enum: typing.Optional[rest_json_extras.model.EnumWithEscapedChars] = ..., some_string: typing.Optional[str] = ...) -> None:
   27         -
        ...
   28         -
   29         -
   30         -
class MapWithEnumKeyOpInput:
   31         -
    map: typing.Optional[typing.Dict[rest_json_extras.model.StringEnum, str]]
   32         -
   33         -
    def __init__(self, map: typing.Optional[typing.Dict[rest_json_extras.model.StringEnum, str]] = ...) -> None:
   34         -
        ...
   35         -
   36         -
   37         -
class NullInNonSparseInput:
   38         -
    def __init__(self) -> None:
   39         -
        ...
   40         -
   41         -
   42         -
class PrimitiveIntHeaderInput:
   43         -
    def __init__(self) -> None:
   44         -
        ...
   45         -
   46         -
   47         -
class PrimitiveIntOpInput:
   48         -
    value: int
   49         -
   50         -
    def __init__(self, value: int) -> None:
   51         -
        ...
   52         -
   53         -
   54         -
class QueryPrecedenceInput:
   55         -
    baz: typing.Optional[typing.Dict[str, str]]
   56         -
   57         -
    foo: typing.Optional[str]
   58         -
   59         -
    def __init__(self, foo: typing.Optional[str] = ..., baz: typing.Optional[typing.Dict[str, str]] = ...) -> None:
   60         -
        ...
   61         -
   62         -
   63         -
class StatusResponseInput:
   64         -
    def __init__(self) -> None:
   65         -
        ...
   66         -
   67         -
   68         -
class StringPayloadInput:
   69         -
    payload: typing.Optional[str]
   70         -
   71         -
    def __init__(self, payload: typing.Optional[str] = ...) -> None:
   72         -
        ...
   73         -

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/logging/__init__.pyi

@@ -1,0 +26,0 @@
    1         -
import pathlib
    2         -
import typing
    3         -
    4         -
class TracingHandler:
    5         -
    """
    6         -
    Modifies the Python `logging` module to deliver its log messages using [tracing::Subscriber] events.
    7         -
    8         -
    To achieve this goal, the following changes are made to the module:
    9         -
    - A new builtin function `logging.py_tracing_event` transcodes `logging.LogRecord`s to `tracing::Event`s. This function
   10         -
      is not exported in `logging.__all__`, as it is not intended to be called directly.
   11         -
    - A new class `logging.TracingHandler` provides a `logging.Handler` that delivers all records to `python_tracing`.
   12         -
    """
   13         -
   14         -
    def handler(self) -> typing.Any:
   15         -
        ...
   16         -
   17         -
   18         -
    def __init__(self, level: typing.Optional[int] = ..., logfile: typing.Optional[pathlib.Path] = ..., format: typing.Optional[typing.Literal['compact', 'pretty', 'json']] = ...) -> None:
   19         -
        ...
   20         -
   21         -
   22         -
def py_tracing_event() -> None:
   23         -
    """
   24         -
    Consumes a Python `logging.LogRecord` and emits a Rust [tracing::Event] instead.
   25         -
    """
   26         -
    ...

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/middleware/__init__.pyi

@@ -1,0 +78,0 @@
    1         -
import typing
    2         -
    3         -
class MiddlewareException(Exception):
    4         -
    """
    5         -
    Exception that can be thrown from a Python middleware.
    6         -
    7         -
    It allows to specify a message and HTTP status code and implementing protocol specific capabilities
    8         -
    to build a [aws_smithy_http_server::response::Response] from it.
    9         -
    """
   10         -
   11         -
    message: str
   12         -
   13         -
    status_code: int
   14         -
   15         -
    def __init__(self, message: str, status_code: typing.Optional[int] = ...) -> None:
   16         -
        ...
   17         -
   18         -
   19         -
class Request:
   20         -
    """
   21         -
    Python-compatible [Request] object.
   22         -
    """
   23         -
   24         -
    body: typing.Awaitable[bytes]
   25         -
    """
   26         -
    Return the HTTP body of this request.
   27         -
    Note that this is a costly operation because the whole request body is cloned.
   28         -
    """
   29         -
   30         -
    headers: typing.MutableMapping[str, str]
   31         -
    """
   32         -
    Return the HTTP headers of this request.
   33         -
    """
   34         -
   35         -
    method: str
   36         -
    """
   37         -
    Return the HTTP method of this request.
   38         -
    """
   39         -
   40         -
    uri: str
   41         -
    """
   42         -
    Return the URI of this request.
   43         -
    """
   44         -
   45         -
    version: str
   46         -
    """
   47         -
    Return the HTTP version of this request.
   48         -
    """
   49         -
   50         -
class Response:
   51         -
    """
   52         -
    Python-compatible [Response] object.
   53         -
    """
   54         -
   55         -
    body: typing.Awaitable[bytes]
   56         -
    """
   57         -
    Return the HTTP body of this response.
   58         -
    Note that this is a costly operation because the whole response body is cloned.
   59         -
    """
   60         -
   61         -
    headers: typing.MutableMapping[str, str]
   62         -
    """
   63         -
    Return the HTTP headers of this response.
   64         -
    """
   65         -
   66         -
    status: int
   67         -
    """
   68         -
    Return the HTTP status of this response.
   69         -
    """
   70         -
   71         -
    version: str
   72         -
    """
   73         -
    Return the HTTP version of this response.
   74         -
    """
   75         -
   76         -
    def __init__(self, status: int, headers: typing.Optional[typing.Dict[str, str]] = ..., body: typing.Optional[bytes] = ...) -> None:
   77         -
        ...
   78         -

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/model/__init__.pyi

@@ -1,0 +64,0 @@
    1         -
import typing
    2         -
    3         -
class EmptyStruct:
    4         -
    def __init__(self) -> None:
    5         -
        ...
    6         -
    7         -
    8         -
class EnumWithEscapedChars:
    9         -
    HasQuotes: EnumWithEscapedChars
   10         -
   11         -
    Normal: EnumWithEscapedChars
   12         -
   13         -
    name: typing.Any
   14         -
   15         -
    value: typing.Any
   16         -
   17         -
class SingleElementUnion:
   18         -
    @staticmethod
   19         -
    def a(data: str) -> SingleElementUnion:
   20         -
        """
   21         -
        Creates a new union instance of [`A`](crate::model::SingleElementUnion::A)
   22         -
        """
   23         -
        ...
   24         -
   25         -
   26         -
    def as_a(self) -> str:
   27         -
        """
   28         -
        Tries to convert the enum instance into [`A`](crate::model::SingleElementUnion::A), extracting the inner [`String`](::std::string::String).
   29         -
        """
   30         -
        ...
   31         -
   32         -
   33         -
    def is_a(self) -> bool:
   34         -
        """
   35         -
        Returns true if this is a [`A`](crate::model::SingleElementUnion::A).
   36         -
        """
   37         -
        ...
   38         -
   39         -
   40         -
class StringEnum:
   41         -
    V: StringEnum
   42         -
   43         -
    name: typing.Any
   44         -
   45         -
    value: typing.Any
   46         -
   47         -
class ValidationExceptionField:
   48         -
    """
   49         -
    Describes one specific validation failure for an input member.
   50         -
    """
   51         -
   52         -
    message: str
   53         -
    """
   54         -
    A detailed description of the validation failure.
   55         -
    """
   56         -
   57         -
    path: str
   58         -
    """
   59         -
    A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
   60         -
    """
   61         -
   62         -
    def __init__(self, path: str, message: str) -> None:
   63         -
        ...
   64         -

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/python/rest_json_extras/output/__init__.pyi

@@ -1,0 +79,0 @@
    1         -
import rest_json_extras.model
    2         -
import typing
    3         -
    4         -
class CaseInsensitiveErrorOperationOutput:
    5         -
    def __init__(self) -> None:
    6         -
        ...
    7         -
    8         -
    9         -
class EmptyStructWithContentOnWireOpOutput:
   10         -
    empty: typing.Optional[rest_json_extras.model.EmptyStruct]
   11         -
   12         -
    def __init__(self, empty: typing.Optional[rest_json_extras.model.EmptyStruct] = ...) -> None:
   13         -
        ...
   14         -
   15         -
   16         -
class EnumQueryOutput:
   17         -
    def __init__(self) -> None:
   18         -
        ...
   19         -
   20         -
   21         -
class EscapedStringValuesOutput:
   22         -
    enum: typing.Optional[rest_json_extras.model.EnumWithEscapedChars]
   23         -
   24         -
    some_string: typing.Optional[str]
   25         -
   26         -
    def __init__(self, r#enum: typing.Optional[rest_json_extras.model.EnumWithEscapedChars] = ..., some_string: typing.Optional[str] = ...) -> None:
   27         -
        ...
   28         -
   29         -
   30         -
class MapWithEnumKeyOpOutput:
   31         -
    map: typing.Optional[typing.Dict[rest_json_extras.model.StringEnum, str]]
   32         -
   33         -
    def __init__(self, map: typing.Optional[typing.Dict[rest_json_extras.model.StringEnum, str]] = ...) -> None:
   34         -
        ...
   35         -
   36         -
   37         -
class NullInNonSparseOutput:
   38         -
    list: typing.Optional[typing.List[str]]
   39         -
   40         -
    map: typing.Optional[typing.Dict[str, str]]
   41         -
   42         -
    union: typing.Optional[rest_json_extras.model.SingleElementUnion]
   43         -
   44         -
    def __init__(self, list: typing.Optional[typing.List[str]] = ..., map: typing.Optional[typing.Dict[str, str]] = ..., union: typing.Optional[rest_json_extras.model.SingleElementUnion] = ...) -> None:
   45         -
        ...
   46         -
   47         -
   48         -
class PrimitiveIntHeaderOutput:
   49         -
    field: int
   50         -
   51         -
    def __init__(self, field: int) -> None:
   52         -
        ...
   53         -
   54         -
   55         -
class PrimitiveIntOpOutput:
   56         -
    value: int
   57         -
   58         -
    def __init__(self, value: int) -> None:
   59         -
        ...
   60         -
   61         -
   62         -
class QueryPrecedenceOutput:
   63         -
    def __init__(self) -> None:
   64         -
        ...
   65         -
   66         -
   67         -
class StatusResponseOutput:
   68         -
    field: int
   69         -
   70         -
    def __init__(self, field: int) -> None:
   71         -
        ...
   72         -
   73         -
   74         -
class StringPayloadOutput:
   75         -
    payload: typing.Optional[str]
   76         -
   77         -
    def __init__(self, payload: typing.Optional[str] = ...) -> None:
   78         -
        ...
   79         -