ruff-only #1

Open
leo wants to merge 17 commits from ruff-only into main
4 changed files with 10 additions and 8 deletions
Showing only changes of commit c8d0c1bf28 - Show all commits

View File

@ -762,7 +762,7 @@ class Sanic(
blueprint: Blueprint | (Iterable[Blueprint] | BlueprintGroup), blueprint: Blueprint | (Iterable[Blueprint] | BlueprintGroup),
*, *,
url_prefix: str | None = None, url_prefix: str | None = None,
version: int | (float | str) | None = None, version: int | float | str | None = None,
strict_slashes: bool | None = None, strict_slashes: bool | None = None,
version_prefix: str | None = None, version_prefix: str | None = None,
name_prefix: str | None = None, name_prefix: str | None = None,
@ -1788,7 +1788,7 @@ class Sanic(
# Configuration # Configuration
# -------------------------------------------------------------------- # # -------------------------------------------------------------------- #
def update_config(self, config: bytes | (str | (dict | Any))) -> None: def update_config(self, config: Any) -> None:
"""Update the application configuration. """Update the application configuration.
This method is used to update the application configuration. It can 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. See [Configuration](/en/guide/deployment/configuration) for details.
Args: 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. dictionary, or path to a configuration file.
""" """

View File

@ -644,7 +644,7 @@ class BlueprintGroup(bpg_base):
def __init__( def __init__(
self, self,
url_prefix: str | None = None, url_prefix: str | None = None,
version: int | (str | float) | None = None, version: int | str | float | None = None,
strict_slashes: bool | None = None, strict_slashes: bool | None = None,
version_prefix: str = "/v", version_prefix: str = "/v",
name_prefix: str | None = "", name_prefix: str | None = "",

View File

@ -17,6 +17,8 @@ CIPHERS_TLS12 = [
"ECDHE-RSA-AES128-GCM-SHA256", "ECDHE-RSA-AES128-GCM-SHA256",
] ]
TlsDef = None | ssl.SSLContext | dict[str, Any] | str
TlsDefs = TlsDef | list[TlsDef] | tuple[TlsDef, ...]
def create_context( def create_context(
certfile: str | None = None, certfile: str | None = None,
@ -37,7 +39,7 @@ def create_context(
def shorthand_to_ctx( def shorthand_to_ctx(
ctxdef: None | (ssl.SSLContext | (dict | str)) ctxdef: TlsDef
) -> ssl.SSLContext | None: ) -> ssl.SSLContext | None:
"""Convert an ssl argument shorthand to an SSLContext object.""" """Convert an ssl argument shorthand to an SSLContext object."""
if ctxdef is None or isinstance(ctxdef, ssl.SSLContext): if ctxdef is None or isinstance(ctxdef, ssl.SSLContext):
@ -53,7 +55,7 @@ def shorthand_to_ctx(
def process_to_context( def process_to_context(
ssldef: None | ssl.SSLContext | dict | str | list | tuple ssldef: TlsDefs
) -> ssl.SSLContext | None: ) -> ssl.SSLContext | None:
"""Process app.run ssl argument from easy formats to full SSLContext.""" """Process app.run ssl argument from easy formats to full SSLContext."""
return ( return (

View File

@ -44,8 +44,8 @@ class Inspector:
host: str, host: str,
port: int, port: int,
api_key: str, api_key: str,
tls_key: Path | (str | Default), tls_key: Path | str | Default,
tls_cert: Path | (str | Default), tls_cert: Path | str | Default,
): ):
self._publisher = publisher self._publisher = publisher
self.app_info = app_info self.app_info = app_info