Server Test Python

Server Test Python

rev. 399187927edd9a1e762efeae060e3a56d671920a (ignoring whitespace)

Files changed:

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

@@ -1,0 +8,0 @@
    1         -
    2         -
    3         -
class InternalServerError(Exception):
    4         -
    message: str
    5         -
    6         -
    def __init__(self, message: str) -> None:
    7         -
        ...
    8         -

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

@@ -1,0 +6,0 @@
    1         -
    2         -
    3         -
class DoNothingInput:
    4         -
    def __init__(self) -> None:
    5         -
        ...
    6         -

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

@@ -1,0 +6,0 @@
    1         -
    2         -
    3         -
class DoNothingOutput:
    4         -
    def __init__(self) -> None:
    5         -
        ...
    6         -

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

@@ -1,0 +167,0 @@
    1         -
import naming_test_ops.input
    2         -
import naming_test_ops.middleware
    3         -
import naming_test_ops.output
    4         -
import naming_test_ops.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 naming_test_ops import input
   20         -
    from naming_test_ops import output
   21         -
    from naming_test_ops import error
   22         -
    from naming_test_ops import middleware
   23         -
    from naming_test_ops 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.err_collisions
   38         -
    def err_collisions(input: input::ErrCollisionsInput, ctx: Context) -> output::ErrCollisionsOutput:
   39         -
        raise NotImplementedError
   40         -
   41         -
    @app.match
   42         -
    def match(input: input::MatchInput, ctx: Context) -> output::MatchOutput:
   43         -
        raise NotImplementedError
   44         -
   45         -
    @app.option
   46         -
    def option(input: input::OptionInput, ctx: Context) -> output::OptionOutput:
   47         -
        raise NotImplementedError
   48         -
   49         -
    @app.reserved_words_as_members
   50         -
    def reserved_words_as_members(input: input::ReservedWordsAsMembersInput, ctx: Context) -> output::ReservedWordsAsMembersOutput:
   51         -
        raise NotImplementedError
   52         -
   53         -
    @app.result
   54         -
    def result(input: input::ResultInput, ctx: Context) -> output::ResultOutput:
   55         -
        raise NotImplementedError
   56         -
   57         -
    @app.rpc_echo
   58         -
    def rpc_echo(input: input::RpcEchoInput, ctx: Context) -> output::RpcEchoOutput:
   59         -
        raise NotImplementedError
   60         -
   61         -
    @app.structure_name_punning
   62         -
    def structure_name_punning(input: input::StructureNamePunningInput, ctx: Context) -> output::StructureNamePunningOutput:
   63         -
        raise NotImplementedError
   64         -
   65         -
    app.run()
   66         -
    ```
   67         -
   68         -
    Any of operations above can be written as well prepending the `async` keyword and
   69         -
    the Python application will automatically handle it and schedule it on the event loop for you.
   70         -
    """
   71         -
   72         -
    def context(self, context: Ctx) -> None:
   73         -
        """
   74         -
        Register a context object that will be shared between handlers.
   75         -
        """
   76         -
        ...
   77         -
   78         -
   79         -
    def err_collisions(self, func: typing.Union[typing.Callable[[naming_test_ops.input.ErrCollisionsInput, Ctx], typing.Union[naming_test_ops.output.ErrCollisionsOutput, typing.Awaitable[naming_test_ops.output.ErrCollisionsOutput]]], typing.Callable[[naming_test_ops.input.ErrCollisionsInput], typing.Union[naming_test_ops.output.ErrCollisionsOutput, typing.Awaitable[naming_test_ops.output.ErrCollisionsOutput]]]]) -> None:
   80         -
        """
   81         -
        Method to register `err_collisions` Python implementation inside the handlers map.
   82         -
        It can be used as a function decorator in Python.
   83         -
        """
   84         -
        ...
   85         -
   86         -
   87         -
    def match(self, func: typing.Union[typing.Callable[[naming_test_ops.input.MatchInput, Ctx], typing.Union[naming_test_ops.output.MatchOutput, typing.Awaitable[naming_test_ops.output.MatchOutput]]], typing.Callable[[naming_test_ops.input.MatchInput], typing.Union[naming_test_ops.output.MatchOutput, typing.Awaitable[naming_test_ops.output.MatchOutput]]]]) -> None:
   88         -
        """
   89         -
        Method to register `r#match` Python implementation inside the handlers map.
   90         -
        It can be used as a function decorator in Python.
   91         -
        """
   92         -
        ...
   93         -
   94         -
   95         -
    def middleware(self, func: typing.Callable[[naming_test_ops.middleware.Request, typing.Callable[[naming_test_ops.middleware.Request], typing.Awaitable[naming_test_ops.middleware.Response]]], typing.Awaitable[naming_test_ops.middleware.Response]]) -> None:
   96         -
        """
   97         -
        Register a Python function to be executed inside a Tower middleware layer.
   98         -
        """
   99         -
        ...
  100         -
  101         -
  102         -
    def option(self, func: typing.Union[typing.Callable[[naming_test_ops.input.OptionInput, Ctx], typing.Union[naming_test_ops.output.OptionOutput, typing.Awaitable[naming_test_ops.output.OptionOutput]]], typing.Callable[[naming_test_ops.input.OptionInput], typing.Union[naming_test_ops.output.OptionOutput, typing.Awaitable[naming_test_ops.output.OptionOutput]]]]) -> None:
  103         -
        """
  104         -
        Method to register `option` Python implementation inside the handlers map.
  105         -
        It can be used as a function decorator in Python.
  106         -
        """
  107         -
        ...
  108         -
  109         -
  110         -
    def reserved_words_as_members(self, func: typing.Union[typing.Callable[[naming_test_ops.input.ReservedWordsAsMembersInput, Ctx], typing.Union[naming_test_ops.output.ReservedWordsAsMembersOutput, typing.Awaitable[naming_test_ops.output.ReservedWordsAsMembersOutput]]], typing.Callable[[naming_test_ops.input.ReservedWordsAsMembersInput], typing.Union[naming_test_ops.output.ReservedWordsAsMembersOutput, typing.Awaitable[naming_test_ops.output.ReservedWordsAsMembersOutput]]]]) -> None:
  111         -
        """
  112         -
        Method to register `reserved_words_as_members` Python implementation inside the handlers map.
  113         -
        It can be used as a function decorator in Python.
  114         -
        """
  115         -
        ...
  116         -
  117         -
  118         -
    def result(self, func: typing.Union[typing.Callable[[naming_test_ops.input.ResultInput, Ctx], typing.Union[naming_test_ops.output.ResultOutput, typing.Awaitable[naming_test_ops.output.ResultOutput]]], typing.Callable[[naming_test_ops.input.ResultInput], typing.Union[naming_test_ops.output.ResultOutput, typing.Awaitable[naming_test_ops.output.ResultOutput]]]]) -> None:
  119         -
        """
  120         -
        Method to register `result` Python implementation inside the handlers map.
  121         -
        It can be used as a function decorator in Python.
  122         -
        """
  123         -
        ...
  124         -
  125         -
  126         -
    def rpc_echo(self, func: typing.Union[typing.Callable[[naming_test_ops.input.RPCEchoInput, Ctx], typing.Union[naming_test_ops.output.RPCEchoOutput, typing.Awaitable[naming_test_ops.output.RPCEchoOutput]]], typing.Callable[[naming_test_ops.input.RPCEchoInput], typing.Union[naming_test_ops.output.RPCEchoOutput, typing.Awaitable[naming_test_ops.output.RPCEchoOutput]]]]) -> None:
  127         -
        """
  128         -
        Method to register `rpc_echo` Python implementation inside the handlers map.
  129         -
        It can be used as a function decorator in Python.
  130         -
        """
  131         -
        ...
  132         -
  133         -
  134         -
    def run(self, address: typing.Optional[str] = ..., port: typing.Optional[int] = ..., backlog: typing.Optional[int] = ..., workers: typing.Optional[int] = ..., tls: typing.Optional[naming_test_ops.tls.TlsConfig] = ...) -> None:
  135         -
        """
  136         -
        Main entrypoint: start the server on multiple workers.
  137         -
        """
  138         -
        ...
  139         -
  140         -
  141         -
    def run_lambda(self) -> None:
  142         -
        """
  143         -
        Lambda entrypoint: start the server on Lambda.
  144         -
        """
  145         -
        ...
  146         -
  147         -
  148         -
    def start_worker(self) -> None:
  149         -
        """
  150         -
        Build the service and start a single worker.
  151         -
        """
  152         -
        ...
  153         -
  154         -
  155         -
    def structure_name_punning(self, func: typing.Union[typing.Callable[[naming_test_ops.input.StructureNamePunningInput, Ctx], typing.Union[naming_test_ops.output.StructureNamePunningOutput, typing.Awaitable[naming_test_ops.output.StructureNamePunningOutput]]], typing.Callable[[naming_test_ops.input.StructureNamePunningInput], typing.Union[naming_test_ops.output.StructureNamePunningOutput, typing.Awaitable[naming_test_ops.output.StructureNamePunningOutput]]]]) -> None:
  156         -
        """
  157         -
        Method to register `structure_name_punning` Python implementation inside the handlers map.
  158         -
        It can be used as a function decorator in Python.
  159         -
        """
  160         -
        ...
  161         -
  162         -
  163         -
    def __init__(self) -> None:
  164         -
        ...
  165         -
  166         -
  167         -
CODEGEN_VERSION: str = ...

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

@@ -1,0 +42,0 @@
    1         -
import naming_test_ops.model
    2         -
import typing
    3         -
    4         -
class CollidingError(Exception):
    5         -
    def __init__(self) -> None:
    6         -
        ...
    7         -
    8         -
    9         -
class CollidingException(Exception):
   10         -
    """
   11         -
    This will be renamed to CollidingError
   12         -
    """
   13         -
   14         -
    def __init__(self) -> None:
   15         -
        ...
   16         -
   17         -
   18         -
class InternalServerError(Exception):
   19         -
    message: str
   20         -
   21         -
    def __init__(self, message: str) -> None:
   22         -
        ...
   23         -
   24         -
   25         -
class ValidationException(Exception):
   26         -
    """
   27         -
    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.
   28         -
    """
   29         -
   30         -
    field_list: typing.Optional[typing.List[naming_test_ops.model.ValidationExceptionField]]
   31         -
    """
   32         -
    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.
   33         -
    """
   34         -
   35         -
    message: str
   36         -
    """
   37         -
    A summary of the validation failure.
   38         -
    """
   39         -
   40         -
    def __init__(self, message: str, field_list: typing.Optional[typing.List[naming_test_ops.model.ValidationExceptionField]] = ...) -> None:
   41         -
        ...
   42         -

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

@@ -1,0 +99,0 @@
    1         -
import naming_test_ops.model
    2         -
import typing
    3         -
    4         -
class ErrCollisionsInput:
    5         -
    def __init__(self) -> None:
    6         -
        ...
    7         -
    8         -
    9         -
class MatchInput:
   10         -
    as: typing.Optional[int]
   11         -
   12         -
    async: typing.Optional[bool]
   13         -
   14         -
    build_value: typing.Optional[str]
   15         -
   16         -
    crate_: typing.Optional[bool]
   17         -
   18         -
    default_value: typing.Optional[str]
   19         -
   20         -
    enum: typing.Optional[naming_test_ops.model.UnknownVariantCollidingEnum]
   21         -
   22         -
    self_: typing.Optional[bool]
   23         -
   24         -
    send: typing.Optional[str]
   25         -
   26         -
    super_: typing.Optional[bool]
   27         -
   28         -
    def __init__(self, r#as: typing.Optional[int] = ..., r#async: typing.Optional[bool] = ..., r#enum: typing.Optional[naming_test_ops.model.UnknownVariantCollidingEnum] = ..., self_: typing.Optional[bool] = ..., crate_: typing.Optional[bool] = ..., super_: typing.Optional[bool] = ..., build_value: typing.Optional[str] = ..., default_value: typing.Optional[str] = ..., send: typing.Optional[str] = ...) -> None:
   29         -
        ...
   30         -
   31         -
   32         -
class OptionInput:
   33         -
    pv_member: typing.Optional[bool]
   34         -
   35         -
    def __init__(self, pv_member: typing.Optional[bool] = ...) -> None:
   36         -
        ...
   37         -
   38         -
   39         -
class ReservedWordsAsMembersInput:
   40         -
    as: typing.Optional[int]
   41         -
   42         -
    async: typing.Optional[bool]
   43         -
   44         -
    build_value: typing.Optional[str]
   45         -
   46         -
    crate_: typing.Optional[bool]
   47         -
   48         -
    default_value: typing.Optional[str]
   49         -
   50         -
    enum: typing.Optional[naming_test_ops.model.UnknownVariantCollidingEnum]
   51         -
   52         -
    self_: typing.Optional[bool]
   53         -
   54         -
    send: typing.Optional[str]
   55         -
   56         -
    super_: typing.Optional[bool]
   57         -
   58         -
    def __init__(self, r#as: typing.Optional[int] = ..., r#async: typing.Optional[bool] = ..., r#enum: typing.Optional[naming_test_ops.model.UnknownVariantCollidingEnum] = ..., self_: typing.Optional[bool] = ..., crate_: typing.Optional[bool] = ..., super_: typing.Optional[bool] = ..., build_value: typing.Optional[str] = ..., default_value: typing.Optional[str] = ..., send: typing.Optional[str] = ...) -> None:
   59         -
        ...
   60         -
   61         -
   62         -
class ResultInput:
   63         -
    pv_member: typing.Optional[bool]
   64         -
   65         -
    def __init__(self, pv_member: typing.Optional[bool] = ...) -> None:
   66         -
        ...
   67         -
   68         -
   69         -
class RpcEchoInput:
   70         -
    as: typing.Optional[int]
   71         -
   72         -
    async: typing.Optional[bool]
   73         -
   74         -
    build_value: typing.Optional[str]
   75         -
   76         -
    crate_: typing.Optional[bool]
   77         -
   78         -
    default_value: typing.Optional[str]
   79         -
   80         -
    enum: typing.Optional[naming_test_ops.model.UnknownVariantCollidingEnum]
   81         -
   82         -
    self_: typing.Optional[bool]
   83         -
   84         -
    send: typing.Optional[str]
   85         -
   86         -
    super_: typing.Optional[bool]
   87         -
   88         -
    def __init__(self, r#as: typing.Optional[int] = ..., r#async: typing.Optional[bool] = ..., r#enum: typing.Optional[naming_test_ops.model.UnknownVariantCollidingEnum] = ..., self_: typing.Optional[bool] = ..., crate_: typing.Optional[bool] = ..., super_: typing.Optional[bool] = ..., build_value: typing.Optional[str] = ..., default_value: typing.Optional[str] = ..., send: typing.Optional[str] = ...) -> None:
   89         -
        ...
   90         -
   91         -
   92         -
class StructureNamePunningInput:
   93         -
    punned_vec: typing.Optional[naming_test_ops.model.Vec]
   94         -
   95         -
    regular_string: typing.Optional[str]
   96         -
   97         -
    def __init__(self, regular_string: typing.Optional[str] = ..., punned_vec: typing.Optional[naming_test_ops.model.Vec] = ...) -> None:
   98         -
        ...
   99         -

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/python/naming_test_ops/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/naming_test_ops/rust-server-codegen-python/python/naming_test_ops/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         -