diff --git a/sanic/app.py b/sanic/app.py index 42c2024b..2c114557 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -762,7 +762,7 @@ class Sanic( blueprint: Blueprint | (Iterable[Blueprint] | BlueprintGroup), *, url_prefix: str | None = None, - version: int | (float | str) | None = None, + version: int | float | str | None = None, strict_slashes: bool | None = None, version_prefix: str | None = None, name_prefix: str | None = None, @@ -1788,7 +1788,7 @@ class Sanic( # Configuration # -------------------------------------------------------------------- # - def update_config(self, config: bytes | (str | (dict | Any))) -> None: + def update_config(self, config: Any) -> None: """Update the application configuration. This method is used to update the application configuration. It can @@ -1798,7 +1798,7 @@ class Sanic( See [Configuration](/en/guide/deployment/configuration) for details. Args: - config (Union[bytes, str, dict, Any]): The configuration object, + config (bytes | str | dict | Any): The configuration object, dictionary, or path to a configuration file. """ diff --git a/sanic/blueprints.py b/sanic/blueprints.py index 53c408c7..758277e3 100644 --- a/sanic/blueprints.py +++ b/sanic/blueprints.py @@ -644,7 +644,7 @@ class BlueprintGroup(bpg_base): def __init__( self, url_prefix: str | None = None, - version: int | (str | float) | None = None, + version: int | str | float | None = None, strict_slashes: bool | None = None, version_prefix: str = "/v", name_prefix: str | None = "", diff --git a/sanic/http/tls/context.py b/sanic/http/tls/context.py index dffb2201..193ae165 100644 --- a/sanic/http/tls/context.py +++ b/sanic/http/tls/context.py @@ -17,6 +17,8 @@ CIPHERS_TLS12 = [ "ECDHE-RSA-AES128-GCM-SHA256", ] +TlsDef = None | ssl.SSLContext | dict[str, Any] | str +TlsDefs = TlsDef | list[TlsDef] | tuple[TlsDef, ...] def create_context( certfile: str | None = None, @@ -37,7 +39,7 @@ def create_context( def shorthand_to_ctx( - ctxdef: None | (ssl.SSLContext | (dict | str)) + ctxdef: TlsDef ) -> ssl.SSLContext | None: """Convert an ssl argument shorthand to an SSLContext object.""" if ctxdef is None or isinstance(ctxdef, ssl.SSLContext): @@ -53,7 +55,7 @@ def shorthand_to_ctx( def process_to_context( - ssldef: None | ssl.SSLContext | dict | str | list | tuple + ssldef: TlsDefs ) -> ssl.SSLContext | None: """Process app.run ssl argument from easy formats to full SSLContext.""" return ( diff --git a/sanic/worker/inspector.py b/sanic/worker/inspector.py index ce294109..b22dabea 100644 --- a/sanic/worker/inspector.py +++ b/sanic/worker/inspector.py @@ -44,8 +44,8 @@ class Inspector: host: str, port: int, api_key: str, - tls_key: Path | (str | Default), - tls_cert: Path | (str | Default), + tls_key: Path | str | Default, + tls_cert: Path | str | Default, ): self._publisher = publisher self.app_info = app_info