From 736bfaa6ecb93f17617593859683151a8212ed33 Mon Sep 17 00:00:00 2001 From: Damian Czajkowski Date: Tue, 24 Mar 2026 10:22:43 +0100 Subject: [PATCH] feat: add OPTIONS HTTP method support and apply minor code cleanup --- src/smyth/__main__.py | 8 ++++---- src/smyth/server/app.py | 2 +- src/smyth/utils.py | 2 +- tests/server/test_app.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/smyth/__main__.py b/src/smyth/__main__.py index 1f9469f..4aadb0c 100644 --- a/src/smyth/__main__.py +++ b/src/smyth/__main__.py @@ -2,7 +2,7 @@ import logging.config import os from enum import Enum -from typing import Annotated, Optional +from typing import Annotated import typer import uvicorn @@ -36,10 +36,10 @@ def run( ), # noqa: UP007 ] = "smyth.server.app:create_app", factory: Annotated[bool, typer.Option(help="Use factory for app creation")] = True, - host: Annotated[Optional[str], typer.Option()] = config.host, # noqa: UP007 - port: Annotated[Optional[int], typer.Option()] = config.port, # noqa: UP007 + host: Annotated[str | None, typer.Option()] = config.host, # noqa: UP007 + port: Annotated[int | None, typer.Option()] = config.port, # noqa: UP007 log_level: Annotated[ - Optional[LogLevel], # noqa: UP007 + LogLevel | None, # noqa: UP007 typer.Option( help=( "Override the log level specified in the configuration, " diff --git a/src/smyth/server/app.py b/src/smyth/server/app.py index 253bcee..8e4744c 100644 --- a/src/smyth/server/app.py +++ b/src/smyth/server/app.py @@ -48,7 +48,7 @@ def __init__(self, smyth: Smyth, smyth_path_prefix: str, *args: Any, **kwargs: A self.add_route( "/{path:path}", lambda_invoker_endpoint, - methods=["GET", "POST", "PUT", "DELETE"], + methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"], ) diff --git a/src/smyth/utils.py b/src/smyth/utils.py index 6bc47e2..d487ee9 100644 --- a/src/smyth/utils.py +++ b/src/smyth/utils.py @@ -98,7 +98,7 @@ def create_header_row(self, record: LogRecord) -> RenderableType: process_name = record.processName return Text.from_markup( - f"{issuer}:" f"[bold]{process_name}[/]", + f"{issuer}:[bold]{process_name}[/]", style="log.process", ) diff --git a/tests/server/test_app.py b/tests/server/test_app.py index ae7e757..33c39c9 100644 --- a/tests/server/test_app.py +++ b/tests/server/test_app.py @@ -72,7 +72,7 @@ def test_smyth_starlette(mocker): Route( "/{path:path}", lambda_invoker_endpoint, - methods=["DELETE", "GET", "HEAD", "POST", "PUT"], + methods=["DELETE", "GET", "HEAD", "POST", "PUT", "OPTIONS"], ), ]