ruff-only #1
|
@ -118,7 +118,7 @@ class Blueprint(BaseSanic):
|
|||
name: str,
|
||||
url_prefix: str | None = None,
|
||||
host: list[str] | str | None = None,
|
||||
version: int | (str | float) | None = None,
|
||||
version: int | str | float | None = None,
|
||||
strict_slashes: bool | None = None,
|
||||
version_prefix: str = "/v",
|
||||
):
|
||||
|
@ -203,7 +203,7 @@ class Blueprint(BaseSanic):
|
|||
self,
|
||||
name: str,
|
||||
url_prefix: str | Default | None = _default,
|
||||
version: int | (str | (float | Default)) | None = _default,
|
||||
version: int | str | float | Default | None = _default,
|
||||
version_prefix: str | Default = _default,
|
||||
allow_route_overwrite: bool | Default = _default,
|
||||
strict_slashes: bool | Default | None = _default,
|
||||
|
@ -273,7 +273,7 @@ class Blueprint(BaseSanic):
|
|||
def group(
|
||||
*blueprints: Blueprint | BlueprintGroup,
|
||||
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 = "",
|
||||
|
@ -675,7 +675,7 @@ class BlueprintGroup(bpg_base):
|
|||
self._name_prefix = name_prefix
|
||||
|
||||
@property
|
||||
def url_prefix(self) -> int | (str | float) | None:
|
||||
def url_prefix(self) -> int | str | float | None:
|
||||
"""The URL prefix for the Blueprint Group.
|
||||
|
||||
Returns:
|
||||
|
@ -695,7 +695,7 @@ class BlueprintGroup(bpg_base):
|
|||
return self._blueprints
|
||||
|
||||
@property
|
||||
def version(self) -> str | (int | float) | None:
|
||||
def version(self) -> str | int | float | None:
|
||||
"""API Version for the Blueprint Group, if any.
|
||||
|
||||
Returns:
|
||||
|
|
|
@ -98,14 +98,14 @@ class Config(dict, metaclass=DescriptorMeta):
|
|||
INSPECTOR: bool
|
||||
INSPECTOR_HOST: str
|
||||
INSPECTOR_PORT: int
|
||||
INSPECTOR_TLS_KEY: Path | (str | Default)
|
||||
INSPECTOR_TLS_CERT: Path | (str | Default)
|
||||
INSPECTOR_TLS_KEY: Path | str | Default
|
||||
INSPECTOR_TLS_CERT: Path | str | Default
|
||||
INSPECTOR_API_KEY: str
|
||||
KEEP_ALIVE_TIMEOUT: int
|
||||
KEEP_ALIVE: bool
|
||||
LOCAL_CERT_CREATOR: str | LocalCertCreator
|
||||
LOCAL_TLS_KEY: Path | (str | Default)
|
||||
LOCAL_TLS_CERT: Path | (str | Default)
|
||||
LOCAL_TLS_KEY: Path | str | Default
|
||||
LOCAL_TLS_CERT: Path | str | Default
|
||||
LOCALHOST: str
|
||||
MOTD: bool
|
||||
MOTD_DISPLAY: dict[str, str]
|
||||
|
@ -323,7 +323,7 @@ class Config(dict, metaclass=DescriptorMeta):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
def update_config(self, config: bytes | (str | (dict | Any))):
|
||||
def update_config(self, config: bytes | str | dict | Any):
|
||||
"""Update app.config.
|
||||
|
||||
.. note::
|
||||
|
|
|
@ -529,7 +529,7 @@ def format_http1_response(status: int, headers: HeaderBytesIterable) -> bytes:
|
|||
|
||||
def parse_credentials(
|
||||
header: str | None,
|
||||
prefixes: list | (tuple | set) | None = None,
|
||||
prefixes: list | tuple | set | None = None,
|
||||
) -> tuple[str | None, str | None]:
|
||||
"""Parses any header with the aim to retrieve any credentials from it.
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ def shorthand_to_ctx(
|
|||
|
||||
|
||||
def process_to_context(
|
||||
ssldef: None | (ssl.SSLContext | (dict | (str | (list | tuple))))
|
||||
ssldef: None | ssl.SSLContext | dict | str | list | tuple
|
||||
) -> ssl.SSLContext | None:
|
||||
"""Process app.run ssl argument from easy formats to full SSLContext."""
|
||||
return (
|
||||
|
|
|
@ -157,7 +157,7 @@ class StartupMixin(metaclass=SanicMeta):
|
|||
debug: bool = False,
|
||||
auto_reload: bool | None = None,
|
||||
version: HTTPVersion = HTTP.VERSION_1,
|
||||
ssl: None | (SSLContext | (dict | (str | (list | tuple)))) = None,
|
||||
ssl: None | SSLContext | dict | str | list | tuple = None,
|
||||
sock: socket | None = None,
|
||||
workers: int = 1,
|
||||
protocol: type[Protocol] | None = None,
|
||||
|
@ -287,7 +287,7 @@ class StartupMixin(metaclass=SanicMeta):
|
|||
debug: bool = False,
|
||||
auto_reload: bool | None = None,
|
||||
version: HTTPVersion = HTTP.VERSION_1,
|
||||
ssl: None | (SSLContext | (dict | (str | (list | tuple)))) = None,
|
||||
ssl: None | SSLContext | dict | str | list | tuple = None,
|
||||
sock: socket | None = None,
|
||||
workers: int = 1,
|
||||
protocol: type[Protocol] | None = None,
|
||||
|
@ -466,7 +466,7 @@ class StartupMixin(metaclass=SanicMeta):
|
|||
port: int | None = None,
|
||||
*,
|
||||
debug: bool = False,
|
||||
ssl: None | (SSLContext | (dict | (str | (list | tuple)))) = None,
|
||||
ssl: None | SSLContext | dict | str | list | tuple = None,
|
||||
sock: socket | None = None,
|
||||
protocol: type[Protocol] | None = None,
|
||||
backlog: int = 100,
|
||||
|
@ -632,7 +632,7 @@ class StartupMixin(metaclass=SanicMeta):
|
|||
port: int | None = None,
|
||||
debug: bool = False,
|
||||
version: HTTPVersion = HTTP.VERSION_1,
|
||||
ssl: None | (SSLContext | (dict | (str | (list | tuple)))) = None,
|
||||
ssl: None | SSLContext | dict | str | list | tuple = None,
|
||||
sock: socket | None = None,
|
||||
unix: str | None = None,
|
||||
workers: int = 1,
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Any
|
|||
class RequestParameters(dict):
|
||||
"""Hosts a dict with lists as values where get returns the first value of the list and getlist returns the whole shebang""" # noqa: E501
|
||||
|
||||
def get(self, name: str, default: Any | None = None) -> Any | None:
|
||||
def get(self, name: str, default: Any = None) -> Any:
|
||||
"""Return the first value, either the default or actual
|
||||
|
||||
Args:
|
||||
|
@ -18,7 +18,7 @@ class RequestParameters(dict):
|
|||
""" # noqa: E501
|
||||
return super().get(name, [default])[0]
|
||||
|
||||
def getlist(self, name: str, default: Any | None = None) -> Any | None:
|
||||
def getlist(self, name: str, default: Any = None) -> Any:
|
||||
"""Return the entire list
|
||||
|
||||
Args:
|
||||
|
|
|
@ -155,7 +155,7 @@ class Request(Generic[sanic_type, ctx_type]):
|
|||
except HttpParserInvalidURLError:
|
||||
url = url_bytes.decode(errors="backslashreplace")
|
||||
raise BadURL(f"Bad URL: {url}")
|
||||
self._id: uuid.UUID | (str | int) | None = None
|
||||
self._id: uuid.UUID | str | int | None = None
|
||||
self._name: str | None = None
|
||||
self._stream_id = stream_id
|
||||
self.app = app
|
||||
|
@ -245,7 +245,7 @@ class Request(Generic[sanic_type, ctx_type]):
|
|||
return request
|
||||
|
||||
@classmethod
|
||||
def generate_id(*_) -> uuid.UUID | (str | int):
|
||||
def generate_id(*_) -> uuid.UUID | str | int:
|
||||
"""Generate a unique ID for the request.
|
||||
|
||||
This method is called to generate a unique ID for each request.
|
||||
|
@ -488,7 +488,7 @@ class Request(Generic[sanic_type, ctx_type]):
|
|||
return bytes(reqline)
|
||||
|
||||
@property
|
||||
def id(self) -> uuid.UUID | (str | int) | None:
|
||||
def id(self) -> uuid.UUID | str | int | None:
|
||||
"""A request ID passed from the client, or generated from the backend.
|
||||
|
||||
By default, this will look in a request header defined at:
|
||||
|
|
|
@ -120,7 +120,7 @@ def raw(
|
|||
|
||||
|
||||
def html(
|
||||
body: str | (bytes | HTMLProtocol),
|
||||
body: str | bytes | HTMLProtocol,
|
||||
status: int = 200,
|
||||
headers: dict[str, str] | None = None,
|
||||
) -> HTTPResponse:
|
||||
|
@ -151,7 +151,7 @@ def html(
|
|||
|
||||
|
||||
async def validate_file(
|
||||
request_headers: Header, last_modified: datetime | (float | int)
|
||||
request_headers: Header, last_modified: datetime | float | int
|
||||
) -> HTTPResponse | None:
|
||||
"""Validate file based on request headers.
|
||||
|
||||
|
@ -170,8 +170,7 @@ async def validate_file(
|
|||
if_modified_since = parsedate_to_datetime(if_modified_since)
|
||||
except (TypeError, ValueError):
|
||||
logger.warning(
|
||||
"Ignoring invalid If-Modified-Since header received: '%s'",
|
||||
if_modified_since,
|
||||
f"Ignoring invalid If-Modified-Since header received: '{if_modified_since}'"
|
||||
)
|
||||
return None
|
||||
if not isinstance(last_modified, datetime):
|
||||
|
@ -211,7 +210,7 @@ async def file(
|
|||
mime_type: str | None = None,
|
||||
headers: dict[str, str] | None = None,
|
||||
filename: str | None = None,
|
||||
last_modified: datetime | (float | (int | Default)) | None = _default,
|
||||
last_modified: datetime | float | int | Default | None = _default,
|
||||
max_age: float | int | None = None,
|
||||
no_store: bool | None = None,
|
||||
_range: Range | None = None,
|
||||
|
|
|
@ -64,7 +64,7 @@ class BaseHTTPResponse:
|
|||
self.asgi: bool = False
|
||||
self.body: bytes | None = None
|
||||
self.content_type: str | None = None
|
||||
self.stream: Http | (ASGIApp | HTTPReceiver) | None = None
|
||||
self.stream: Http | ASGIApp | HTTPReceiver | None = None
|
||||
self.status: int = None
|
||||
self.headers = Header({})
|
||||
self._cookies: CookieJar | None = None
|
||||
|
|
|
@ -82,7 +82,7 @@ class Router(BaseRouter):
|
|||
strict_slashes: bool = False,
|
||||
stream: bool = False,
|
||||
ignore_body: bool = False,
|
||||
version: str | (float | int) | None = None,
|
||||
version: str | float | int | None = None,
|
||||
name: str | None = None,
|
||||
unquote: bool = False,
|
||||
static: bool = False,
|
||||
|
|
|
@ -128,4 +128,4 @@ def load_module_from_file_location(
|
|||
try:
|
||||
return import_string(location)
|
||||
except ValueError:
|
||||
raise OSError("Unable to load configuration %s" % str(location))
|
||||
raise OSError(f"Unable to load configuration {location!s}")
|
||||
|
|
Loading…
Reference in New Issue
Block a user