Hand-fixed typing extra () and changed some formatting to f-strings that Ruff had missed

This commit is contained in:
L. Kärkkäinen
2023-10-25 02:36:08 +00:00
committed by GitHub
parent 6fac60c6fe
commit cdc5dd6b75
11 changed files with 28 additions and 29 deletions

View File

@@ -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:

View File

@@ -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: