Server Test Python

Server Test Python

rev. 399187927edd9a1e762efeae060e3a56d671920a (ignoring whitespace)

Files changed:

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

@@ -1,0 +170,0 @@
    1         -
import json_rpc10.model
    2         -
import json_rpc10.types
    3         -
import typing
    4         -
    5         -
class ContentTypeParametersOutput:
    6         -
    def __init__(self) -> None:
    7         -
        ...
    8         -
    9         -
   10         -
class EmptyInputAndEmptyOutputOutput:
   11         -
    def __init__(self) -> None:
   12         -
        ...
   13         -
   14         -
   15         -
class EndpointOperationOutput:
   16         -
    def __init__(self) -> None:
   17         -
        ...
   18         -
   19         -
   20         -
class EndpointWithHostLabelOperationOutput:
   21         -
    def __init__(self) -> None:
   22         -
        ...
   23         -
   24         -
   25         -
class GreetingWithErrorsOutput:
   26         -
    greeting: typing.Optional[str]
   27         -
   28         -
    def __init__(self, greeting: typing.Optional[str] = ...) -> None:
   29         -
        ...
   30         -
   31         -
   32         -
class HostWithPathOperationOutput:
   33         -
    def __init__(self) -> None:
   34         -
        ...
   35         -
   36         -
   37         -
class JsonUnionsOutput:
   38         -
    contents: typing.Optional[json_rpc10.model.MyUnion]
   39         -
    """
   40         -
    A union with a representative set of types for members.
   41         -
    """
   42         -
   43         -
    def __init__(self, contents: typing.Optional[json_rpc10.model.MyUnion] = ...) -> None:
   44         -
        ...
   45         -
   46         -
   47         -
class NoInputAndNoOutputOutput:
   48         -
    def __init__(self) -> None:
   49         -
        ...
   50         -
   51         -
   52         -
class NoInputAndOutputOutput:
   53         -
    def __init__(self) -> None:
   54         -
        ...
   55         -
   56         -
   57         -
class OperationWithDefaultsOutput:
   58         -
    default_blob: json_rpc10.types.Blob
   59         -
   60         -
    default_boolean: bool
   61         -
   62         -
    default_byte: int
   63         -
   64         -
    default_document_boolean: json_rpc10.types.Document
   65         -
   66         -
    default_document_list: json_rpc10.types.Document
   67         -
   68         -
    default_document_map: json_rpc10.types.Document
   69         -
   70         -
    default_document_string: json_rpc10.types.Document
   71         -
   72         -
    default_double: float
   73         -
   74         -
    default_enum: json_rpc10.model.TestEnum
   75         -
   76         -
    default_float: float
   77         -
   78         -
    default_int_enum: int
   79         -
   80         -
    default_integer: int
   81         -
   82         -
    default_list: typing.List[str]
   83         -
   84         -
    default_long: int
   85         -
   86         -
    default_map: typing.Dict[str, str]
   87         -
   88         -
    default_null_document: typing.Optional[json_rpc10.types.Document]
   89         -
   90         -
    default_short: int
   91         -
   92         -
    default_string: str
   93         -
   94         -
    default_timestamp: json_rpc10.types.DateTime
   95         -
   96         -
    empty_blob: json_rpc10.types.Blob
   97         -
   98         -
    empty_string: str
   99         -
  100         -
    false_boolean: bool
  101         -
  102         -
    zero_byte: int
  103         -
  104         -
    zero_double: float
  105         -
  106         -
    zero_float: float
  107         -
  108         -
    zero_integer: int
  109         -
  110         -
    zero_long: int
  111         -
  112         -
    zero_short: int
  113         -
  114         -
    def __init__(self, default_string: str, default_boolean: bool, default_list: typing.List[str], default_document_map: json_rpc10.types.Document, default_document_string: json_rpc10.types.Document, default_document_boolean: json_rpc10.types.Document, default_document_list: json_rpc10.types.Document, default_null_document: typing.Optional[json_rpc10.types.Document] = ..., default_timestamp: json_rpc10.types.DateTime, default_blob: json_rpc10.types.Blob, default_byte: int, default_short: int, default_integer: int, default_long: int, default_float: float, default_double: float, default_map: typing.Dict[str, str], default_enum: json_rpc10.model.TestEnum, default_int_enum: int, empty_string: str, false_boolean: bool, empty_blob: json_rpc10.types.Blob, zero_byte: int, zero_short: int, zero_integer: int, zero_long: int, zero_float: float, zero_double: float) -> None:
  115         -
        ...
  116         -
  117         -
  118         -
class OperationWithNestedStructureOutput:
  119         -
    dialog: json_rpc10.model.Dialog
  120         -
  121         -
    dialog_list: typing.List[json_rpc10.model.Dialog]
  122         -
  123         -
    dialog_map: typing.Dict[str, json_rpc10.model.Dialog]
  124         -
  125         -
    def __init__(self, dialog: json_rpc10.model.Dialog, dialog_list: typing.List[json_rpc10.model.Dialog], dialog_map: typing.Dict[str, json_rpc10.model.Dialog]) -> None:
  126         -
        ...
  127         -
  128         -
  129         -
class OperationWithRequiredMembersOutput:
  130         -
    required_blob: json_rpc10.types.Blob
  131         -
  132         -
    required_boolean: bool
  133         -
  134         -
    required_byte: int
  135         -
  136         -
    required_double: float
  137         -
  138         -
    required_float: float
  139         -
  140         -
    required_integer: int
  141         -
  142         -
    required_list: typing.List[str]
  143         -
  144         -
    required_long: int
  145         -
  146         -
    required_map: typing.Dict[str, str]
  147         -
  148         -
    required_short: int
  149         -
  150         -
    required_string: str
  151         -
  152         -
    required_timestamp: json_rpc10.types.DateTime
  153         -
  154         -
    def __init__(self, required_string: str, required_boolean: bool, required_list: typing.List[str], required_timestamp: json_rpc10.types.DateTime, required_blob: json_rpc10.types.Blob, required_byte: int, required_short: int, required_integer: int, required_long: int, required_float: float, required_double: float, required_map: typing.Dict[str, str]) -> None:
  155         -
        ...
  156         -
  157         -
  158         -
class PutWithContentEncodingOutput:
  159         -
    def __init__(self) -> None:
  160         -
        ...
  161         -
  162         -
  163         -
class SimpleScalarPropertiesOutput:
  164         -
    double_value: typing.Optional[float]
  165         -
  166         -
    float_value: typing.Optional[float]
  167         -
  168         -
    def __init__(self, float_value: typing.Optional[float] = ..., double_value: typing.Optional[float] = ...) -> None:
  169         -
        ...
  170         -

tmp-codegen-diff/codegen-server-test-python/json_rpc10/rust-server-codegen-python/python/json_rpc10/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/json_rpc10/rust-server-codegen-python/python/json_rpc10/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/json_rpc10/rust-server-codegen-python/python/json_rpc10/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/json_rpc10/rust-server-codegen-python/src/model.rs

@@ -1796,1796 +1863,1857 @@
 1816   1816   
        /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if a [`ConstraintViolation`] occurs.
 1817   1817   
        ///
 1818   1818   
        pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
 1819   1819   
            self.build_enforcing_all_constraints()
 1820   1820   
        }
 1821   1821   
        fn build_enforcing_all_constraints(
 1822   1822   
            self,
 1823   1823   
        ) -> Result<crate::model::TopLevel, ConstraintViolation> {
 1824   1824   
            Ok(crate::model::TopLevel {
 1825   1825   
                dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
 1826         -
                dialog_list: self.dialog_list.unwrap_or_else(
 1827         -
                    #[allow(clippy::redundant_closure)]
 1828         -
                    || ::std::vec::Vec::new(),
 1829         -
                ),
 1830         -
                dialog_map: self.dialog_map.unwrap_or_else(
 1831         -
                    #[allow(clippy::redundant_closure)]
 1832         -
                    || ::std::collections::HashMap::new(),
 1833         -
                ),
        1826  +
                dialog_list: self.dialog_list.unwrap_or_default(),
        1827  +
                dialog_map: self.dialog_map.unwrap_or_default(),
 1834   1828   
            })
 1835   1829   
        }
 1836   1830   
    }
 1837   1831   
}
 1838   1832   
/// See [`TopLevel`](crate::model::TopLevel).
 1839   1833   
pub mod top_level {
 1840   1834   
 1841   1835   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
 1842   1836   
    /// Holds one variant for each of the ways the builder can fail.
 1843   1837   
@@ -1877,1871 +1944,1932 @@
 1897   1891   
        /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if you do not provide a value for all non-`Option`al members.
 1898   1892   
        ///
 1899   1893   
        pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
 1900   1894   
            self.build_enforcing_required_and_enum_traits()
 1901   1895   
        }
 1902   1896   
        fn build_enforcing_required_and_enum_traits(
 1903   1897   
            self,
 1904   1898   
        ) -> Result<crate::model::TopLevel, ConstraintViolation> {
 1905   1899   
            Ok(crate::model::TopLevel {
 1906   1900   
                dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
 1907         -
                dialog_list: self.dialog_list.unwrap_or_else(
 1908         -
                    #[allow(clippy::redundant_closure)]
 1909         -
                    || ::std::vec::Vec::new(),
 1910         -
                ),
 1911         -
                dialog_map: self.dialog_map.unwrap_or_else(
 1912         -
                    #[allow(clippy::redundant_closure)]
 1913         -
                    || ::std::collections::HashMap::new(),
 1914         -
                ),
        1901  +
                dialog_list: self.dialog_list.unwrap_or_default(),
        1902  +
                dialog_map: self.dialog_map.unwrap_or_default(),
 1915   1903   
            })
 1916   1904   
        }
 1917   1905   
    }
 1918   1906   
}
 1919   1907   
/// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
 1920   1908   
pub(crate) mod client_optional_defaults_internal {
 1921   1909   
 1922   1910   
    impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
 1923   1911   
        fn from(builder: Builder) -> Self {
 1924   1912   
            builder.build()
@@ -2245,2233 +2348,2330 @@
 2265   2253   
        }
 2266   2254   
        fn build_enforcing_all_constraints(
 2267   2255   
            self,
 2268   2256   
        ) -> Result<crate::model::Defaults, ConstraintViolation> {
 2269   2257   
            Ok(crate::model::Defaults {
 2270   2258   
                default_string: self.default_string.unwrap_or_else(
 2271   2259   
                    #[allow(clippy::redundant_closure)]
 2272   2260   
                    || String::from("hi"),
 2273   2261   
                ),
 2274   2262   
                default_boolean: self.default_boolean.unwrap_or(true),
 2275         -
                default_list: self.default_list.unwrap_or_else(
 2276         -
                    #[allow(clippy::redundant_closure)]
 2277         -
                    || ::std::vec::Vec::new(),
 2278         -
                ),
        2263  +
                default_list: self.default_list.unwrap_or_default(),
 2279   2264   
                default_document_map: self.default_document_map.unwrap_or_else(
 2280   2265   
                    #[allow(clippy::redundant_closure)]
 2281   2266   
                    || {
 2282   2267   
                        ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
 2283   2268   
                            .into()
 2284   2269   
                    },
 2285   2270   
                ),
 2286   2271   
                default_document_string: self.default_document_string.unwrap_or_else(
 2287   2272   
                    #[allow(clippy::redundant_closure)]
 2288   2273   
                    || {
 2289   2274   
                        ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
 2290   2275   
                            .into()
 2291   2276   
                    },
 2292   2277   
                ),
 2293   2278   
                default_document_boolean: self
 2294   2279   
                    .default_document_boolean
 2295   2280   
                    .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
 2296   2281   
                default_document_list: self.default_document_list.unwrap_or_else(
 2297   2282   
                    #[allow(clippy::redundant_closure)]
 2298   2283   
                    || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
 2299   2284   
                ),
 2300   2285   
                default_null_document: self.default_null_document,
 2301   2286   
                default_timestamp: self.default_timestamp.unwrap_or_else(
 2302   2287   
                    #[allow(clippy::redundant_closure)]
 2303   2288   
                    || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
 2304   2289   
                ),
 2305   2290   
                default_blob: self.default_blob.unwrap_or_else(
 2306   2291   
                    #[allow(clippy::redundant_closure)]
 2307   2292   
                    || ::aws_smithy_types::Blob::new("abc").into(),
 2308   2293   
                ),
 2309   2294   
                default_byte: self.default_byte.unwrap_or(1i8),
 2310   2295   
                default_short: self.default_short.unwrap_or(1i16),
 2311   2296   
                default_integer: self.default_integer.unwrap_or(10i32),
 2312   2297   
                default_long: self.default_long.unwrap_or(100i64),
 2313   2298   
                default_float: self.default_float.unwrap_or(1.0f32),
 2314   2299   
                default_double: self.default_double.unwrap_or(1.0f64),
 2315         -
                default_map: self.default_map.unwrap_or_else(
 2316         -
                    #[allow(clippy::redundant_closure)]
 2317         -
                    || ::std::collections::HashMap::new(),
 2318         -
                ),
        2300  +
                default_map: self.default_map.unwrap_or_default(),
 2319   2301   
                default_enum: self
 2320   2302   
                    .default_enum
 2321   2303   
                    .map(|v| match v {
 2322   2304   
                        crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
 2323   2305   
                        crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
 2324   2306   
                    })
 2325   2307   
                    .map(|res| res.map_err(ConstraintViolation::DefaultEnum))
 2326   2308   
                    .transpose()?
 2327   2309   
                    .unwrap_or(
 2328   2310   
                        "FOO"
@@ -2544,2526 +2647,2623 @@
 2564   2546   
        pub fn build(self) -> crate::model::Defaults {
 2565   2547   
            self.build_enforcing_required_and_enum_traits()
 2566   2548   
        }
 2567   2549   
        fn build_enforcing_required_and_enum_traits(self) -> crate::model::Defaults {
 2568   2550   
            crate::model::Defaults {
 2569   2551   
                default_string: self.default_string.unwrap_or_else(
 2570   2552   
                    #[allow(clippy::redundant_closure)]
 2571   2553   
                    || String::from("hi"),
 2572   2554   
                ),
 2573   2555   
                default_boolean: self.default_boolean.unwrap_or(true),
 2574         -
                default_list: self.default_list.unwrap_or_else(
 2575         -
                    #[allow(clippy::redundant_closure)]
 2576         -
                    || ::std::vec::Vec::new(),
 2577         -
                ),
        2556  +
                default_list: self.default_list.unwrap_or_default(),
 2578   2557   
                default_document_map: self.default_document_map.unwrap_or_else(
 2579   2558   
                    #[allow(clippy::redundant_closure)]
 2580   2559   
                    || {
 2581   2560   
                        ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
 2582   2561   
                            .into()
 2583   2562   
                    },
 2584   2563   
                ),
 2585   2564   
                default_document_string: self.default_document_string.unwrap_or_else(
 2586   2565   
                    #[allow(clippy::redundant_closure)]
 2587   2566   
                    || {
 2588   2567   
                        ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
 2589   2568   
                            .into()
 2590   2569   
                    },
 2591   2570   
                ),
 2592   2571   
                default_document_boolean: self
 2593   2572   
                    .default_document_boolean
 2594   2573   
                    .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
 2595   2574   
                default_document_list: self.default_document_list.unwrap_or_else(
 2596   2575   
                    #[allow(clippy::redundant_closure)]
 2597   2576   
                    || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
 2598   2577   
                ),
 2599   2578   
                default_null_document: self.default_null_document,
 2600   2579   
                default_timestamp: self.default_timestamp.unwrap_or_else(
 2601   2580   
                    #[allow(clippy::redundant_closure)]
 2602   2581   
                    || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
 2603   2582   
                ),
 2604   2583   
                default_blob: self.default_blob.unwrap_or_else(
 2605   2584   
                    #[allow(clippy::redundant_closure)]
 2606   2585   
                    || ::aws_smithy_types::Blob::new("abc").into(),
 2607   2586   
                ),
 2608   2587   
                default_byte: self.default_byte.unwrap_or(1i8),
 2609   2588   
                default_short: self.default_short.unwrap_or(1i16),
 2610   2589   
                default_integer: self.default_integer.unwrap_or(10i32),
 2611   2590   
                default_long: self.default_long.unwrap_or(100i64),
 2612   2591   
                default_float: self.default_float.unwrap_or(1.0f32),
 2613   2592   
                default_double: self.default_double.unwrap_or(1.0f64),
 2614         -
                default_map: self.default_map.unwrap_or_else(
 2615         -
                    #[allow(clippy::redundant_closure)]
 2616         -
                    || ::std::collections::HashMap::new(),
 2617         -
                ),
        2593  +
                default_map: self.default_map.unwrap_or_default(),
 2618   2594   
                default_enum: self.default_enum.unwrap_or(
 2619   2595   
                    "FOO"
 2620   2596   
                        .parse::<crate::model::TestEnum>()
 2621   2597   
                        .expect("static value validated to member"),
 2622   2598   
                ),
 2623   2599   
                default_int_enum: self.default_int_enum.unwrap_or(1i32),
 2624   2600   
                empty_string: self.empty_string.unwrap_or_else(
 2625   2601   
                    #[allow(clippy::redundant_closure)]
 2626   2602   
                    || String::from(""),
 2627   2603   
                ),

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

@@ -1156,1156 +1223,1217 @@
 1176   1176   
        ) -> Result<crate::output::OperationWithNestedStructureOutput, ConstraintViolation>
 1177   1177   
        {
 1178   1178   
            self.build_enforcing_required_and_enum_traits()
 1179   1179   
        }
 1180   1180   
        fn build_enforcing_required_and_enum_traits(
 1181   1181   
            self,
 1182   1182   
        ) -> Result<crate::output::OperationWithNestedStructureOutput, ConstraintViolation>
 1183   1183   
        {
 1184   1184   
            Ok(crate::output::OperationWithNestedStructureOutput {
 1185   1185   
                dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
 1186         -
                dialog_list: self.dialog_list.unwrap_or_else(
 1187         -
                    #[allow(clippy::redundant_closure)]
 1188         -
                    || ::std::vec::Vec::new(),
 1189         -
                ),
 1190         -
                dialog_map: self.dialog_map.unwrap_or_else(
 1191         -
                    #[allow(clippy::redundant_closure)]
 1192         -
                    || ::std::collections::HashMap::new(),
 1193         -
                ),
        1186  +
                dialog_list: self.dialog_list.unwrap_or_default(),
        1187  +
                dialog_map: self.dialog_map.unwrap_or_default(),
 1194   1188   
            })
 1195   1189   
        }
 1196   1190   
    }
 1197   1191   
}
 1198   1192   
/// See [`OperationWithRequiredMembersOutput`](crate::output::OperationWithRequiredMembersOutput).
 1199   1193   
pub mod operation_with_required_members_output {
 1200   1194   
 1201   1195   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
 1202   1196   
    /// Holds one variant for each of the ways the builder can fail.
 1203   1197   
@@ -1596,1590 +1699,1687 @@
 1616   1610   
        }
 1617   1611   
        fn build_enforcing_required_and_enum_traits(
 1618   1612   
            self,
 1619   1613   
        ) -> crate::output::OperationWithDefaultsOutput {
 1620   1614   
            crate::output::OperationWithDefaultsOutput {
 1621   1615   
                default_string: self.default_string.unwrap_or_else(
 1622   1616   
                    #[allow(clippy::redundant_closure)]
 1623   1617   
                    || String::from("hi"),
 1624   1618   
                ),
 1625   1619   
                default_boolean: self.default_boolean.unwrap_or(true),
 1626         -
                default_list: self.default_list.unwrap_or_else(
 1627         -
                    #[allow(clippy::redundant_closure)]
 1628         -
                    || ::std::vec::Vec::new(),
 1629         -
                ),
        1620  +
                default_list: self.default_list.unwrap_or_default(),
 1630   1621   
                default_document_map: self.default_document_map.unwrap_or_else(
 1631   1622   
                    #[allow(clippy::redundant_closure)]
 1632   1623   
                    || {
 1633   1624   
                        ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
 1634   1625   
                            .into()
 1635   1626   
                    },
 1636   1627   
                ),
 1637   1628   
                default_document_string: self.default_document_string.unwrap_or_else(
 1638   1629   
                    #[allow(clippy::redundant_closure)]
 1639   1630   
                    || {
 1640   1631   
                        ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
 1641   1632   
                            .into()
 1642   1633   
                    },
 1643   1634   
                ),
 1644   1635   
                default_document_boolean: self
 1645   1636   
                    .default_document_boolean
 1646   1637   
                    .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
 1647   1638   
                default_document_list: self.default_document_list.unwrap_or_else(
 1648   1639   
                    #[allow(clippy::redundant_closure)]
 1649   1640   
                    || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
 1650   1641   
                ),
 1651   1642   
                default_null_document: self.default_null_document,
 1652   1643   
                default_timestamp: self.default_timestamp.unwrap_or_else(
 1653   1644   
                    #[allow(clippy::redundant_closure)]
 1654   1645   
                    || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
 1655   1646   
                ),
 1656   1647   
                default_blob: self.default_blob.unwrap_or_else(
 1657   1648   
                    #[allow(clippy::redundant_closure)]
 1658   1649   
                    || ::aws_smithy_types::Blob::new("abc").into(),
 1659   1650   
                ),
 1660   1651   
                default_byte: self.default_byte.unwrap_or(1i8),
 1661   1652   
                default_short: self.default_short.unwrap_or(1i16),
 1662   1653   
                default_integer: self.default_integer.unwrap_or(10i32),
 1663   1654   
                default_long: self.default_long.unwrap_or(100i64),
 1664   1655   
                default_float: self.default_float.unwrap_or(1.0f32),
 1665   1656   
                default_double: self.default_double.unwrap_or(1.0f64),
 1666         -
                default_map: self.default_map.unwrap_or_else(
 1667         -
                    #[allow(clippy::redundant_closure)]
 1668         -
                    || ::std::collections::HashMap::new(),
 1669         -
                ),
        1657  +
                default_map: self.default_map.unwrap_or_default(),
 1670   1658   
                default_enum: self.default_enum.unwrap_or(
 1671   1659   
                    "FOO"
 1672   1660   
                        .parse::<crate::model::TestEnum>()
 1673   1661   
                        .expect("static value validated to member"),
 1674   1662   
                ),
 1675   1663   
                default_int_enum: self.default_int_enum.unwrap_or(1i32),
 1676   1664   
                empty_string: self.empty_string.unwrap_or_else(
 1677   1665   
                    #[allow(clippy::redundant_closure)]
 1678   1666   
                    || String::from(""),
 1679   1667   
                ),

tmp-codegen-diff/codegen-server-test-python/json_rpc11/rust-server-codegen-python/Cargo.toml

@@ -8,8 +60,60 @@
   28     28   
version = "0.14.26"
   29     29   
[dependencies.mime]
   30     30   
version = "0.3"
   31     31   
[dependencies.once_cell]
   32     32   
version = "1.16"
   33     33   
[dependencies.parking_lot]
   34     34   
version = "0.12"
   35     35   
[dependencies.pin-project-lite]
   36     36   
version = "0.2"
   37     37   
[dependencies.pyo3]
   38         -
version = "0.18"
          38  +
version = "0.20"
   39     39   
[dependencies.pyo3-asyncio]
   40         -
version = "0.18"
          40  +
version = "0.20"
   41     41   
features = ["attributes", "tokio-runtime"]
   42     42   
[dependencies.tower]
   43     43   
version = "0.4"
   44     44   
[dependencies.tracing]
   45     45   
version = "0.1"
   46     46   
[dev-dependencies.hyper]
   47     47   
version = "0.14.12"
   48     48   
[dev-dependencies.tokio]
   49     49   
version = "1.23.1"
   50     50   
[features]

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

@@ -1,0 +300,0 @@
    1         -
import json_rpc11.input
    2         -
import json_rpc11.middleware
    3         -
import json_rpc11.output
    4         -
import json_rpc11.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 json_rpc11 import input
   20         -
    from json_rpc11 import output
   21         -
    from json_rpc11 import error
   22         -
    from json_rpc11 import middleware
   23         -
    from json_rpc11 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         -
    # The example tests how servers must support requests
   38         -
    # containing a `Content-Type` header with parameters.
   39         -
    @app.content_type_parameters
   40         -
    def content_type_parameters(input: input::ContentTypeParametersInput, ctx: Context) -> output::ContentTypeParametersOutput:
   41         -
        raise NotImplementedError
   42         -
   43         -
    @app.datetime_offsets
   44         -
    def datetime_offsets(input: input::DatetimeOffsetsInput, ctx: Context) -> output::DatetimeOffsetsOutput:
   45         -
        raise NotImplementedError
   46         -
   47         -
    @app.empty_operation
   48         -
    def empty_operation(input: input::EmptyOperationInput, ctx: Context) -> output::EmptyOperationOutput:
   49         -
        raise NotImplementedError
   50         -
   51         -
    @app.endpoint_operation
   52         -
    def endpoint_operation(input: input::EndpointOperationInput, ctx: Context) -> output::EndpointOperationOutput:
   53         -
        raise NotImplementedError
   54         -
   55         -
    @app.endpoint_with_host_label_operation
   56         -
    def endpoint_with_host_label_operation(input: input::EndpointWithHostLabelOperationInput, ctx: Context) -> output::EndpointWithHostLabelOperationOutput:
   57         -
        raise NotImplementedError
   58         -
   59         -
    @app.fractional_seconds
   60         -
    def fractional_seconds(input: input::FractionalSecondsInput, ctx: Context) -> output::FractionalSecondsOutput:
   61         -
        raise NotImplementedError
   62         -
   63         -
    # This operation has three possible return values:
   64         -
    #
   65         -
    # 1. A successful response in the form of GreetingWithErrorsOutput
   66         -
    # 2. An InvalidGreeting error.
   67         -
    # 3. A ComplexError error.
   68         -
    #
   69         -
    # Implementations must be able to successfully take a response and
   70         -
    # properly deserialize successful and error responses.
   71         -
    @app.greeting_with_errors
   72         -
    def greeting_with_errors(input: input::GreetingWithErrorsInput, ctx: Context) -> output::GreetingWithErrorsOutput:
   73         -
        raise NotImplementedError
   74         -
   75         -
    @app.host_with_path_operation
   76         -
    def host_with_path_operation(input: input::HostWithPathOperationInput, ctx: Context) -> output::HostWithPathOperationOutput:
   77         -
        raise NotImplementedError
   78         -
   79         -
    # This example serializes enums as top level properties, in lists, sets, and maps.
   80         -
    @app.json_enums
   81         -
    def json_enums(input: input::JsonEnumsInput, ctx: Context) -> output::JsonEnumsOutput:
   82         -
        raise NotImplementedError
   83         -
   84         -
    # This operation uses unions for inputs and outputs.
   85         -
    @app.json_unions
   86         -
    def json_unions(input: input::JsonUnionsInput, ctx: Context) -> output::JsonUnionsOutput:
   87         -
        raise NotImplementedError
   88         -
   89         -
    @app.kitchen_sink_operation
   90         -
    def kitchen_sink_operation(input: input::KitchenSinkOperationInput, ctx: Context) -> output::KitchenSinkOperationOutput:
   91         -
        raise NotImplementedError
   92         -
   93         -
    @app.null_operation
   94         -
    def null_operation(input: input::NullOperationInput, ctx: Context) -> output::NullOperationOutput:
   95         -
        raise NotImplementedError
   96         -
   97         -
    @app.operation_with_optional_input_output
   98         -
    def operation_with_optional_input_output(input: input::OperationWithOptionalInputOutputInput, ctx: Context) -> output::OperationWithOptionalInputOutputOutput:
   99         -
        raise NotImplementedError
  100         -
  101         -
    # This example serializes an inline document as part of the payload.
  102         -
    @app.put_and_get_inline_documents
  103         -
    def put_and_get_inline_documents(input: input::PutAndGetInlineDocumentsInput, ctx: Context) -> output::PutAndGetInlineDocumentsOutput:
  104         -
        raise NotImplementedError
  105         -
  106         -
    @app.put_with_content_encoding
  107         -
    def put_with_content_encoding(input: input::PutWithContentEncodingInput, ctx: Context) -> output::PutWithContentEncodingOutput:
  108         -
        raise NotImplementedError
  109         -
  110         -
    @app.simple_scalar_properties
  111         -
    def simple_scalar_properties(input: input::SimpleScalarPropertiesInput, ctx: Context) -> output::SimpleScalarPropertiesOutput:
  112         -
        raise NotImplementedError
  113         -
  114         -
    @app.sparse_nulls_operation
  115         -
    def sparse_nulls_operation(input: input::SparseNullsOperationInput, ctx: Context) -> output::SparseNullsOperationOutput:
  116         -
        raise NotImplementedError
  117         -
  118         -
    app.run()
  119         -
    ```
  120         -
  121         -
    Any of operations above can be written as well prepending the `async` keyword and
  122         -
    the Python application will automatically handle it and schedule it on the event loop for you.
  123         -
    """
  124         -
  125         -
    def content_type_parameters(self, func: typing.Union[typing.Callable[[json_rpc11.input.ContentTypeParametersInput, Ctx], typing.Union[json_rpc11.output.ContentTypeParametersOutput, typing.Awaitable[json_rpc11.output.ContentTypeParametersOutput]]], typing.Callable[[json_rpc11.input.ContentTypeParametersInput], typing.Union[json_rpc11.output.ContentTypeParametersOutput, typing.Awaitable[json_rpc11.output.ContentTypeParametersOutput]]]]) -> None:
  126         -
        """
  127         -
        Method to register `content_type_parameters` Python implementation inside the handlers map.
  128         -
        It can be used as a function decorator in Python.
  129         -
        """
  130         -
        ...
  131         -
  132         -
  133         -
    def context(self, context: Ctx) -> None:
  134         -
        """
  135         -
        Register a context object that will be shared between handlers.
  136         -
        """
  137         -
        ...
  138         -
  139         -
  140         -
    def datetime_offsets(self, func: typing.Union[typing.Callable[[json_rpc11.input.DatetimeOffsetsInput, Ctx], typing.Union[json_rpc11.output.DatetimeOffsetsOutput, typing.Awaitable[json_rpc11.output.DatetimeOffsetsOutput]]], typing.Callable[[json_rpc11.input.DatetimeOffsetsInput], typing.Union[json_rpc11.output.DatetimeOffsetsOutput, typing.Awaitable[json_rpc11.output.DatetimeOffsetsOutput]]]]) -> None:
  141         -
        """
  142         -
        Method to register `datetime_offsets` Python implementation inside the handlers map.
  143         -
        It can be used as a function decorator in Python.
  144         -
        """
  145         -
        ...
  146         -
  147         -
  148         -
    def empty_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.EmptyOperationInput, Ctx], typing.Union[json_rpc11.output.EmptyOperationOutput, typing.Awaitable[json_rpc11.output.EmptyOperationOutput]]], typing.Callable[[json_rpc11.input.EmptyOperationInput], typing.Union[json_rpc11.output.EmptyOperationOutput, typing.Awaitable[json_rpc11.output.EmptyOperationOutput]]]]) -> None:
  149         -
        """
  150         -
        Method to register `empty_operation` Python implementation inside the handlers map.
  151         -
        It can be used as a function decorator in Python.
  152         -
        """
  153         -
        ...
  154         -
  155         -
  156         -
    def endpoint_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.EndpointOperationInput, Ctx], typing.Union[json_rpc11.output.EndpointOperationOutput, typing.Awaitable[json_rpc11.output.EndpointOperationOutput]]], typing.Callable[[json_rpc11.input.EndpointOperationInput], typing.Union[json_rpc11.output.EndpointOperationOutput, typing.Awaitable[json_rpc11.output.EndpointOperationOutput]]]]) -> None:
  157         -
        """
  158         -
        Method to register `endpoint_operation` Python implementation inside the handlers map.
  159         -
        It can be used as a function decorator in Python.
  160         -
        """
  161         -
        ...
  162         -
  163         -
  164         -
    def endpoint_with_host_label_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.EndpointWithHostLabelOperationInput, Ctx], typing.Union[json_rpc11.output.EndpointWithHostLabelOperationOutput, typing.Awaitable[json_rpc11.output.EndpointWithHostLabelOperationOutput]]], typing.Callable[[json_rpc11.input.EndpointWithHostLabelOperationInput], typing.Union[json_rpc11.output.EndpointWithHostLabelOperationOutput, typing.Awaitable[json_rpc11.output.EndpointWithHostLabelOperationOutput]]]]) -> None:
  165         -
        """
  166         -
        Method to register `endpoint_with_host_label_operation` Python implementation inside the handlers map.
  167         -
        It can be used as a function decorator in Python.
  168         -
        """
  169         -
        ...
  170         -
  171         -
  172         -
    def fractional_seconds(self, func: typing.Union[typing.Callable[[json_rpc11.input.FractionalSecondsInput, Ctx], typing.Union[json_rpc11.output.FractionalSecondsOutput, typing.Awaitable[json_rpc11.output.FractionalSecondsOutput]]], typing.Callable[[json_rpc11.input.FractionalSecondsInput], typing.Union[json_rpc11.output.FractionalSecondsOutput, typing.Awaitable[json_rpc11.output.FractionalSecondsOutput]]]]) -> None:
  173         -
        """
  174         -
        Method to register `fractional_seconds` Python implementation inside the handlers map.
  175         -
        It can be used as a function decorator in Python.
  176         -
        """
  177         -
        ...
  178         -
  179         -
  180         -
    def greeting_with_errors(self, func: typing.Union[typing.Callable[[json_rpc11.input.GreetingWithErrorsInput, Ctx], typing.Union[json_rpc11.output.GreetingWithErrorsOutput, typing.Awaitable[json_rpc11.output.GreetingWithErrorsOutput]]], typing.Callable[[json_rpc11.input.GreetingWithErrorsInput], typing.Union[json_rpc11.output.GreetingWithErrorsOutput, typing.Awaitable[json_rpc11.output.GreetingWithErrorsOutput]]]]) -> None:
  181         -
        """
  182         -
        Method to register `greeting_with_errors` Python implementation inside the handlers map.
  183         -
        It can be used as a function decorator in Python.
  184         -
        """
  185         -
        ...
  186         -
  187         -
  188         -
    def host_with_path_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.HostWithPathOperationInput, Ctx], typing.Union[json_rpc11.output.HostWithPathOperationOutput, typing.Awaitable[json_rpc11.output.HostWithPathOperationOutput]]], typing.Callable[[json_rpc11.input.HostWithPathOperationInput], typing.Union[json_rpc11.output.HostWithPathOperationOutput, typing.Awaitable[json_rpc11.output.HostWithPathOperationOutput]]]]) -> None:
  189         -
        """
  190         -
        Method to register `host_with_path_operation` Python implementation inside the handlers map.
  191         -
        It can be used as a function decorator in Python.
  192         -
        """
  193         -
        ...
  194         -
  195         -
  196         -
    def json_enums(self, func: typing.Union[typing.Callable[[json_rpc11.input.JsonEnumsInput, Ctx], typing.Union[json_rpc11.output.JsonEnumsOutput, typing.Awaitable[json_rpc11.output.JsonEnumsOutput]]], typing.Callable[[json_rpc11.input.JsonEnumsInput], typing.Union[json_rpc11.output.JsonEnumsOutput, typing.Awaitable[json_rpc11.output.JsonEnumsOutput]]]]) -> None:
  197         -
        """
  198         -
        Method to register `json_enums` Python implementation inside the handlers map.
  199         -
        It can be used as a function decorator in Python.
  200         -
        """
  201         -
        ...
  202         -
  203         -
  204         -
    def json_unions(self, func: typing.Union[typing.Callable[[json_rpc11.input.JsonUnionsInput, Ctx], typing.Union[json_rpc11.output.JsonUnionsOutput, typing.Awaitable[json_rpc11.output.JsonUnionsOutput]]], typing.Callable[[json_rpc11.input.JsonUnionsInput], typing.Union[json_rpc11.output.JsonUnionsOutput, typing.Awaitable[json_rpc11.output.JsonUnionsOutput]]]]) -> None:
  205         -
        """
  206         -
        Method to register `json_unions` Python implementation inside the handlers map.
  207         -
        It can be used as a function decorator in Python.
  208         -
        """
  209         -
        ...
  210         -
  211         -
  212         -
    def kitchen_sink_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.KitchenSinkOperationInput, Ctx], typing.Union[json_rpc11.output.KitchenSinkOperationOutput, typing.Awaitable[json_rpc11.output.KitchenSinkOperationOutput]]], typing.Callable[[json_rpc11.input.KitchenSinkOperationInput], typing.Union[json_rpc11.output.KitchenSinkOperationOutput, typing.Awaitable[json_rpc11.output.KitchenSinkOperationOutput]]]]) -> None:
  213         -
        """
  214         -
        Method to register `kitchen_sink_operation` Python implementation inside the handlers map.
  215         -
        It can be used as a function decorator in Python.
  216         -
        """
  217         -
        ...
  218         -
  219         -
  220         -
    def middleware(self, func: typing.Callable[[json_rpc11.middleware.Request, typing.Callable[[json_rpc11.middleware.Request], typing.Awaitable[json_rpc11.middleware.Response]]], typing.Awaitable[json_rpc11.middleware.Response]]) -> None:
  221         -
        """
  222         -
        Register a Python function to be executed inside a Tower middleware layer.
  223         -
        """
  224         -
        ...
  225         -
  226         -
  227         -
    def null_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.NullOperationInput, Ctx], typing.Union[json_rpc11.output.NullOperationOutput, typing.Awaitable[json_rpc11.output.NullOperationOutput]]], typing.Callable[[json_rpc11.input.NullOperationInput], typing.Union[json_rpc11.output.NullOperationOutput, typing.Awaitable[json_rpc11.output.NullOperationOutput]]]]) -> None:
  228         -
        """
  229         -
        Method to register `null_operation` Python implementation inside the handlers map.
  230         -
        It can be used as a function decorator in Python.
  231         -
        """
  232         -
        ...
  233         -
  234         -
  235         -
    def operation_with_optional_input_output(self, func: typing.Union[typing.Callable[[json_rpc11.input.OperationWithOptionalInputOutputInput, Ctx], typing.Union[json_rpc11.output.OperationWithOptionalInputOutputOutput, typing.Awaitable[json_rpc11.output.OperationWithOptionalInputOutputOutput]]], typing.Callable[[json_rpc11.input.OperationWithOptionalInputOutputInput], typing.Union[json_rpc11.output.OperationWithOptionalInputOutputOutput, typing.Awaitable[json_rpc11.output.OperationWithOptionalInputOutputOutput]]]]) -> None:
  236         -
        """
  237         -
        Method to register `operation_with_optional_input_output` Python implementation inside the handlers map.
  238         -
        It can be used as a function decorator in Python.
  239         -
        """
  240         -
        ...
  241         -
  242         -
  243         -
    def put_and_get_inline_documents(self, func: typing.Union[typing.Callable[[json_rpc11.input.PutAndGetInlineDocumentsInput, Ctx], typing.Union[json_rpc11.output.PutAndGetInlineDocumentsOutput, typing.Awaitable[json_rpc11.output.PutAndGetInlineDocumentsOutput]]], typing.Callable[[json_rpc11.input.PutAndGetInlineDocumentsInput], typing.Union[json_rpc11.output.PutAndGetInlineDocumentsOutput, typing.Awaitable[json_rpc11.output.PutAndGetInlineDocumentsOutput]]]]) -> None:
  244         -
        """
  245         -
        Method to register `put_and_get_inline_documents` Python implementation inside the handlers map.
  246         -
        It can be used as a function decorator in Python.
  247         -
        """
  248         -
        ...
  249         -
  250         -
  251         -
    def put_with_content_encoding(self, func: typing.Union[typing.Callable[[json_rpc11.input.PutWithContentEncodingInput, Ctx], typing.Union[json_rpc11.output.PutWithContentEncodingOutput, typing.Awaitable[json_rpc11.output.PutWithContentEncodingOutput]]], typing.Callable[[json_rpc11.input.PutWithContentEncodingInput], typing.Union[json_rpc11.output.PutWithContentEncodingOutput, typing.Awaitable[json_rpc11.output.PutWithContentEncodingOutput]]]]) -> None:
  252         -
        """
  253         -
        Method to register `put_with_content_encoding` Python implementation inside the handlers map.
  254         -
        It can be used as a function decorator in Python.
  255         -
        """
  256         -
        ...
  257         -
  258         -
  259         -
    def run(self, address: typing.Optional[str] = ..., port: typing.Optional[int] = ..., backlog: typing.Optional[int] = ..., workers: typing.Optional[int] = ..., tls: typing.Optional[json_rpc11.tls.TlsConfig] = ...) -> None:
  260         -
        """
  261         -
        Main entrypoint: start the server on multiple workers.
  262         -
        """
  263         -
        ...
  264         -
  265         -
  266         -
    def run_lambda(self) -> None:
  267         -
        """
  268         -
        Lambda entrypoint: start the server on Lambda.
  269         -
        """
  270         -
        ...
  271         -
  272         -
  273         -
    def simple_scalar_properties(self, func: typing.Union[typing.Callable[[json_rpc11.input.SimpleScalarPropertiesInput, Ctx], typing.Union[json_rpc11.output.SimpleScalarPropertiesOutput, typing.Awaitable[json_rpc11.output.SimpleScalarPropertiesOutput]]], typing.Callable[[json_rpc11.input.SimpleScalarPropertiesInput], typing.Union[json_rpc11.output.SimpleScalarPropertiesOutput, typing.Awaitable[json_rpc11.output.SimpleScalarPropertiesOutput]]]]) -> None:
  274         -
        """
  275         -
        Method to register `simple_scalar_properties` Python implementation inside the handlers map.
  276         -
        It can be used as a function decorator in Python.
  277         -
        """
  278         -
        ...
  279         -
  280         -
  281         -
    def sparse_nulls_operation(self, func: typing.Union[typing.Callable[[json_rpc11.input.SparseNullsOperationInput, Ctx], typing.Union[json_rpc11.output.SparseNullsOperationOutput, typing.Awaitable[json_rpc11.output.SparseNullsOperationOutput]]], typing.Callable[[json_rpc11.input.SparseNullsOperationInput], typing.Union[json_rpc11.output.SparseNullsOperationOutput, typing.Awaitable[json_rpc11.output.SparseNullsOperationOutput]]]]) -> None:
  282         -
        """
  283         -
        Method to register `sparse_nulls_operation` Python implementation inside the handlers map.
  284         -
        It can be used as a function decorator in Python.
  285         -
        """
  286         -
        ...
  287         -
  288         -
  289         -
    def start_worker(self) -> None:
  290         -
        """
  291         -
        Build the service and start a single worker.
  292         -
        """
  293         -
        ...
  294         -
  295         -
  296         -
    def __init__(self) -> None:
  297         -
        ...
  298         -
  299         -
  300         -
CODEGEN_VERSION: str = ...

tmp-codegen-diff/codegen-server-test-python/json_rpc11/rust-server-codegen-python/python/json_rpc11/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/json_rpc11/rust-server-codegen-python/python/json_rpc11/error/__init__.pyi

@@ -1,0 +88,0 @@
    1         -
import json_rpc11.model
    2         -
import typing
    3         -
    4         -
class ComplexError(Exception):
    5         -
    """
    6         -
    This error is thrown when a request is invalid.
    7         -
    """
    8         -
    9         -
    nested: typing.Optional[json_rpc11.model.ComplexNestedErrorData]
   10         -
   11         -
    top_level: typing.Optional[str]
   12         -
   13         -
    def __init__(self, top_level: typing.Optional[str] = ..., nested: typing.Optional[json_rpc11.model.ComplexNestedErrorData] = ...) -> None:
   14         -
        ...
   15         -
   16         -
   17         -
class ErrorWithMembers(Exception):
   18         -
    code: typing.Optional[str]
   19         -
   20         -
    complex_data: typing.Optional[json_rpc11.model.KitchenSink]
   21         -
   22         -
    integer_field: typing.Optional[int]
   23         -
   24         -
    list_field: typing.Optional[typing.List[str]]
   25         -
   26         -
    map_field: typing.Optional[typing.Dict[str, str]]
   27         -
   28         -
    message: typing.Optional[str]
   29         -
   30         -
    string_field: typing.Optional[str]
   31         -
    """
   32         -
    abc
   33         -
    """
   34         -
   35         -
    def __init__(self, code: typing.Optional[str] = ..., complex_data: typing.Optional[json_rpc11.model.KitchenSink] = ..., integer_field: typing.Optional[int] = ..., list_field: typing.Optional[typing.List[str]] = ..., map_field: typing.Optional[typing.Dict[str, str]] = ..., message: typing.Optional[str] = ..., string_field: typing.Optional[str] = ...) -> None:
   36         -
        ...
   37         -
   38         -
   39         -
class ErrorWithoutMembers(Exception):
   40         -
    def __init__(self) -> None:
   41         -
        ...
   42         -
   43         -
   44         -
class FooError(Exception):
   45         -
    """
   46         -
    This error has test cases that test some of the dark corners of Amazon service framework history. It should only be implemented by clients.
   47         -
    """
   48         -
   49         -
    def __init__(self) -> None:
   50         -
        ...
   51         -
   52         -
   53         -
class InternalServerError(Exception):
   54         -
    message: str
   55         -
   56         -
    def __init__(self, message: str) -> None:
   57         -
        ...
   58         -
   59         -
   60         -
class InvalidGreeting(Exception):
   61         -
    """
   62         -
    This error is thrown when an invalid greeting value is provided.
   63         -
    """
   64         -
   65         -
    message: typing.Optional[str]
   66         -
   67         -
    def __init__(self, message: typing.Optional[str] = ...) -> None:
   68         -
        ...
   69         -
   70         -
   71         -
class ValidationException(Exception):
   72         -
    """
   73         -
    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.
   74         -
    """
   75         -
   76         -
    field_list: typing.Optional[typing.List[json_rpc11.model.ValidationExceptionField]]
   77         -
    """
   78         -
    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.
   79         -
    """
   80         -
   81         -
    message: str
   82         -
    """
   83         -
    A summary of the validation failure.
   84         -
    """
   85         -
   86         -
    def __init__(self, message: str, field_list: typing.Optional[typing.List[json_rpc11.model.ValidationExceptionField]] = ...) -> None:
   87         -
        ...
   88         -